Updating pyglet.text.Label from another thread

164 views
Skip to first unread message

Jason Spashett

unread,
Jan 27, 2016, 11:11:22 AM1/27/16
to pyglet-users
Hello Again,

I would like to update a pyglet Label from some other thread. It seems that this won't work directly (as is usual with ui toolkits)

What is the general solution to this?

At the moment I am trying to use pyglet.schedule_once( update_function, 0) which nearly works, but does not call the update function unless the mouse is moved around first.
Looking the pyglet code the scheduled functions go into an a dict, which may work, but there are is no locking in these functions.

The other solution I have in mind is to write a customised pyglet run loop that uses a python Queue to call callback functions.


- Jason

Serdar Yegulalp

unread,
Jan 27, 2016, 1:20:57 PM1/27/16
to pyglet-users
I've used queues to pass messages between threads before, specifically to synchronize operations between Pyglet and another thread operation, and it seemed to do the job nicely.

Jason Spashett

unread,
Jan 28, 2016, 6:54:15 AM1/28/16
to pyglet-users


On Wednesday, 27 January 2016 18:20:57 UTC, Serdar Yegulalp wrote:
I've used queues to pass messages between threads before, specifically to synchronize operations between Pyglet and another thread operation, and it seemed to do the job nicely.

Thanks Serdar,

That is what I should do then, you wrote a custom event loop for this I assume?

Serdar Yegulalp

unread,
Jan 28, 2016, 4:11:16 PM1/28/16
to pyglet-users
Right. I don't have an example immediately handy, but I've been using my own event loop anyway -- I should actually post about my reasons for that here when I have a moment.
Reply all
Reply to author
Forward
0 new messages