Draw over or under the widgets in a sizer

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

[1] http://stackoverflow.com/questions/22592281/is-it-possible-to-draw-on-a-textctrl-and-if-so-how/28651972#28651972

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()

If you change the dc to draw on the rtc itself, it at least draws the line
at first:

        dc = wx.PaintDC(self.rtc2)

but it's not a solution because, I think, every time you click into the
richtextctrl it repaints and uses the text entered as what to paint it
with.

What do you need a drawn line for if there is already a line across the two
richTextCtrls due to their borders?

ยทยทยท

On Sat, Feb 21, 2015 at 8:43 PM, Jeffrey Brown <jeffbrown.the@gmail.com> wrote:

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

[1]
wxpython - Is it possible to draw on a TextCtrl? And if so, how? - Stack Overflow