textctrl presentation

Hi list,

what is the best way to have a nice presentation (input also?) of
textCtrls?

ie: 2,145,145,789.19 vs 2145145789.19
    2011-12-07 vs 07/12/2011
    XX 11-234567 vs XX11234567

JY

···

--
Alexander Graham Bell is alive and well in New York, and still
waiting for a dial tone.

Jean-Yves,

···

On 12/07/2011 12:15 AM, Jean-Yves F. Barbier wrote:

Hi list,

what is the best way to have a nice presentation (input also?) of
textCtrls?

ie: 2,145,145,789.19 vs 2145145789.19
     2011-12-07 vs 07/12/2011
     XX 11-234567 vs XX11234567

Have a look at wx.lib.masked, first would be a MaskedNumCtrl and the third a MaskedTextCtrl. For the date I would probably use wx.DatePickerCtrl.

Check out the wxPython demo.

Werner

> ie: 2,145,145,789.19 vs 2145145789.19
> 2011-12-07 vs 07/12/2011
> XX 11-234567 vs XX11234567
>
Have a look at wx.lib.masked, first would be a MaskedNumCtrl and the
third a MaskedTextCtrl.

Thanks Werner, that's exactly what I wanted:)

For the date I would probably use
wx.DatePickerCtrl.

I use it but didn't found out how to change the displayed date to
my format instead of the default one.

JY

···

On Wed, 07 Dec 2011 08:53:34 +0100 werner <wbruhin@free.fr> wrote:
--
  "It's today!" said Piglet.
  "My favorite day," said Pooh.

Oops, didn't catch on that it is another 370 style thingy;-)

http://docs.wxwidgets.org/stable/wx_wxdatepickerctrl.html#wxdatepickerctrlsetformat

But only with the generic version of the control as per the doc, otherwise it default to the format set in the users locale.

Werner

···

On 12/07/2011 01:59 PM, Jean-Yves F. Barbier wrote:

On Wed, 07 Dec 2011 08:53:34 +0100 > werner<wbruhin@free.fr> wrote:

ie: 2,145,145,789.19 vs 2145145789.19
      2011-12-07 vs 07/12/2011
      XX 11-234567 vs XX11234567

Have a look at wx.lib.masked, first would be a MaskedNumCtrl and the
third a MaskedTextCtrl.

Thanks Werner, that's exactly what I wanted:)

  For the date I would probably use
wx.DatePickerCtrl.

I use it but didn't found out how to change the displayed date to
my format instead of the default one.

Of course masked text control supports dates as well, EUDATEYYYYMMDD. or
EUDATEYYYYMMDD/ nearly do what you need or you could use a mask of
####-##-## and if necessary supply a validator.

Gadget/Steve

···

On 07/12/2011 2:03 PM, werner wrote:

On 12/07/2011 01:59 PM, Jean-Yves F. Barbier wrote:

On Wed, 07 Dec 2011 08:53:34 +0100 >> werner<wbruhin@free.fr> wrote:

ie: 2,145,145,789.19 vs 2145145789.19
      2011-12-07 vs 07/12/2011
      XX 11-234567 vs XX11234567

Have a look at wx.lib.masked, first would be a MaskedNumCtrl and the
third a MaskedTextCtrl.

Thanks Werner, that's exactly what I wanted:)

  For the date I would probably use
wx.DatePickerCtrl.

I use it but didn't found out how to change the displayed date to
my format instead of the default one.

Oops, didn't catch on that it is another 370 style thingy;-)

http://docs.wxwidgets.org/stable/wx_wxdatepickerctrl.html#wxdatepickerctrlsetformat

But only with the generic version of the control as per the doc,
otherwise it default to the format set in the users locale.

Werner

Good point, only thing it doesn't have a popup, but then it would be faster for data entry, ala 370;-)

        "JEANDATEYYYYMMDD.": {
            'mask': "####-##-##",
            'formatcodes': 'DF',
            'validRegex': '^' + '\d{4}'+ '-' + months + '-' + days,
            'description': "YYYY-MM-DD"
            },

or:

textctrl.SetCtrlParameters(mask = "####-##-##",
                             formatcodes = 'DF',
                             validRegex = '^' + '\d{4}'+ '-' + months + '-' + days,
                             emptyInvalid = ctrl['emptyInvalid'])

Totally untested, see wx.lib.masked.maskededit.masktags for more info.

