[wxPython] Paint events don't seem to trigger a refresh when there's an OnPaint handler

In the short example below, I was under the impression that the EVT_SIZE handler would not be necessary, with the idea that paint events would be generated to repaint the whole panel when a resize occurs. Is this intended? Or a bug?

Enjoy,
Mike

"""Basic non-linear editing control"""
from wxPython.wx import *

class NonlinearCanvas (wxPanel):
     def __init__(
         self, parent, id = -1,
         pos = wxDefaultPosition, size = wxDefaultSize,
         style = wxTAB_TRAVERSAL, name = "nonlinear",
     ):
         wxPanel.__init__(self, parent, id, pos, size, style, name )
         EVT_PAINT (self, self.OnPaint)
## EVT_SIZE ( self, self.OnSize )
## def OnSize (self, event):
## """Handle a size event"""
## self.Refresh()
## event.Skip()
     def OnPaint( self, event):
         """The drawing operations to display the nonlinear editor"""
         paint = wxPaintDC( self )
         paint.Clear()
         paint.BeginDrawing()
         try:
             self.DrawGrid( paint )
         finally:
             paint.EndDrawing ()
     def DrawGrid(self, paint):
         """Draw the correctly scaled grid for the current scaling of the canvas"""
         width, height = self.GetSizeTuple()
         # hack, eventually this should all be precalculated...
         count = 10
         lines = []
         for index in range( count ):
             x = width/count * index
             lines.append ( (x,0,x,height) )
         paint.DrawLineList(lines, wxPen("RED", 1))

if __name__ == "__main__":
     class TestApplication (wxPySimpleApp):
         def OnInit(self):
             frame =wxFrame (NULL, -1, "test", size = (300,300))
             panel = NonlinearCanvas(frame, -1 )
             frame.Show (1)
             self.SetTopWindow(frame)
             return 1
     app = TestApplication ()
     app.MainLoop()

···

_______________________________________
   Mike C. Fletcher
   http://members.rogers.com/mcfletch/

In the short example below, I was under the impression that the EVT_SIZE
handler would not be necessary, with the idea that paint events would be
generated to repaint the whole panel when a resize occurs. Is this
intended? Or a bug?

There was some effort a while back to eliminate redundant paint events, size
events, and etc. My guess is that in this sample that the paint events
happening after the size are clipping to only the area that has been
exposed. If you need to redraw the entire window then what you are doing in
OnSize is correct.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!