[Tutor] [tutor] threading problem in GUI

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Wed Sep 7 18:21:34 CEST 2005

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 :

    self.emit("writing", str)

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 Barbier de Reuille

INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde

tel   : (33) 4 67 61 65 77    fax   : (33) 4 67 61 56 68

More information about the Tutor mailing list