from wxPython.wx import * class myTextCtrl(wxTextCtrl): def __init__(self, *_args, **_kwargs): wxTextCtrl.__init__(self, *_args, **_kwargs) EVT_MOUSE_EVENTS(self, self.OnMouseEvent) EVT_TEXT(self, self.EvtText) EVT_CHAR(self, self.EvtChar) self.focus = false def OnMouseEvent(self,event): if event.LeftDown():#mouse down if not self.focus: print 'Highlight' self.focus = true def EvtText(self,event): pass def EvtChar(self,event): pass class ViewerFrame(wxFrame): def __init__(self, parent, id, title): wxFrame.__init__(self, parent, id, title,wxDefaultPosition,wxDefaultSize) mything = myTextCtrlt1 = wxTextCtrl(self, 10, "Test", size=(125, -1)) class MyApp(wxApp): def OnInit(self): frame = ViewerFrame(NULL, -1, "Test") frame.Show(true) self.SetTopWindow(frame) return true app = MyApp(0) app.MainLoop()