masked.NumCtrl wierd behaviour

hi all

If I do this:
self.txt_limit = masked.NumCtrl(pane, -1, value = 30)
self.txt_limit.SetParameters( integerWidth = 3)
self.txt_limit.SetValue(30)

I get a valuerror:

ValueError: value 3030 exceeds the integer width of the control

By increasing the integerWidth the NumCtrl ends up with a value of 30, wich is right, but anyway before displaing itself he thinks of having a value of 3030 (the reseved gui space is bigger too)

Marco De Felice wrote:

hi all

If I do this:
self.txt_limit = masked.NumCtrl(pane, -1, value = 30)
self.txt_limit.SetParameters( integerWidth = 3)
self.txt_limit.SetValue(30)

I get a valuerror:

ValueError: value 3030 exceeds the integer width of the control

I have seen this too, I think it is a but in NumCtrl that sometimes the SetValue does not align correctly. For example if you change integerWidth to 4 it will probably go away.

By increasing the integerWidth the NumCtrl ends up with a value of 30, wich is right, but anyway before displaing itself he thinks of having a value of 3030 (the reseved gui space is bigger too)

It reserves space for negative value, change AllowNegative to False.

You might also want to use ChangeValue, so that you do not generate change events when programmatically changing the value.

BTW, if I do the following on Py26 and wxPython 2.8.9.1pre (I think I have seen this on earlier versions too) I get a crash, instead of a crash.

        self.numCtrl1 = wx.lib.masked.numctrl.NumCtrl(id=wxID_FRAME1NUMCTRL1,
              name='numCtrl1', parent=self.panel1, pos=wx.Point(0, 33),
              size=wx.Size(29, 22), style=0, value=0)
        self.numCtrl1.SetAllowNegative(False)
        self.numCtrl1.SetIntegerWidth(3)

        self.numCtrl1.ChangeValue(3000)

but the following is fine:
        self.numCtrl1.ChangeValue(300)

Werner

Werner F. Bruhin wrote:

Marco De Felice wrote:

hi all

If I do this:
self.txt_limit = masked.NumCtrl(pane, -1, value = 30)
self.txt_limit.SetParameters( integerWidth = 3)
self.txt_limit.SetValue(30)

I get a valuerror:

ValueError: value 3030 exceeds the integer width of the control

I have seen this too, I think it is a but in NumCtrl that sometimes the SetValue does not align correctly. For example if you change integerWidth to 4 it will probably go away.

By increasing the integerWidth the NumCtrl ends up with a value of 30, wich is right, but anyway before displaing itself he thinks of having a value of 3030 (the reseved gui space is bigger too)

It reserves space for negative value, change AllowNegative to False.

You might also want to use ChangeValue, so that you do not generate change events when programmatically changing the value.

BTW, if I do the following on Py26 and wxPython 2.8.9.1pre (I think I have seen this on earlier versions too) I get a crash, instead of a crash.

I'm confused by this...what is the difference between the crashes )i.e. "I get a crash, instead of a crash")?

- Mike

Hi Mike,

Mike Driscoll wrote:
...

BTW, if I do the following on Py26 and wxPython 2.8.9.1pre (I think I have seen this on earlier versions too) I get a crash, instead of a crash.

I'm confused by this...what is the difference between the crashes )i.e. "I get a crash, instead of a crash")?

Maybe time to go to bed :slight_smile: , should read "I get a crash, instead of a nice traceback"

Werner

No, Werner, you should stay up even later and compose more of
these zen koans! :smiley:

ยทยทยท

On 5/14/09, Werner F. Bruhin <werner.bruhin@free.fr> wrote:

Hi Mike,

Mike Driscoll wrote:
...

BTW, if I do the following on Py26 and wxPython 2.8.9.1pre (I think I
have seen this on earlier versions too) I get a crash, instead of a
crash.

I'm confused by this...what is the difference between the crashes
)i.e. "I get a crash, instead of a crash")?

Maybe time to go to bed :slight_smile: , should read "I get a crash, instead of a
nice traceback"

Werner