Werner

P.S. I promise I stop with the 370 references:)

···

On 12/07/2011 03:32 PM, Gadget/Steve wrote:

On 07/12/2011 2:03 PM, werner wrote:

On 12/07/2011 01:59 PM, Jean-Yves F. Barbier wrote:

On Wed, 07 Dec 2011 08:53:34 +0100 >>> werner<wbruhin@free.fr> wrote:

ie: 2,145,145,789.19 vs 2145145789.19
       2011-12-07 vs 07/12/2011
       XX 11-234567 vs XX11234567

Have a look at wx.lib.masked, first would be a MaskedNumCtrl and the
third a MaskedTextCtrl.

Thanks Werner, that's exactly what I wanted:)

   For the date I would probably use
wx.DatePickerCtrl.

I use it but didn't found out how to change the displayed date to
my format instead of the default one.

Oops, didn't catch on that it is another 370 style thingy;-)

http://docs.wxwidgets.org/stable/wx_wxdatepickerctrl.html#wxdatepickerctrlsetformat

But only with the generic version of the control as per the doc,
otherwise it default to the format set in the users locale.

Werner

Of course masked text control supports dates as well, EUDATEYYYYMMDD. or
EUDATEYYYYMMDD/ nearly do what you need or you could use a mask of
####-##-## and if necessary supply a validator.

I plan much better: a port on an AppleII (my first computer:)

···

On Wed, 07 Dec 2011 15:03:58 +0100 werner <wbruhin@free.fr> wrote:

Oops, didn't catch on that it is another 370 style thingy;-)

--

Ok, thanks; I browse the web using your info and find some examples,
although there's a big PB: SetFormat isn't part of wxPython
2.8.12.1-4, it doesn't appear in pydoc and a test:

self.myDP.SetFormat("%y-%m-%d")

errors as:

AttributeError: 'GenericDatePickerCtrl' object has no
  attribute 'SetFormat'

So, either I missed the whole picture (which is totally possible),
or I'm a sitting duck.

JY

···

On Wed, 07 Dec 2011 15:03:58 +0100 werner <wbruhin@free.fr> wrote:

http://docs.wxwidgets.org/stable/wx_wxdatepickerctrl.html#wxdatepickerctrlsetformat

But only with the generic version of the control as per the doc,
otherwise it default to the format set in the users locale.

--
If men could get pregnant, abortion would be a sacrament.

Jean-Yves,

···

On 12/07/2011 04:44 PM, Jean-Yves F. Barbier wrote:

On Wed, 07 Dec 2011 15:03:58 +0100 > werner<wbruhin@free.fr> wrote:

http://docs.wxwidgets.org/stable/wx_wxdatepickerctrl.html#wxdatepickerctrlsetformat

But only with the generic version of the control as per the doc,
otherwise it default to the format set in the users locale.

Ok, thanks; I browse the web using your info and find some examples,
although there's a big PB: SetFormat isn't part of wxPython
2.8.12.1-4, it doesn't appear in pydoc and a test:

self.myDP.SetFormat("%y-%m-%d")

errors as:

AttributeError: 'GenericDatePickerCtrl' object has no
   attribute 'SetFormat'

I see the same on 2.9.2.4.

Will have to wait for Robin or someone else to chip in who actually used this.

Werner

That method was removed in 2.9. I'm not sure why it was never wrapped in 2.8, perhaps it was added later and I didn't notice it.

···

On 12/7/11 8:36 AM, werner wrote:

Jean-Yves,

On 12/07/2011 04:44 PM, Jean-Yves F. Barbier wrote:

On Wed, 07 Dec 2011 15:03:58 +0100 >> werner<wbruhin@free.fr> wrote:

http://docs.wxwidgets.org/stable/wx_wxdatepickerctrl.html#wxdatepickerctrlsetformat

But only with the generic version of the control as per the doc,
otherwise it default to the format set in the users locale.

Ok, thanks; I browse the web using your info and find some examples,
although there's a big PB: SetFormat isn't part of wxPython
2.8.12.1-4, it doesn't appear in pydoc and a test:

self.myDP.SetFormat("%y-%m-%d")

errors as:

AttributeError: 'GenericDatePickerCtrl' object has no
attribute 'SetFormat'

I see the same on 2.9.2.4.

Will have to wait for Robin or someone else to chip in who actually used
this.

--
Robin Dunn
Software Craftsman