[PyKDE] How to do *INTERACTIVE* plotting with PyQt (or PyQwt)
kibab at icehouse.net
Sat Sep 7 19:47:00 BST 2002
On Friday 06 September 2002 06:21 pm, Peter Lipa wrote:
> Hi Guys (Phil, Gerard and Boudewijn),
> Thanks so much for your replies - I really appreciate any help or
> suggestion. Unfortunatley I am still desparate....
> 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 ).
Why can't you use many modeless windows? You can always set it up so that you
can send a signal to any one of the windows that contains a chunk of python
code you wanted executed, that being the line(s) that you typed in your
LineEdit/TextEdit. Then, the receiving function could "exec(<codeblock>)".
I would only use threading for the time consuming parts where you want your
application to remain responsive.
> (I tried this also in a QThread but the
> QThreaq.run() never gave control back to the python
> interpreter! QTheads seem to need the eventloop running BEFORE creation
> although I am not sure about that).
Hmm.... You should define a run function that will be called by the thread.
Hence, you should have called mythread.start() which would call your run
method. If run didn't return (and you're using QThreads) then you run
function didn't return... mythread.start() will return immediately.
> If you close the last created Window (e.g 'Document 3'), control goes back
> to 'Document 2' (and all print messages are printe there) and
> if you close that one too, control goes back to 'Document 1'. This is
> ALMOST the basic functinality I need!
I would make my windows "Owned" windows, that is, I would give each one an ID
and then when I send the signal from my interpreter the receiving windows
will check to see that the ID matches, if it does, then it will process the
events. There are many other options that will allow you to send a signal to
any windows instead of all of them--Boudewijn's example is one example. I
like the "Owned" concept personally where a simple if statement determines
whether or not it responds.
Well, I wish I had time to hack out something that you could start from but
I'm already 1-2 weeks behind on a project that is supposed to be done at the
end of this month.... so, I hope what I have said helps.
More information about the PyQt