[wxPython] Setting cursor to default to wxTextCtrl in wxPython

Platform = Win32

Python Version = 2.1.x

Hi there,

I have an application which has a child dialog box which is used as a login screen … (see sample code below) … what I would like to do is when this method is called, to have the cursor automatically be set in the username test control box ready to type text … rather than having to manually place the cursor in the field with the mouse … I know it must be simple … but I have not been able to locate the appropriate info … would someone be kind enough to point me to some documentation regarding how to do this or some pointers in the right direction

thanks in advance

Ben

def OnLogIn(self, event):
    self.login_dialogue = wxDialog(self, -1, "Login", wxDefaultPosition, wxSize(200, 150))
    self.login_dialogue.SetBackgroundColour(wxColour(red=170, green=180, blue=190) )


    # USERNAME STATIC TEXT LABEL
    self.user_name_login_txt = wxStaticText(self.login_dialogue, -1, "Username", wxDLG_PNT(self.login_dialogue, 10, 5))

    # USERNAME BOX
    self.user_name_login_box = wxTextCtrl(self.login_dialogue, -1, '', wxDLG_PNT(self.login_dialogue, 10, 15 ), wxDLG_SZE(self.login_dialogue, 110, 16))       

    # PASSWORD STATIC TEXT LABEL
    self.password_login_txt = wxStaticText(self.login_dialogue, -1, "Password", wxDLG_PNT(self.login_dialogue, 10, 35))

    # PASSWORD BOX
    self.password_login_box = wxTextCtrl(self.login_dialogue, ID_OK_LOGIN, '', wxDLG_PNT(self.login_dialogue, 10, 45 ), wxDLG_SZE(self.login_dialogue, 110, 16), style=wxTE_PASSWORD | wxTE_PROCESS_ENTER )       

    # ON ENTER KEY EVENT CALL LOGIN METHOD
    EVT_TEXT_ENTER(self.password_login_box,  ID_OK_LOGIN, self.OnOKLogin)
   
    self.login_dialogue.ShowModal()

try this:
self.user_name_login_box.SetFocus ()

Quoting Ben Catanzariti <benc@rehame.com>:

···

# Platform = Win32
# Python Version = 2.1.x

Hi there,

I have an application which has a child dialog box which is used as a login
screen .... (see sample code below) ... what I would like to do is when this
method is called, to have the cursor automatically be set in the username
test control box ready to type text ... rather than having to manually place
the cursor in the field with the mouse ... I know it must be simple ... but I
have not been able to locate the appropriate info .... would someone be kind
enough to point me to some documentation regarding how to do this or some
pointers in the right direction

thanks in advance

Ben

    def OnLogIn(self, event):
        self.login_dialogue = wxDialog(self, -1, "Login", wxDefaultPosition,
wxSize(200, 150))
        self.login_dialogue.SetBackgroundColour(wxColour(red=170, green=180,
blue=190) )
     
        # USERNAME STATIC TEXT LABEL
        self.user_name_login_txt = wxStaticText(self.login_dialogue, -1,
"Username", wxDLG_PNT(self.login_dialogue, 10, 5))

        # USERNAME BOX
        self.user_name_login_box = wxTextCtrl(self.login_dialogue, -1, '',
wxDLG_PNT(self.login_dialogue, 10, 15 ), wxDLG_SZE(self.login_dialogue, 110,
16))

        # PASSWORD STATIC TEXT LABEL
        self.password_login_txt = wxStaticText(self.login_dialogue, -1,
"Password", wxDLG_PNT(self.login_dialogue, 10, 35))

        # PASSWORD BOX
        self.password_login_box = wxTextCtrl(self.login_dialogue,
ID_OK_LOGIN, '', wxDLG_PNT(self.login_dialogue, 10, 45 ),
wxDLG_SZE(self.login_dialogue, 110, 16), style=wxTE_PASSWORD |
wxTE_PROCESS_ENTER )

        # ON ENTER KEY EVENT CALL LOGIN METHOD
        EVT_TEXT_ENTER(self.password_login_box, ID_OK_LOGIN,
self.OnOKLogin)
        
        self.login_dialogue.ShowModal()

-------------------------------------------------
This mail sent through IMP: http://www.cdc.unict.it/

Thanks for that

···

----- Original Message -----
From: "Corrado Santoro" <csanto@diit.unict.it>
To: <wxpython-users@lists.wxwindows.org>
Sent: Friday, September 06, 2002 7:42 PM
Subject: Re: [wxPython] Setting cursor to default to wxTextCtrl in wxPython

try this:
self.user_name_login_box.SetFocus ()

Quoting Ben Catanzariti <benc@rehame.com>:

> # Platform = Win32
> # Python Version = 2.1.x
>
> Hi there,
>
> I have an application which has a child dialog box which is used as a

login

> screen .... (see sample code below) ... what I would like to do is when

this

> method is called, to have the cursor automatically be set in the

username

> test control box ready to type text ... rather than having to manually

place

> the cursor in the field with the mouse ... I know it must be simple ...

but I

> have not been able to locate the appropriate info .... would someone be

kind

> enough to point me to some documentation regarding how to do this or

some

> pointers in the right direction
>
> thanks in advance
>
> Ben
>
>
>
>
> def OnLogIn(self, event):
> self.login_dialogue = wxDialog(self, -1, "Login",

wxDefaultPosition,

> wxSize(200, 150))
> self.login_dialogue.SetBackgroundColour(wxColour(red=170,

green=180,

> blue=190) )
>
>
> # USERNAME STATIC TEXT LABEL
> self.user_name_login_txt = wxStaticText(self.login_dialogue, -1,
> "Username", wxDLG_PNT(self.login_dialogue, 10, 5))
>
> # USERNAME BOX
> self.user_name_login_box = wxTextCtrl(self.login_dialogue, -1,

'',

> wxDLG_PNT(self.login_dialogue, 10, 15 ), wxDLG_SZE(self.login_dialogue,

110,

> 16))
>
> # PASSWORD STATIC TEXT LABEL
> self.password_login_txt = wxStaticText(self.login_dialogue, -1,
> "Password", wxDLG_PNT(self.login_dialogue, 10, 35))
>
> # PASSWORD BOX
> self.password_login_box = wxTextCtrl(self.login_dialogue,
> ID_OK_LOGIN, '', wxDLG_PNT(self.login_dialogue, 10, 45 ),
> wxDLG_SZE(self.login_dialogue, 110, 16), style=wxTE_PASSWORD |
> wxTE_PROCESS_ENTER )
>
>
> # ON ENTER KEY EVENT CALL LOGIN METHOD
> EVT_TEXT_ENTER(self.password_login_box, ID_OK_LOGIN,
> self.OnOKLogin)
>
> self.login_dialogue.ShowModal()
>
>

-------------------------------------------------
This mail sent through IMP: http://www.cdc.unict.it/

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users