Draw rectangle on a Window DC
Anand
anandpillai6 at yahoo.com
Mon Oct 21 10:01:16 EDT 2002
Hi
I need to draw a rectangle when the user selects an area
over a wxPanel containing a wxStaticBitmap. The rectangle shoud change
in size according to the dragging of the mouse.
How do I write the event processing code so that I dont have many
rectangles overlapping each other, but just one that keeps changing size ?
The code I have right now,
if event.Dragging():
self.endpt = event.GetPosition()
w = (self.endpt.x - self.stpt.x) # stpt is stored in earlier
# left mouse click.
h = (self.endpt.y - self.stpt.y)
wdc.DrawRectangle(self.stpt.x, self.stpt.y, w, h)
self.SetCursor(wxStockCursor(wxCURSOR_ARROW))
This draws a number of rectangles overlapping each other. I am using a
transparent brush and a black pen. I can of course refresh the bitmap
every time the mouse is dragged but that causes flicker.
Any other functions/approach for this.
Thanks
Anand
More information about the Python-list
mailing list