[wxPython-users] XML subclassing and wx.lib.masked.TimeCtrl
Robin Dunn
robin at alldunn.com
Wed Sep 6 19:48:41 PDT 2006
Basil Shubin wrote:
> Robin Dunn wrote:
>> Basil Shubin wrote:
>>> Robin Dunn wrote:
>>>> Basil Shubin wrote:
>>>>
>>>>>
>>>>> # get masked controls start/finish time
>>>>> self.startTime = xrc.XRCCTRL(self.parent, 'startTime')
>>>>> self.finishTime = xrc.XRCCTRL(self.parent, 'finishTime')
>>>>>
>>
>>> For the above example I make following changes:
>>>
>>> self.parent.Bind(wx.lib.masked.EVT_TIMEUPDATE,
>>> self.OnTimeUpdate,
>>> self.startTime.timeCtrl)
>>>
>>> and I recive an error:
>>>
>>> AttributeError: 'WorkoutTime' object has no attribute 'timeCtrl'
>>>
>>> What is my fault?
>>>
>>
>> You probably want to use just self.startTime, don't you? Are you
>> expecting self.startTime to have a timeCtrl attribute? Do you give it
>> one in your code anyplace?
>
> I am puzzled totally! Yes, I want to use just self.startTime. timeCtrl
> is created in the OnCreate method of WorkoutTime subclass, is it
> timeCtrl its attribute or what? self.startTime itself is not wxTimeCtrl,
> right? so it cannot recive EVT_TIMEUPDATE event, right? Uhh, I am
> totally puzzled! :-(
I think I am confused now too.
What type is self.startTime? I assume that is the object you are
creating with your XRC subclass?
If it is not a TimeCtrl, but contains one, then yes, you'll need to do
something like self.startTime.timeCtrl to get to it, but if
self.startTime.timeCtrl is not created until the OnCreate then it may
not exist yet. One approach you can take is to move the event handler
to the WorkoutTime class and do the binding in OnCreate. Then the
handler can call a method in the parent if needed, or perhaps just send
a message, or whatever.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list