Hi John et al., I know that the development of a wx
> backend is under way.
Well under way in fact. Jeremy O'Donoghue sent me a version yesterday
which I checked into CVS. It is still under active development, with
several known bugs, but he has tested it across platforms with most of
the example scripts. I'll post in the text of his email below which
has more details.
> But meanwhile, can any of the non GTK backends (PS and GD)
> be used from within a wx app?
> I suspect that the answer to this question is no because
> the mere import of matplotlib.matlab from any wxpython
> shell (like pycrust) will crash it. But I don't want to
> assume that before I am certain of it.
matplotlib should not crash pycrust (it doesn't on my system). This
may be related to an improper GTK install on your system. In any
case, you need to import the backend you plan to use before importing
matplotlib.matlab. I just did the following from pycrust w/o problems
import matplotlib
matplotlib.use('PS')
import os
def psshow():
savefig('tmp.ps')
os.system('ggv tmp.ps')
close()
from matplotlib.matlab import *
plot([1,2,3])
psshow()
t = arange(0.0, 1.0, 0.01)
plot(t, sin(2*pi*t))
psshow()
I also did the the same with GD module. Just replace 'PS' with GD and
execute your favorite image viewer command.
For either of these, though, You'll first need to comment out line 43
in _matlab_helpers.py, which reads 'figwin.window.destroy()'. I only
discovered this bug when trying to answer your question.
Now, on to WX. It is currently only working from pycrust and is under
heavy development, but you are welcome to try it from CVS. Let me
know if you need a win32 installer and I'll email one.
Here is Jeremy's email:
I thought I'd keep you up to date with my progress.
Attached is the set of files for an early version of the wxWindows
back-end. It seems to work with most of the examples on the website, and
has been tested with wxPython 2.3.3 (on wxWindows 2.2.9) on Windows 2000
using Active State Python 2.2, and (less thoroughly) using wxWindows 2.4
under WxGTK with Python 2.3 on Debian GNU/Linux.
The implementation is very similar to your GTK back-end (probably too
similar, but I like re-using code which works This at least means that
it should be pretty easy for you to follow what I've done.
The code is probably only ready for very early users - if anyone is
screaming for wxWindows, you may wish to put it into CVS, otherwise it may
be better to wait for a while - say until I have the interactive functions
working. I'll leave it to your judgement.
Best regards
Jeremy
Known bugs:
- Coloured text labels to not work correctly. I do
not yet understand why not, and will need to look
carefully at how wxWindows treats text, as I think
the code I have is OK!
- I currently do not perform any clipping, as this
clips text labels.
- Under Windows 2000, the Figure window is larger
than the figure (seems OK on Linux, however)
- Interactive sessions currently only work inside
a Python console which already has a wxWindows
event loop (I recommend PyCrust, which is
distributed with wxPython)
Not implemented:
- Printing
- Interactive operation using the toolbar (probably
not a large job to do, as I suspect that I can simply
re-use the functions from backend_gtk).
Ugly hacks:
- Dotted lines - I have a nasty hack to make this work
sufficiently for demonstration purposes. The problem
is that you currently implement dotted lines in a rather
GTK-specific way. I'd prefer, given that there are only
a few 'dotted' styles, for these to have symbolic names
(e.g. in a dictionary), and to do all of the decisions
on how to draw the 'dotted' style in the back-end.
- As wxWindows has no 'stock' icons, I have converted GTK
icons similar to those used in backend_gtk into XPM
format and put them into an 'images' directory under
backends. I'm open to your preference as to whether it
would be better to put the images into python code or
leave them as pixmaps.