[wxPython-users] Re: how to draw in a window, device context
Peter Decker
pydecker at gmail.com
Mon Jun 4 13:09:11 PDT 2007
On 6/4/07, 7stud <bbxx789_05ss at yahoo.com> wrote:
> Thanks for the explanation. The cobwebs are clearing a bit from the
> memories of some C++ GUI programming I once did. Now I seem to
> recall that a window is painted when:
>
> 1) it's initially displayed
>
> 2) it's covered up and then uncovered.
>
> And in order to draw in a window, you have to intercept a paint
> message that is issued in response to those events, and then draw
> your window the way you want it.
>
> Unfortunately, "wxPython in Action" fails to mention the fact that
> you need to listen for wx.EVT_PAINT and then draw the
> window inside the event handler. There is no mention of that fact in
> section 6.1 "Drawing to the Screen" nor in section 12.2.2 "How do
> I draw to a device context?", and the examples are so long and
> convoluted, it's not possible fora beginner to discern that requirement
> from the examples.
I had problems trying to understand drawing in wxPython, and could
never seem to get it to work properly. Then I discovered Dabo
(http://dabodev.com).
You say you want to draw a circle. All it takes in Dabo is:
circ = object.drawCircle(x, y, radius)
You can also specify stuff like PenColor, PenWidth, FillColor, etc.
The circle is drawn to your settings, and redraws itself as needed
without any code on your part. And the object reference it returns is
'live' - you can change any of its properties, and the drawn circle
changes accordingly. So if you want to change it to be filled with
blue, you just write:
circ.FillColor = "blue"
And it just works!
--
# p.d.
More information about the wxpython-users
mailing list