Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Invoke a method to a specific thread

Reply
Thread Tools

Re: Invoke a method to a specific thread

 
 
=?ISO-8859-1?Q?Varghj=E4rta?=
Guest
Posts: n/a
 
      08-04-2005
On 25/07/05, Diez B.Roggisch <(E-Mail Removed)> 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/tutor...ml#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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Method.invoke() with one arg compiles despite method signature lyallex Java 6 09-29-2007 07:33 PM
invoke a method by reflection£¬the method's parameters can not be ArrayList? jerry051 ASP .Net 2 08-02-2005 10:35 AM
Invoke a method to a specific thread =?ISO-8859-1?Q?Varghj=E4rta?= Python 0 07-25-2005 05:20 AM
How to invoke a method using the thread which created the object Henrik Dahl ASP .Net 2 05-21-2004 08:44 PM
[Method.invoke] wrapper - accessing arguments passed to user method. Storm Java 1 05-01-2004 11:20 AM



Advertisments