[PyKDE] How to do *INTERACTIVE* plotting with PyQt (or PyQwt)

Jonathan Gardner jgardn at alumni.washington.edu
Sat Sep 7 06:07:01 BST 2002

On Friday 06 September 2002 06:21 pm, Peter Lipa wrote:
> I seems to me, that only Gerard Vermeulen understood fully what I *need* to
> do (since he tried  that before).
> I looked a bit at eric and this is not quite what I want (it is a qt app
> with a single qApp in the main thread and runs
> a independent - and isolated- python shell inside which in turn can run a
> single Qt app to be debugged).
> My problem is the other way round. I want to run several Qt windows and
> send commands via the interpreter to these
> windows, such as, add a line (xarray,yarray) to the current axes ).

You want two independent processes or threads, or at least the appearance of 
such. One will handle the interaction with the user (asking for commands, 
etc...)  The other will handle the windows and redrawing and such. Between 
the two, some data will be shared.

How do you get the two to interact? You set up a socket or pipe from one to 
the other. On the other hand, you can pass data through signals and slots, 
etc... but both must then run in the same process. Of the two, the second is 
going to be easier to implement. However, the first is going to be more 
flexible, and in my opinion, easier to develop quickly.

The windowing process -- the one that draws the stuff -- is going to be 
implement in PyQt from the start. You will also have to set it up so that it 
listens to a port or it inherits a file handle that is a pipe from its parent 
process to it.

The interpreter can be written as a module. You should be able to run this 
from the command line. A call to spawn a new window will create a new data 
object to represent that window, and then launch a new process that will then 
launch the windowing app, which will then somehow connect back to the process 
that spawned it (using sockets or pipe, or whatever you choose). When you 
call the "Draw a line from here to here in this window" method, it will send 
a message to draw a line from a to b to the spawned process. The spawned 
process will get the message, and then update its data and its drawing area. 

I think this sounds like what you want. The devil is in the details, and 
you'll have to choose to go one way or the other.

Jonathan Gardner
jgardn at alumni.washington.edu

More information about the PyQt mailing list