[Tutor] [tutor] threading problem in GUI

nephish nephish at xit.net
Thu Sep 8 15:23:54 CEST 2005


Pierre Barbier de Reuille wrote:

>Great :)
>
>Just to be clear about that: you can see the "connect" line as a dynamic
>registration process (with the symetric disconnect operation available
>via ... "disconnect"). The only thing you need is to connect (at
>runtime) the even before it's called (obvious isn't it ? ;) ), but you
>have no other constraint. You can even choose to connect/disconnect
>events when they are used/unused ... You can also connect a single event
>many times (to different functions) or you can connect many events to
>the same function. This is the "power" of this system :) Like now if you
>want to log your strings on a file, you just define the function writing
>in the file and connect the event to this function: you'll have both the
>GUI and the log-file outputs !
>
>This is, AFAIK, the best existing implementation for user interfaces !
>
>Pierre
>
>nephish a écrit :
>  
>
>>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
>>>
>>>
>>> 
>>>
>>>      
>>>
>>I finally got it working !!
>>thanks so much for all your help
>>i would not have gotten it working without you,
>>(or this mailing list)
>>
>>God bless
>>shawn
>>
>>    
>>
>
>  
>
indeed. i really want to get into this stuff more.
i think a whole lot of what i have been doing could really be
done easier and cleaner.
thanks for everything,
shawn


More information about the Tutor mailing list