views:

238

answers:

2

In my wx.Frame based wxpython application, I draw some lines on a panel when some events occur by creating wx.ClientDC instances when needed. The only problem is, if the window is minimized and then restored, the lines disappear! Is there some kind of method that I should override or event to bind to that will allow me to call the drawing method I created when the window is restored?

Thanks!

A: 

When the window is restored it is (on some platforms) repainted using EVT_PAINT handler.

The solution is e.g. to draw the same lines in OnPaint(). Or buffer what you draw. See the wxBufferedDC class.

marcin
+1  A: 

only place you must be drawing is on wx.EVT_PAINT, so bind to that event in init of panel e.g.

self.Bind(wx.EVT_PAINT, self._onPaint)

in _onPaint, use wx.PaintDC to to draw e.g.

dc = wx.PaintDC(self)
dc.DrawLine(0,0,100,100)
Anurag Uniyal