Jonathan Abrams
Jonathan Abrams

Reputation:

wxpython: How can I redraw something when a window is retored?

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!

Upvotes: 1

Views: 603

Answers (2)

Anurag Uniyal
Anurag Uniyal

Reputation: 88855

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)

Upvotes: 1

marcin
marcin

Reputation: 3581

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.

Upvotes: 0

Related Questions