digit/integer value from wxTextCtrl

Guys help me out. I wanna make user only enter
integer/digit in wxTextCtrl.

if user input correctly is not a problems but when i
tried to enter wrongly I dont know how to prevent it.

value1 = self.Entry1.GetValue()

I can't use isdigit() I don't know why.

I use Boa contructor v0.2.3 on wxPython 2.4 for Python
2.3 on w2k

please help me out

thankx

danu

···

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

take a look at maskededit.py in the current CVS tree under lib/
It can do that and more.

···

On Sunday 08 June 2003 07:15 pm, danu kusmana wrote:

Guys help me out. I wanna make user only enter
integer/digit in wxTextCtrl.

if user input correctly is not a problems but when i
tried to enter wrongly I dont know how to prevent it.

value1 = self.Entry1.GetValue()

I can't use isdigit() I don't know why.

I use Boa contructor v0.2.3 on wxPython 2.4 for Python
2.3 on w2k

please help me out

thankx

danu

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

---------------------------------------------------------------------
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

There's an excellent integer control in the demo that comes with
wxPython 2.4.0.7. The first section (called Recent Additions) contains
"wxIntCtrl" which should be exactly what you're looking for.
Unfortunately, I don't know if it's included in, or accessible from Boa
- maybe someone else has some experience with adding or using Boa
controls. Good luck,
Dan Cherry

···

-----Original Message-----
From: danu kusmana [mailto:danu_milis@yahoo.com]
Sent: Sunday, June 08, 2003 10:16 PM
To: wxpython
Subject: [wxPython-users] digit/integer value from wxTextCtrl

Guys help me out. I wanna make user only enter
integer/digit in wxTextCtrl.

if user input correctly is not a problems but when i
tried to enter wrongly I dont know how to prevent it.

value1 = self.Entry1.GetValue()

I can't use isdigit() I don't know why.

I use Boa contructor v0.2.3 on wxPython 2.4 for Python
2.3 on w2k

please help me out

thankx

danu

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

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

wxPython-users-help@lists.wxwindows.org

danu kusmana wrote:

Guys help me out. I wanna make user only enter
integer/digit in wxTextCtrl.

if user input correctly is not a problems but when i
tried to enter wrongly I dont know how to prevent it.

value1 = self.Entry1.GetValue()

I can't use isdigit() I don't know why.

You can also build a small validator that makes sure that alpha characters
are not accepted. Take a look at the demo's wxValidator section under Core
Windows/Controls.

Ilia Kats

I'd try using what u suggested but it still doesn't
work. I make a new module TextObjectValidator.py & all
the source is the same like in the demo(class
TextObjectValidator). In wxFrame I add:

from TextObjectValidator import TextObjectValidator

& tried:

1. self.Umur = wxTextCtrl(id=wxID_MAINMENUUMUR,
name='Umur', parent=self.panel1, pos=wxPoint(168, 88),
size=wxSize(100, 21), style=0, value='',
validator=TextObjectValidator())

or

2. self.Umur = wxTextCtrl(id=wxID_MAINMENUUMUR,
name='Umur', parent=self.panel1, pos=wxPoint(168, 88),
size=wxSize(100, 21), style=0, value='')
self.Umur.SetValidator(TextObjectValidator())

or

3. in my wxButton event I add:
    self.Umur.SetValidator(TextObjectValidator())

But nothing works. When I tried to go to designer mode
in Boa I got error message "name TextObjectValidator"
not defined when I tried 1 & 2

help me please

danu

···

--- Ilia Kats <ilia_kats@hotmail.com> wrote:

danu kusmana wrote:
> Guys help me out. I wanna make user only enter
> integer/digit in wxTextCtrl.
>
> if user input correctly is not a problems but when
i
> tried to enter wrongly I dont know how to prevent
it.
>
> value1 = self.Entry1.GetValue()
>
> I can't use isdigit() I don't know why.
>
You can also build a small validator that makes sure
that alpha characters
are not accepted. Take a look at the demo's
wxValidator section under Core
Windows/Controls.

