Hi Everyone,
I've spent a significant amount of time hacking away at code trying to
figure this out. After hitting wall after wall, I decided I should try
asking for a bit of help.
The end goal that I'm trying to achieve is to get matplotlib's wx
backend to work (interactively) with the Python Tools for Visual
Studio (PTVS) IDE.
Currently the PTVS only supports matplotlib for Python builds with
integrated matplot libary, so IPython and EPD I believe.
(I found that other IDE's usually have some sort of hack to allow
this, for example PyScripter requires you to run in a special mode,
"Remote Wx", or in IDLE you have to launch with the -n argument.)
Long story short, I would love to figure out how to get this going in
the PTVS IDE. (I'm hoping I can write some Python code for this,
possibly a new matplotlib backend, and not have to hack away at the
PTVS source code.)
The problem it seems is that wxPython (and other GUI toolkits) require
a MainLoop, which by default runs in a blocking manner, keeping you
from having the interactive plots along with the interactive
interpreter (REPL).
I came across an example (http://wiki.wxpython.org/MainLoopAsThread),
which allows me to open one GUI window that runs asynchronously, and
keeps the REPL running. Now that I have the MainLoop running in a
separate thread, I'm not sure how to go about creating and showing
more frames. Any new frame will open, but then becomes unresponsive.
Here is my example code, I'm running it in PTVS, but I found the
behavior is the same if I use PyScripter in "Remote mode" (not the
"Remote Wx" mode).
I've been digging through the PyScripter source code and it seem that
their hack, has something to do with creating a dummy MainLoop after
the initial one is run, but I can't quite figure out how it's done. (I
don't know, or have a Delphi IDE J).
Maybe I need to turn the first thread I created into a frame
generating factory.?
Any little pointers would be greatly appreciated.
Thanks!
Chris