wxPython and overloading wxTextCtrl

Doug Farrell writeson at earthlink.net
Fri Jan 25 08:16:24 EST 2002


Hi all,

I'm trying to write a class like this:

from wxPython.wx import *

class myTextCtrl(wxTextCtrl):
    def __init__(self, ......)
        wxTextCtrl.__init__(self, ......)


so that I can have my derived class handle the OnSetFocus() event and
have the control automatically select and highlight the current text
in the control when the user moves to that control. This is the
behavior of most, if not all, windows programs. However, I'm having
trouble getting the class definition write so it will run without a
traceback. In the wxPython source code for controls.py I see that
wxTextCtrl is defined as follows:

class wxTextCtrl(wxTextCtrlPtr):
    def __init__(self,*_args,**_kwargs):
        self.this = apply(controlsc.new_wxTextCtrl,_args,_kwargs)
        self.thisown = 1
        self._setOORInfo(self)


And that's it. When I try to define my class like this:

class myTextCtrl(wxTextCtrl):
    def __init__(self, *_args, **_kwargs):
        wxTextCtrl.__init__(self, *_args, **_kwargs)

I get a traceback. Does anyone have any ideas how I should do what I'm
attempting to do?

Thanks,
Doug Farrell



More information about the Python-list mailing list