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/