[PyKDE] How to do *INTERACTIVE* plotting with PyQt (or PyQwt)
Gerard Vermeulen
gvermeul at grenoble.cnrs.fr
Wed Sep 11 17:31:01 BST 2002
Hi Peter
On Tue, Sep 10, 2002 at 04:36:19PM -0700, Peter Lipa wrote:
[ snip ]
>
> Gerard's solution - to have a PyQt app shell running another instance of the
> interpreter inside is working! Thanks for your suggestions and sharing the
> testcode, Gerard! I really appreciate it!
>
> Comments to Gerard's solution:
> It's great, it works, and is the obvious way to go ..., however, my
> colleague is developed already a python shell (called Neuralab) on Windows
> using MFC and has the python interpreter embedded in C. Now we would like
> to run PyQt graphics within the this shell. Having another PyQt interpreter
> shell (pycute.py) running inside the C-embedded python shell is possible,
> but the communication then has to go through 2 layers of python interpreters
> (and makes things a little ugly, I guess). So this solution is perfect if
> one targets a PyQt shell or re-writes Neuralab in PyQt. A good, portable
> opensouce PyQt shell would be of great benefit for everybody. (PyQt crashes
> the PythonWin shell from ActiveState, and does not integrate smoothly into
> wxWindows and Tkinter based shells either...)
>
I do not know if there are really two interpreters. It depends on how you
look at it. I have a newer version of the Python shell (with more code
stolen from Idle) that shares name space with the (main) Python interpreter.
I do not know if you want to give so much power to the users
Here follows a little experiment (copy&paste):
Python 2.2.1 (#1, May 8 2002, 22:31:32)
[GCC 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)] on linux-i386
Type "copyright", "credits" or "license" for more information.
>>> error
Traceback (most recent call last):
File "<PQShell#0>", line 1, in ?
error
NameError: name 'error' is not defined
>>> a
<qt.QApplication instance at 0x8170b74>
>>> del a
>>> a
Traceback (most recent call last):
File "<PQShell#3>", line 1, in ?
a
NameError: name 'a' is not defined
>>>
WOW: I managed to delete the only QApplicationInstance (did I?), but the
Python Shell did not crash.
I suppose, that if the Python shell can look into the Python interpreter,
the Python interpreter can look into the Python shell.
Contact me, if you cannot get Boudewijn's idea working (leaves me some time
to polish the shell). This kind of META programming is fun, but I barely
understand what I am doing :-)
Gerard
PS: the version that you have, does not allow this. I have to figure out why.
More information about the PyQt
mailing list