I haven't used threads with Pyglet, but other GUI toolkits also restrict changing gui stuff from other threads. I usually fix this by having having the worker threads tell the "gui thread" something more symbolic like "I'm working on file X" and then the gui thread takes that message and changes the label text.
-Winston
On Feb 4, 2013, at 3:15 PM, Lord Anton Hvornum <
anton...@gmail.com> wrote:
> I have a scenario where:
>
> class main(pyglet.window):
> ...
> generates a lot of objects
>
> sends a label to another thread
>
> class the_thread(Thread):
> ...
> tries to:
> self.lable.text = 'New string'
> self.lable.draw()
>
> Which causes:
>
> > GLException: invalid operation
>
>
> Even keeping the .draw() part in the main thread and just update the text causes the error.
> Using the "lock" function via self.lable.being_update() and then calling .end_update() causes the error.
>
> The code i've got works fine if i take away the Threading part, which, i don't because the whole idea with the thread is to have a socket and some processing operations being performed at X times / minute under different circumstances.
>
>
> Any idea if it's possible to solve at all?
> Can i hook the thread objects to the main window resorce somehow or blit it into the main instance? I **think** i've solved this once back in the days when i was programming at a helpdesk by blitting the object into a "scene" or something but i can't find my code, and it might not even have been based on Pyglet to begin with.
>
> --
> You received this message because you are subscribed to the Google Groups "pyglet-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
pyglet-users...@googlegroups.com.
> To post to this group, send email to
pyglet...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/pyglet-users?hl=en.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>