Dear wxPythonistas,
I would like to draw arrows that overlap (over or under) text entry widgets. I read on Stackoverflow [1] that I would need to use the RichTextCtrl, because TextCtrl will not permit modifications to its drawing method. Below is a minimal piece of code that creates two RichTextCtrl objects, puts them i a sizer, and attempts to draw a line across them. The line-drawing portion fails.
Thanks,
Jeff
import wx
import wx.richtext as rt
class DrawPanel(wx.Frame):
def init(self, *args, **kw):
wx.Frame.init(self, *args, **kw)
self.rtc1 = rt.RichTextCtrl(self,
style=wx.VSCROLL|wx.HSCROLL|wx.SIMPLE_BORDER);
self.rtc2 = rt.RichTextCtrl(self,
style=wx.VSCROLL|wx.HSCROLL|wx.SIMPLE_BORDER);
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.rtc1, 1, wx.EXPAND)
self.sizer.Add(self.rtc2, 1, wx.EXPAND)
self.SetSizer(self.sizer)
self.SetAutoLayout(1)
self.sizer.Fit(self)
self.Show()
self.Maximize(True)
self.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, event=None):
dc = wx.PaintDC(self)
dc.Clear()
dc.SetPen(wx.Pen(wx.BLACK, 2))
dc.DrawLine(0, 0, 1000, 1000)
app = wx.App(False)
frame = DrawPanel(None)
frame.Show()
app.MainLoop()