Masked TextEdit

Hi,

I'm trying to understand the masked textctrl.
Something is strange about it. Simple scenario.
I have a zipcode field. I use the USZIPPLUS4 autoformat.
So far so good, everything fine. However when I tell it "emptyInvalid=True"
There is a difference between validation and emptyvalidation.
I want the user to type something valid in there (so NOT empty), but I don't
want to force the last 4 digits. This is fine with the validation, but not
with the emptyInvalid set.
I tried to address the fields, but all autoformats only have one field !

Since I can't get this working another question:
Is there a way to set the background color similar to the way I'd do it in a
normal TextCtrl ?
Then I could omit the emptyInvalid alltogether, since that's the behaviour of
all non-masked fields

Aka:

------------- snip ------------
              text = textCtrl.GetValue()
              if len(text) == 0:
                   if self._message:
                        wx.MessageBox(self._message, "Error")
                   else:
                        wx.MessageBox("Field requires a value !", "Error")
                   textCtrl.SetBackgroundColour("pink")
                   textCtrl.SetFocus()
                   textCtrl.Refresh()
                   return False
              else:
                   textCtrl.SetBackgroundColour(
                        wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))
                   textCtrl.Refresh()
                   return True
-------- snip ---------

Please don't tell me I have to create the format myself. I drive the widget
generation completely off a database and I'd have to make major changes to my
db.

Any help is appreciated

  UC

···

--
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417

Ok, I figured the first part. One should check how the mask is created, so no
wonder it only had one field :frowning: (I should get a whiskey to start thinking
clearly :-))
Anyways. It still doesn't work.
I have the USZIPPLUS4 and set field 0 to

xx.SetFieldParameters(0,emptyInvalid=True)
and I explicitly set
xx.SetFieldParameters(1,emptyInvalid=False)

However the value

94066-

is still invalid.
To my understanding it should be fine.

I'll play some more with it ....

···

On Thursday 05 June 2003 09:41 pm, Uwe C. Schroeder wrote:

Hi,

I'm trying to understand the masked textctrl.
Something is strange about it. Simple scenario.
I have a zipcode field. I use the USZIPPLUS4 autoformat.
So far so good, everything fine. However when I tell it "emptyInvalid=True"
There is a difference between validation and emptyvalidation.
I want the user to type something valid in there (so NOT empty), but I
don't want to force the last 4 digits. This is fine with the validation,
but not with the emptyInvalid set.
I tried to address the fields, but all autoformats only have one field !

Since I can't get this working another question:
Is there a way to set the background color similar to the way I'd do it in
a normal TextCtrl ?
Then I could omit the emptyInvalid alltogether, since that's the behaviour
of all non-masked fields

Aka:

------------- snip ------------
              text = textCtrl.GetValue()
              if len(text) == 0:
                   if self._message:
                        wx.MessageBox(self._message, "Error")
                   else:
                        wx.MessageBox("Field requires a value !", "Error")
                   textCtrl.SetBackgroundColour("pink")
                   textCtrl.SetFocus()
                   textCtrl.Refresh()
                   return False
              else:
                   textCtrl.SetBackgroundColour(
                        wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))
                   textCtrl.Refresh()
                   return True
-------- snip ---------

Please don't tell me I have to create the format myself. I drive the widget
generation completely off a database and I'd have to make major changes to
my db.

Any help is appreciated

  UC

--
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

--
  UC

--
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417