Hi Guiseppe,
Let me preface this by saying that I don't really understand threads, so
I may be wrong. But my understanding is that threads are used to
separate expensive calculations from the code handling the GUI, while
still allowing you to pass Python objects back and forth.
On 03/30/2011 07:50 AM, Giuseppe Penone wrote:
so far I've allowed a single instance only for simplicity but now I
would like to introduce the opportunity to open more instances
of different documents, but avoid to open twice the same document for
mistake and instead put the running window to toplevel
in case there's already an instance of that document opened.
This makes sense, but I don't see why you need threads to do it.
Multiple windows can be controlled by a single thread. If a given
document needs an intensive calculation, that can be split into it's own
thread, but that seems orthogonal to having multiple documents open.
I'm guessing that you're intending to run each window in it's own
thread, but that would mean that each window will have to jump through
the threading hoops (threads_enter/_leave or doing everything with
callbacks) to update itself. This seems like a lot of pain, and I don't
see what you gain.
it seems to me that the only way to obtain this is to have a server that
controls all the instances, being my app cross platform I
opted for a tcp/ip server in loopback 127.0.0.1.
Especially if you're communicating over a socket. If you're doing this,
why not run each document in its own process? You'd get even more
separation (no GIL) and don't have to worry about how to call GTK
functions from multiple threads.
I'm sure it is possible to do what you're trying to do with threads, but
I don't know enough to help you out with it. I do think, though, that
threads are not the easiest answer to your problem.
Robert
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/