I've just joined the site, and I'm embarassed to be posting what is obviously a simple problem, but I've had no luck with figuring it out. I'm sort of new to dealing with GUIs, wx, and much of the CLASS structure of Python. I've put together a simple script below to illustrate my problem. I have a long script that loads, and analyzes large data sets (originating from the scan of a microarray... if anybody is interested). After the analysis is complete, it then plots the results on a canvas. I've got a few problems here. I can't seem to work out the scope of the variables so that they can be seen in the drawline function, and I can't seem to get the function to draw on the canvas defined in the __init__ of the MyFrame class. Thanks again for any help or suggestions.
import wx from floatcanvas import NavCanvas, FloatCanvas class MyFrame(wx.Frame): """a frame with a panel""" def __init__(self, parent=None, id=-1, title=None): wx.Frame.__init__(self, parent, id, title) splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE|wx.SP_3D, size = (600,300)) panel1 = wx.Panel(splitter) panel1.SetBackgroundColour(wx.WHITE) #Draw some widgets for controlling different variables on panel1..... panel2 = NavCanvas.NavCanvas(splitter, ProjectionFun = None, Debug = 0, BackgroundColor = "LIGHT GRAY", ) sash_Position = 100 splitter.SplitVertically(panel1, panel2, sash_Position) splitter.SetSashSize(1) min_Pan_size = 40 splitter.SetMinimumPaneSize(min_Pan_size) self.Fit() panel2.Bind(wx.EVT_PAINT, self.drawline) # flat file is loaded and calculations are made. Results are 'coordinates' (x0,y0, x1,y1....) to be plotted using drawline x0=12 x1=23 y0=13 y1=26 self.Fit() def drawline(self, event): # establish the painting surface dc = wx.PaintDC(self.panel2) dc.SetPen(wx.Pen('blue', 4)) # draw line of coordinates calculated for each file dc.DrawLine(self.x0, self.y0, self.x1, self.y1) #main program app = wx.PySimpleApp() frame1 = MyFrame(title=microarray data) frame1.Center() frame1.Show() app.MainLoop()