I'm writing an editor and just replaced my home-rolled caret
with wx.caret. It vanishes after running a dialog, even though
.IsVisible returns true. Calling .Move, .Show etc. don't help.
Sample app attached (and here).
Thanks in advance for any clues, Phil
import wx
action = """Click on the button,
then cancel the dialog.
The cursor will vanish.
Using wx 2.8.7.1
Python 2.5.2
"""
class Dlg(wx.Dialog):
def __init__(self):
wx.Dialog.__init__(self, None, -1, u"wx.Caret problem")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(wx.StaticText(self, -1, action), 0, wx.ALL, 5)
win = wx.Window(self, -1, size=(100,100))
self.caret = wx.Caret(win, (4, 20))
sizer.Add(win, 0, wx.ALL, 5)
btn = wx.Button(self, -1, "Click me")
sizer.Add(btn, 0, wx.ALL, 5)
btn.Bind(wx.EVT_BUTTON, self.OnClick)
self.SetSizer(sizer)
sizer.Fit(self)
wx.CallAfter(self.MoveCaret, 10,10)
def OnClick(self, evt):
dlg = wx.FileDialog(None, "Caret will vanish", "", "")
dlg.ShowModal()
dlg.Destroy()
def MoveCaret(self, x,y):
if self.caret.IsVisible():
self.caret.Hide()
self.caret.Move((x, y))
self.caret.Show()
if __name__ == '__main__':
app = wx.PySimpleApp()
Dlg().ShowModal()
testcaret.py (1.11 KB)