[pygtk] Socket listening

Maxime Ripard maxime.ripard at anandra.org
Sun May 17 03:46:47 WST 2009


Well I actually found what was really going on.

It was obvious and not at all related to the sockets finally.
I just forgot the gtk.gdk.threads_init()

Sorry for bothering you and thanks for all,
Maxim and thanks for all,
Maxime

On Thu, May 07, 2009 at 09:20:35AM -0700, David Ripton wrote:
> On 2009.05.05 13:39:51 +0200, Maxime Ripard wrote:
> > I am new to pyGTK, and I have few problems writing a GUI for an existing
> > program.
> > 
> > One of the purpose of the program is to set up BOOTP and TFTP servers,
> > to allow a PXE boot. Both servers are in different threads than the
> > program itself.
> > 
> > If was formerly using a cli, and everything was going fine.
> > 
> > I now want to use a GUI, so I decided to use pyGTK and Glade.
> > 
> > All the behaviour of my program is wrapped in a class, instanciated by
> > both interfaces, in the same way. But with the GUI, everything is fine,
> > the servers are launched and listen properly, except that nothing seems
> > to come to them.
> > 
> > I have read somewhere that when you need to listen on sockets while
> > running the event loop, you have to use gtk.input_add(), but what if the
> > sockets aren't in the same thread ? Do I have to use it anyway ?
> > 
> > Launching the cli using subprocess.Popen within the GUI handlers makes
> > it work, but it is kind of dirty to me, and not really what I want ...
> > 
> > Is there any solution ?
> 
> The combination of PyGTK and threads is problematic.  It works if you
> follow all the rules but not always cleanly / easily / portably.
> 
> I've been disappointed with io_add_watch and friends.  The API seems to
> include everything you need, but it doesn't always work cleanly / easily
> / portably.
> 
> When I need to combine PyGTK and non-trivial networking, I use Twisted.
> The main loops integrate seamlessly (using gtk2reactor) and then I use
> Twisted APIs for networking and scheduling and PyGTK's APIs for the GUI
> and it all works.  But of course that may be a much bigger change than
> you want.
> 
> -- 
> David Ripton    dripton at ripton.net
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/

-- 
Maxime Ripard
Étudiant à l'Université de Technologie de Belfort - Montbéliard (UTBM)
Génie Informatique (GI 03)

86 bis rue du temple de Blosne
35136 Saint Jacques de la Lande
France

06 85 40 57 32
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20090516/8b0c64fb/attachment.pgp 


More information about the pygtk mailing list