Ilia Kats

---------------------------------------------------------------------

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

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

danu kusmana wrote:

I'd try using what u suggested but it still doesn't
work. I make a new module TextObjectValidator.py & all
the source is the same like in the demo(class
TextObjectValidator). In wxFrame I add:

Look at the MyValidator class in the same module, it is closer to what you are wanting I think.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

danu kusmana wrote:

I'd try using what u suggested but it still doesn't
work. I make a new module TextObjectValidator.py & all
the source is the same like in the demo(class
TextObjectValidator). In wxFrame I add:

from TextObjectValidator import TextObjectValidator

& tried:

1. self.Umur = wxTextCtrl(id=wxID_MAINMENUUMUR,
name='Umur', parent=self.panel1, pos=wxPoint(168, 88),
size=wxSize(100, 21), style=0, value='',
validator=TextObjectValidator())

or

2. self.Umur = wxTextCtrl(id=wxID_MAINMENUUMUR,
name='Umur', parent=self.panel1, pos=wxPoint(168, 88),
size=wxSize(100, 21), style=0, value='')
self.Umur.SetValidator(TextObjectValidator())

or

3. in my wxButton event I add:
    self.Umur.SetValidator(TextObjectValidator())

But nothing works. When I tried to go to designer mode
in Boa I got error message "name TextObjectValidator"
not defined when I tried 1 & 2

This code bellow works. Though, it doesn't capture the copy&paste insertions
to the wxTextCtrl. In other word you can 'copy' some text that contains
alpha characters and 'paste' it to the control.

BTW: Will (Sadkin), how did you handle this (copy & paste) thing in
wxMaksedTextCtrl?

···

#----------------------------------------------------------------------
from wxPython.wx import *
import string

class MyValidator(wxPyValidator):
    def __init__(self, pyVar=None):
        wxPyValidator.__init__(self)
        EVT_CHAR(self, self.OnChar)

    def Clone(self):
        return MyValidator()

    def Validate(self, win):
        tc = self.GetWindow()
        val = tc.GetValue()

        for x in val:
            if x not in string.digits:
                return False
        return True

    def OnChar(self, event):
        key = event.KeyCode()
        if key < WXK_SPACE or key == WXK_DELETE or key > 255:
            event.Skip()
            return
        if chr(key) in string.digits:
            event.Skip()
            return

        if not wxValidator_IsSilent():
            wxBell()

        # Returning without calling even.Skip eats the event before it
        # gets to the text control
        return

app = wxPySimpleApp()
frm = wxFrame(None, wxNewId(), 'MyValidator')
pnl = wxPanel(frm , wxNewId())
wxTextCtrl(pnl, wxNewId(), '', validator = MyValidator())
frm.Show(True)
app.MainLoop()
#----------------------------------------------------------------------

