I'm new to Python, so bear with me.....

I'm calling the Dislin plotting package from python to plot in a wxPython panel. This works OK but the plot gets grayed out when another window is moved over it. There is a Dislin function, sendbf, which updates the graphics window with a pixmap, so I thought I could use wx.EVT_PAINT to invoke this.

So I made a subclass as follows

class refreshablePanel(wx.Panel): 

    def __init__(self, parent, id, pos, size): 
        wx.Panel.__init__(self, parent, id, pos, size) 
        self.Bind(wx.EVT_PAINT, self.OnPaint) 

    def OnPaint(self,event): 
        sendbf

and replaced following line in my frame class

plotpanel = wx.Panel(self, -1,pos=(0,30),size=(1000,700))

with

plotpanel = refreshablePanel(self, -1,pos=(0,30),size=(1000,700))

But the program just hangs when it comes to plot anything. I'd be very grateful for help with this....

Recommended Answers

All 4 Replies

Quote from the wx.PaintDC doc: If you have an EVT_PAINT handler, you must create a wx.PaintDC object within it even if you don't actually use it.. So you should perhaps try

def OnPaint(self, event):
  dc = wx.PaintDC(self)
  sendbf()

You're right - thanks!

I also ned to put the call to sendbf as

refresh = sendbf()

since the function apparently needs to be called, not just evaluated

Variable should not be needed, but you use the function ie put after it ()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.