Is there an example on how to use MaskedTextCtrl as a subclass in XRC ?
I am trying to create an EmailField class.
I tried wx.PreTextCtrl and wx.lib.masked.PreMaskedTextCtrl but they all failed when I SetValue() to it.
Attached is the wx.PreTextCtrl sample that gives me a list index out of range error.
PreMaskedTextCtrl already has the code needed to integrate with XRC as a subclass, so just derive your class from that one and let it use the default __init__. If you want to set some properties or whatever when it is initialized then you can override the OnCreate method, just be sure to call the base class version from yours.
class EmailField(masked.PreMaskedTextCtrl):
def SetValue(self, value):
print value
if value is None:
value = ""
masked.BaseMaskedTextCtrl.SetValue(self, value)
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
class EmailField(PreMaskedTextCtrl):
def OnCreate(self, event):
if self is event.GetEventObject():
PreMaskedTextCtrl.OnCreate(self, event)
self.SetCtrlParameters(autoformat=“EMAIL”)
def SetValue(self, value):
if value is None:
value = ""
PreMaskedTextCtrl.SetValue(self, value)
Thanks,
George
···
On Sat, Feb 7, 2009 at 12:22 PM, Robin Dunn robin@alldunn.com wrote:
George Verdad wrote:
Hi All,
Is there an example on how to use MaskedTextCtrl as a subclass in XRC ?
I am trying to create an EmailField class.
I tried wx.PreTextCtrl and wx.lib.masked.PreMaskedTextCtrl but they all failed when I SetValue() to it.
Attached is the wx.PreTextCtrl sample that gives me a list index out of range error.
PreMaskedTextCtrl already has the code needed to integrate with XRC as a subclass, so just derive your class from that one and let it use the default init. If you want to set some properties or whatever when it is initialized then you can override the OnCreate method, just be sure to call the base class version from yours.
class EmailField(masked.PreMaskedTextCtrl):
def SetValue(self, value):
print value
if value is None:
value = ""
masked.BaseMaskedTextCtrl.SetValue(self, value)