[wxPython] pxDislin

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] pxDislin

Markus Gritsch
Hi!

Some time ago there was a posting on this list about how to use the DISLIN
plotting and visualization library smoothly together with wxPython.  I had a
look at DISLIN, and was impressed by the features is had, but I wasn't very
happy about it's 6-letter Fortran-like function-calls which are necessary to
interact with DISLIN.

Well, a few days ago Paul Magwene announced his new object-oriented wrapper
around the DISLIN plotting library, named pxDislin.  With these wrapper
classes, one gets the full power of DISLIN combined with a very nice way to
interact with it.  Everybody who uses DISLIN and Python should consider using
these wrapper classes.

Below there is a simple program which demonstrates the use of pxDislin drawing
in a wxFrame.

Requirements:
 *) DISLIN   http://www.linmpi.mpg.de/dislin/
 *) pxDislin http://pantheon.yale.edu/~pmm34/pxdislin.html
 *) NumPy    ftp://ftp-icf.llnl.gov/pub/python/README.html

Have fun,
Markus
--


import pxDobject, pxDobject3D
import pxDplot, pxDplot3D

from wxPython.wx import *

#---------------------------------------------------------------------------
class dislin_frame(wxFrame):
    def __init__(self):
        wxFrame.__init__(
            self,
            NULL, -1, "wxCML",
            wxDefaultPosition,
            wxSize(400, 400)
        )

        # paint with a double-buffering scheme
        #import dislin
        #dislin.x11mod('nostore')

        """Draw some simple geometric figures and Text"""
        self.plot = pxDobject.dPlot()
        self.plot.title.text = 'Example 1: Geometric Figures'

        # set the handle of the window where DISLIN paints to our wxFrame
        self.plot.external_ID = self.GetHandle()

        axis = pxDobject.dAxis(-10,10,-10,10)
        self.plot.add_axis(axis)

        circle = pxDobject.dCircle(0,0,5)
        circle.shading = 'diagonal1'
        self.plot.add_object(circle)

        rect = pxDobject.dRectangle(0,0,6,2)
        self.plot.add_object(rect)

        message = pxDobject.dText('A message on the plot', -5,5)
        message.size = 48
        self.plot.add_object(message)

        self.plot.show()

    def OnPaint(self, event):
        dc = wxPaintDC(self)
        self.plot.show()

#---------------------------------------------------------------------------
class myApp(wxApp):
    def OnInit(self):
        dislin_frame().Show(TRUE)
        return TRUE

#---------------------------------------------------------------------------
if __name__ == '__main__':
    app = myApp(0)
    app.MainLoop()



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users