Python and Sockets,

Chris Liechti cliechti at gmx.net
Thu Aug 1 01:04:07 CEST 2002


John J Breen <jbreen at nospam.com> wrote in 
news:3D486809.6F2DC882 at nospam.com:
>     Hey all,
>             I am writing a program in Pygtk that also has a Python/TK
> component. I need these two components to be able to communicate with
> one another through a third component written in python. I would like to
> use sockets to send information back and forth, but am running into some
> trouble. The components may be sending information at any time so I need
> to the sockets to be able to listen/send at any time. I cant have a loop
> for listening because that would keep the user from sending events to
> either the gtk or TK interface. Someone suggested _createfilehandler but
> Im not sure what that is... Does anyone have any suggestions for such a
> problem?

you'll probably want to look at the threading module. to learn about 
threads, you can look at the slides on Aahz page: 
http://www.pythoncraft.com/

whith threads you can have a loop in one thread and the other is still 
serving the GUI. you might want to look at the Queue module too, as it 
provides an easy solution to savely pass data from one thread to an other.
(from the comm thread to the GUI and back)

chris

-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list