[Tutor] [tutor] threading problem in GUI

nephish nephish at xit.net
Wed Sep 7 18:32:21 CEST 2005


Pierre Barbier de Reuille wrote:

>nephish a écrit :
>  
>
>>one more thing.
>>if i uncomment the lines
>>gtk.threads_enter()
>>and
>>gtk.threads_leave()
>>the whole thing locks up when the function is called.
>>the gui, and the thread both lock up.
>>    
>>
>
>Well, that's just normal. However, what you should do is to send a
>signal from your thread with the text to append in your textbuffer.
>Then, you catch the signal in your main widget to show it !
>
>To emit a signal use :
>
>    gtk.gdk.threads_enter()
>    self.emit("writing", str)
>    gtk.gdk.threads_leave()
>
>To catch it:
>
>
>    emitting_object.connect("writing", self.method_handling_to_signal)
>
>Well, I used that and it just work ! Using the signal does not solve any
>threading problem but allow you to separate between the event and the
>answer to the event, which is a good habit to take !
>
>Pierre
>
>
>  
>
cool, will try.
where exactly do i put this line? Just right in the main loop?

emitting_object.connect("writing", self.method_handling_to_signal)


thanks !


More information about the Tutor mailing list