Titel: self.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus, self.rtc); self.rtc.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus)
Mir ist etwas komisches aufgefallen:
Normalerweise bindet man ja Events per self.Bind(evt, handler, source, id1, id2)
das hat bei mir aber nicht funktioniert und ich musste: self.(source).Bind(evt, handler) verwenden, siehe Besipiel
Code: Alles auswählen
import wx
import wx.richtext as rt
class NotebookPages(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent, id)
vbox = wx.BoxSizer(wx.VERTICAL)
hbox1 = wx.BoxSizer(wx.HORIZONTAL)
# more hboxes
self.rtc = rt.RichTextCtrl(self, style=wx.HSCROLL | rt.RE_READONLY | rt.TEXT_ATTR_URL)
hbox1.Add(self.rtc, 5, wx.EXPAND | wx.ALL, 10)
vbox.Add(hbox1, 1, wx.EXPAND)
# more GUI Layout
self.SetSizer(vbox)
self.rtc.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus)
def on_kill_focus(self, event):
# do something!
pass