On 25/07/05, Diez B.Roggisch <[EMAIL PROTECTED]> wrote: > Varghjärta <varghjarta <at> gmail.com> writes: > > > If I have "GUIClass":... > > And start another thread and from that thread I want to call the > > method "PaintSomething()" in "GUIClass" _in_ the same thread that > > "GUIClass" lives in. > > There is no such thing in python, or any programming language for that matter.
Not exactly sure what you mean, what would you call the ability to sort of, push a method call onto a thread like Invoke() in C# for example. Even if underneath the clean surface it posts the call into the message loop it gets the job done. > However, in GUIs there is usually some so called event-loop. And for the > task you have in mind you need a way to insert a custom event into that loop > that will be executed the next time that gui thread is idle. > Qt uses QCustomEvents for this. Swing has it's SwingUtilities.invokeLater > > http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html#invokeLater > > and others have different means. So - whatever GUI you use, > it depends on that what to do. Yeah, I've been playing around with WX and find it to be the best GUI layer for python, I belive it has some way of dealing with it. But lets say i'm not using a GUI. Or rather, for example in my WxPython application I have classes which needs to perform time consuming operations. I would _really_ not want to include lots of WX-stuff in an otherwise purely python class. I don't like mixing GUI code with other code, it feels very dirty. How would a python programmer(more experienced then I currently am) solve this? Should I implement some kind of message-loop-system in the class which the different threads "posts" to, and then the class(which is in the right thread) deals with any events "posted"? I'm spoiled from C# having everything delivered to me, so I'm confused as to how much I need to implement myself. Thinking perhaps there was some cute special python command I could use to do it for me :) P.S. Currently traveling far from home(but still I have programming on me brain), sorry for the delayed reply. -- http://mail.python.org/mailman/listinfo/python-list