From: Werner S. <sm...@ia...> - 2009-09-03 19:07:26
|
Hi Brian, On Sep 3, 2009, at 3:23 PM, Brian D'Urso wrote: > I have a functional wxpython driver for plplot up and running, and I > attached the needed files: > > plplotcapi.i.diff is the changes I had to make in the swig interface > file to: > 1) expose pl_cmd(), PLESC_DEVINIT, and PLESC_GETBACKEND to python. > However, I think the void* in pl_cmd() causes problems with other > bindings. I am compiling with the python bindings only. > 2) In order to use pl_cmd(PLESC_GETBACKEND, ...) I added a > pointer_function to pass an int* to get the result. There may be a > simpler way. I'll have a look at it, or ask our Python experts if these changes are ok. > > plplotwx.py contains the new PLplotCanvas class I wrote as the > wxpython plplot driver (which is very similar to the wxWidgets > version). It basically has the full plplot C api as methods, with the > exception of the init-like methods. These are handled by the > PLplotCanvas __init__ method (which includes keyword arguments for > setting the bg color and drvopt). I also had to add one > plplot-c-api-like method, plshow(). This method forces the > PLplotCanvas to update the screen, so you can see the results. I > didn't want to update the screen at every step because it would be > impossible to have smooth animated plots without flicker. All the > methods automatically set the plplot stream so you don't have to worry > about it (which may slow things down a little). > So, in use it could look like: > plot = PLplotCanvas(... bg=(255,255,255), drvopt='backend=2') > plot.plenv(0, 10, 0, 1, 0, 0) > plot.plcol0(2) > plot.plline(xs, ys) > ... > plot.plshow() # force a redraw to show the plot at the end Looks good to me. Thanks for all the work! > > plplot_wxpython_examples.py contains a little example app which > includes the first 10 plplot examples as a test case. It will need to > be in the python examples directory. Once you launch it, choose an > example from the menu. The examples which have multiple plots have a > one second pause between the plots. > > There are still many improvements that could be made. I would like to > make the PLplotCanvas methods more 'bulletproof' with checks of the > arguments to avoid any possibility of segfaults. I will finish adding > the examples if you think this whole effort is valuable and you think > the example app is a reasonable way to present it. A little > documentation would also be nice. I have other ideas for enhancements > I would like to see, but this is a good start for me. > > Thank you, > Brian > <plplotcapi.i.diff><plplot_wxpython_examples.py><plplotwx.py> I need to talk/mail with Allan, what the best way is to include the wxphyton bindings - if we make them "full" bindings, or add them to the existing python bindings. We must also change the Cmake build system, so that these bindings (and the example) are only build if wxpython is installed. Do you know how one can find out if wxpython is available? So, python must be available, and if a little python program which imports wx runs without problem, then everything should be ok, or? Thanks for your contribution, Werner -- Dr. Werner Smekal Institut fuer Allgemeine Physik Technische Universitaet Wien Wiedner Hauptstr 8-10 A-1040 Wien Austria DVR-Nr: 0005886 email: sm...@ia... web: http://www.iap.tuwien.ac.at/~smekal phone: +43-(0)1-58801-13463 (office) +43-(0)1-58801-13469 (laboratory) fax: +43-(0)1-58801-13499 |