Hello,
I have included a simple program that uses the DISLIN plotting library.
When a wxPyTimer is included for the status bar it crashes after several
resizes of the main window. With the timer left out there is no problem.
This is what I have in use (on Win2000) :
ActivePython 2.2.1
wxPython 2.4.0.7
Numeric 23.0
DISLIN 8.1
Best regards,
Paul Casteels Paul.Casteels@ua.ac.be Tel: +32.3.8202455
Fax: +32.3.8202470
University of Antwerp Dpt.Physics
Universiteitsplein 1
B-2610 Wilrijk
Belgium
import sys,time
sys.path.append('c:\\dislin\\python')
import dislin
from wxPython.wx import *
import Numeric
crash = 1
ID_ABOUT=101
ID_EXIT=102
ID_OPEN=103
ID_CLOSE=104
class _win_canvas(wxPanel):
def __init__(self,parent,ID=-1,pos=wxDefaultPosition,
size=wxDefaultSize):
wxPanel.__init__(self,parent,ID,pos,size)
self.handle = self.GetHandle()
self.mode = 'store'
self.painter = None
EVT_PAINT(self,self.OnPaint)
def draw(self,target='xwin'):
if self.painter:
dislin.metafl(target)
if target == 'xwin':
dislin.x11mod(self.mode)
dislin.setxid(self.handle,'window')
pw,ph = self.GetClientSizeTuple()
spw = pw*6
sph = ph*6
dislin.sclmod('full')
dislin.page(spw,sph)
self.painter.draw()
def OnPaint(self,event):
dc = wxPaintDC(self)
self.draw()
class plotPainter:
def __init__(self):
pass
def draw(self):
dislin.scrmod('revers')
dislin.disini()
dislin.unit(0)
pw,ph = dislin.getpag()
x = Numeric.arange(10.0)
y = Numeric.array([2.0,6.0,4,3,8,9,11,4,9,3])
dislin.plot(x,y)
dislin.endgrf()
dislin.disfin()
class myFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self,NULL,-1,'PyCVT',
wxDefaultPosition,wxSize(400,320))
display = _win_canvas(self)
display.painter = plotPainter()
menu = self.MakeMenu()
self.SetMenuBar(menu)
self.MakeStatusBar()
self.filterIndex = 0
EVT_CLOSE(self,self.OnCloseWindow)
EVT_MENU(self,ID_OPEN,self.OnMenuOpen)
EVT_MENU(self,ID_CLOSE,self.OnMenuClose)
EVT_MENU(self,ID_ABOUT,self.OnMenuAbout)
EVT_MENU(self,ID_EXIT,self.OnMenuExit)
def MakeMenu(self):
fmenu = wxMenu()
fmenu.Append(ID_OPEN,"&Open","Open a data file")
fmenu.Append(ID_CLOSE,"&Close","Close the current file")
fmenu.AppendSeparator()
fmenu.Append(ID_EXIT,"E&xit","Terminate the program")
hmenu = wxMenu()
hmenu.Append(ID_ABOUT,"&About","More information")
main = wxMenuBar()
main.Append(fmenu,"&File")
main.Append(hmenu,"&Help")
return main
def MakeStatusBar(self):
sb = self.CreateStatusBar(2)
sb.SetStatusWidths([-1,150])
if crash:
self.timer = wxPyTimer(self.Notify)
self.timer.Start(1000)
self.Notify()
def Notify(self):
t = time.localtime(time.time())
st = time.strftime(" %d-%b-%Y %I:%M:%S",t)
self.SetStatusText(st,1)
def OnMenuOpen(self,event):
dlg = wxFileDialog(self)
dlg.SetStyle(wxOPEN)
dlg.ShowModal()
dlg.Destroy()
def OnMenuClose(self,event):
pass
def OnMenuAbout(self,event):
dlg = wxMessageDialog(self,"About",wxOK|wxICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
def OnMenuExit(self,event):
self.Close()
def OnCloseWindow(self,event):
if crash:
self.timer.Stop()
del self.timer
self.Destroy()
class myApp(wxApp):
def OnInit(self):
frame = myFrame()
frame.Show(TRUE)
return TRUE
app = myApp(0)
app.MainLoop()