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

Boudewijn Rempt boud at valdyas.org
Wed Sep 11 20:46:01 BST 2002


On Wednesday 11 September 2002 01:36, Peter Lipa wrote:
>
> Comments ot Boudewijn's sample code:
> Thanks a lot for this example. It is half of what I want. My key problem is
> that I need a mechanism to push those buttons in your command window by
> user commands entered from the python COMMAND LINE (I never had a problem
> issuing commands from a GUI element such as a button.)

Just program a commandline that feeds the commands to the gui windows. That's
easy enough -- as I said, I was just to lazy to code one up. The principle 
remains the same.

Of course, what you hadn't said before, about embedding Python in an MFC app,
changes the situation a bit. Embedding one gui toolkit in another is always
frought with danger... And tricky. Still, you _cannot_ do useful things with
a plain python shell once you've started the QApplication's exec_loop -- 
that's a fact of life, so you _must_ approach the problem from another angle.
And really, you can offer all the user-friendliness you're after from a Python 
shell embedded in the application. Just see it as another window...

> In a Nutshell, Boudewijn, if you can modify the plotter1.py example such
>
> that I can type in the interpreter any of the three commands:

I probably could -- but I think that goes a bit beyond casual help on a 
mailing list... But for a consultancy fee :-).

> then my problem would be solved! This would be my preferred solution (over
> embedding another python instance in a pyQt
> shell such as pycute.py). Boudewijn, maybe you have an idea how to do that!
>

You embed one Python interpreter. That interpreter runs one QApplication. That 
QApplication shows one Python shell -- in a QMainWindow. It can also run any
number of other QMainWindows.

>
> Jonathan Gardner suggested using sockets for communication between the
> threads - something I haven't tried yet, but I doubt that it would solve
> the threading problem. However, I still have to think about that some
> more....

I'd advise against that solution, also against any solution that involves two 
processes and redirected stdin/stdout as comm channel. Been there, failed
that.
-- 
Boudewijn Rempt | http://www.valdyas.org




More information about the PyQt mailing list