[wxpython-users] Advice on drawing shapes

Robin Dunn robin at alldunn.com
Mon Mar 31 10:54:16 PDT 2008


Stewart McLay wrote:
> Hello Everyone,
> 
> I am thinking about creating a window with a wx.GraphicsContext. On that 
> window I want to be able to draw rectangle by left clicking the mouse 
> whilst on the window and and dragging the mouse. I want to be able to 
> see the rectangle grow from the origin of the click and remain once the 
> mouse button has been released. I think this looks achievable in 
> wxPython but I haven't seen any good examples in the demo application 
> that demonstrate how to do this kind of thing. Is this possible to do in 
> wxPython? and does anyone know where a good example might be found?

And if FloatCanvas or OGL are not what you are looking for, it's not 
hard to do it yourself.  Just catch the mouse events and draw as needed. 
  It's not using wx.GraphicsContext, but there is an example of doing 
things like this with wx.DC in samples/pySketch.



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



More information about the wxpython-users mailing list