Hello:
I was wondering if anyone could explain how to draw lines on top of a
TreeCtrl widget. I’ve tried a few things along the lines of the code
shown below:
This draws the lines, but not the TreeCtrl object underneath. I’m kind
of new to this, but I’m assuming that the EVT_PAINT function is
over-writing the TreeCtrl’s own EVT_PAINT…
Any suggestions as to how I might accomplish this?
Hello:
I was wondering if anyone could explain how to draw lines on top of a TreeCtrl widget. I've tried a few things along the lines of the code shown below:
def onPaint(self, event):
dc = wx.PaintDC(self)
dc.BeginDrawing()
dc.SetPen( wx.Pen("BLACK",1) )
dc.DrawLineList( [(10, 100, 50, 100),(10, 200, 50, 200)] )
dc.EndDrawing()
This draws the lines, but not the TreeCtrl object underneath. I'm kind of new to this, but I'm assuming that the EVT_PAINT function is over-writing the TreeCtrl's own EVT_PAINT...
Right. Since you handled the event it is not sent on to the default handler.
Any suggestions as to how I might accomplish this?
Presumably you want to draw your lines on top of what the default paint handler is going to draw, so you need to allow the default handler to run *and then* do your thing. One way to accomplish that is to not do any drawing in your OnPaint, but instead just call event.Skip() so the default handler will still get the event, and also call wx.CallAfter(self.DoMyDrawing) so that your drawing function will be called when the paint event has completed.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!