johnf wrote:
> I have sub-classed dTextBox to provide a way to validate numbers. In this
> case I'm trying to provide a visual clue to the user that number is invalid
> by setting the background color of the textbox to pink.
>
> With (self.IntegerWidth = 2 and self.DecimalWidth =2
>
> self.BackColor executes if I type ".999" in the following code. But I only
> get a color change sometimes.
>
> pattern='^([0-9]{0,%s})(\.[0-9]{0,%s})?$' % (self.IntegerWidth,
> self.DecimalWidth)
> if re.match(pattern, self.GetValue())is None:
> self.BackColor == "pink"
> else:
> self.BackColor == "white"
>
>
> Is there some interaction between my class and dTextBox? Or BackColor has
> some bug?
John, I gotta run, so don't take these quick points personally, but
constructively:
1) This should be posted on dabo-users, not dabo-dev.
2) Liberal print statements help (is the codeblock even running?)
3) No space between ) and 'is None:' should cause syntax error.
4) Unit test your regex to make sure it is working how you expect.
5) Instead of "white", set the normal background to something like
'blue' so you know if the code block is working or not.
--
pkm ~ http://paulmcnett.com
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]