begin 666 p1.py
M9G)O;2!W>%!Y=&AO;BYW>"!I;7!O<G0@*@T*:6UP;W)T('-T<FEN9PT*#0HC
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+0T*(RTM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2T-"F-L87-S($UY5F%L:61A=&]R*'=X4'E686QI9&%T;W(I.@T*
M(" @(&1E9B!?7VEN:71?7RAS96QF+"!P>59A<CU.;VYE*3H-"B @(" @(" @
M=WA0>59A;&ED871O<BY?7VEN:71?7RAS96QF*0T*(" @(" @("!%5E1?0TA!
M4BAS96QF+"!S96QF+D]N0VAA<BD-"@T*(" @(&1E9B!#;&]N92AS96QF*3H-
M"B @(" @(" @<F5T=7)N($UY5F%L:61A=&]R*"D-"@T*(" @(&1E9B!686QI
M9&%T92AS96QF+"!W:6XI.@T*(" @(" @("!T8R ]('-E;&8N1V5T5VEN9&]W
M*"D-"B @(" @(" @=F%L(#T@=&,N1V5T5F%L=64H*0T*#0H@(" @(" @(&9O
M<B!X(&EN('9A;#H-"B @(" @(" @(" @(&EF('@@;F]T(&EN('-T<FEN9RYD
M:6=I=',Z#0H@(" @(" @(" @(" @(" @<F5T=7)N($9A;'-E#0H@(" @(" @
M(')E='5R;B!4<G5E#0H-"B @("!D968@3VY#:&%R*'-E;&8L(&5V96YT*3H-
M"B @(" @(" @:V5Y(#T@979E;G0N2V5Y0V]D92@I#0H@(" @(" @(&EF(&ME

2 \(%=82U]34$%#12!O<B!K97D@/3T@5UA+7T1%3$5412!O<B!K97D@/B R

M-34Z#0H@(" @(" @(" @("!E=F5N="Y3:VEP*"D-"B @(" @(" @(" @(')E
M='5R;@T*(" @(" @("!I9B!C:'(H:V5Y*2!I;B!S=')I;F<N9&EG:71S.@T*
M(" @(" @(" @(" @979E;G0N4VMI<"@I#0H@(" @(" @(" @("!R971U<FX-
M"@T*(" @(" @("!I9B!N;W0@=WA686QI9&%T;W)?27-3:6QE;G0H*3H-"B @
M(" @(" @(" @('=X0F5L;"@I#0H-"B @(" @(" @(R!2971U<FYI;F<@=VET
M:&]U="!C86QL:6YG(&5V96XN4VMI<"!E871S('1H92!E=F5N="!B969O<F4@
M:70-"B @(" @(" @(R!G971S('1O('1H92!T97AT(&-O;G1R;VP-"B @(" @
M(" @<F5T=7)N#0HC+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+0T*(RTM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2T-"@T*87!P(#T@=WA0>5-I;7!L94%P<"@I
M#0IF<FT@/2!W>$9R86UE*$YO;F4L('=X3F5W260H*2P@)TUY5F%L:61A=&]R
M)RD-"G!N;" ]('=X4&%N96PH9G)M("P@=WA.97=)9"@I*0T*=WA497AT0W1R
M;"AP;FPL('=X3F5W260H*2P@)R<L('9A;&ED871O<B ]($UY5F%L:61A=&]R
C*"DI#0IF<FTN4VAO=RA4<G5E*0T*87!P+DUA:6Y,;V]P*"D`
`
end

Hi Danu,

wxIntCtrl and/or maskeditctrl should do what you want - latest editions are in the CVS.

To use them from within Boa you should be able to define them as custom classes (examples\advanced\customclasses) in Boa, haven't tried these particular controls but it did the trick for others.

See you
Werner

danu kusmana wrote:

···

Guys help me out. I wanna make user only enter
integer/digit in wxTextCtrl.

if user input correctly is not a problems but when i
tried to enter wrongly I dont know how to prevent it.

value1 = self.Entry1.GetValue()

I can't use isdigit() I don't know why.

I use Boa contructor v0.2.3 on wxPython 2.4 for Python
2.3 on w2k

please help me out

thankx

danu

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

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

Yes thank you very much its really works

danu

···

--- "Werner F. Bruhin" <werner.bruhin@free.fr> wrote:

Hi Danu,

wxIntCtrl and/or maskeditctrl should do what you
want - latest editions
are in the CVS.

To use them from within Boa you should be able to
define them as custom
classes (examples\advanced\customclasses) in Boa,
haven't tried these
particular controls but it did the trick for others.

See you
Werner

danu kusmana wrote:

>Guys help me out. I wanna make user only enter
>integer/digit in wxTextCtrl.
>
>if user input correctly is not a problems but when
i
>tried to enter wrongly I dont know how to prevent
it.
>
>value1 = self.Entry1.GetValue()
>
>I can't use isdigit() I don't know why.
>
>I use Boa contructor v0.2.3 on wxPython 2.4 for
Python
>2.3 on w2k
>
>
>please help me out
>
>thankx
>
>danu
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Calendar - Free online calendar with sync to
Outlook(TM).
>http://calendar.yahoo.com
>

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

---------------------------------------------------------------------

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

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com