[wxPython] Newbie text ctrl question

Normally, a text control only highlights its selection when it has the input
focus. If the user has clicked a button, the text control no longer has the
input focus, so the selection range isn't highlighted.

You can set the wxTE_NOHIDESEL window style if you want the selection to be
displayed all the time.

···

On Thu, 24 Oct 2002 12:10:02 -0700, "Bill Witherspoon" <bwitherspoon@emseal.com> wrote:

Trying to select (highlight) the text in a wxTextCtrl after user clicks
a button.

I tried:
               self.txtOrderNum.SetSelection(-1, -1)
and
               self.txtOrderNum.SetSelection(0,
len(self.txtOrderNum.GetValue()))

Both have no effect. I can SetValue with no problems.
Should be easy right? What am I missing?

--
- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.

Thanks for the reply.
What I'm trying to do is take some input from a text field (when
the user clicks the appropriate button), do something with that
data, and then upon the function returning, highlight the data that
was entered. ie. Give the text control the focus, so that the user
simply has to type (in my case) another order number. They don't
have to actually tab to the text field, or click on it again.

Any ideas? In VB, I would just set the focus to that text control.
Then do some type of selstart, sellength combo to select the text
that's already there.

Thanks,
Bill

···

----- Original Message -----
From: "Tim Roberts" <timr@probo.com>
To: <wxpython-users@lists.wxwindows.org>
Sent: Thursday, October 24, 2002 3:40 PM
Subject: Re: [wxPython] Newbie text ctrl question

On Thu, 24 Oct 2002 12:10:02 -0700, "Bill Witherspoon" > <bwitherspoon@emseal.com> wrote:
>
>Trying to select (highlight) the text in a wxTextCtrl after user clicks
>a button.
>
>I tried:
> self.txtOrderNum.SetSelection(-1, -1)
>and
> self.txtOrderNum.SetSelection(0,
>len(self.txtOrderNum.GetValue()))
>
>Both have no effect. I can SetValue with no problems.
>Should be easy right? What am I missing?

Normally, a text control only highlights its selection when it has the

input

focus. If the user has clicked a button, the text control no longer has

the

input focus, so the selection range isn't highlighted.

You can set the wxTE_NOHIDESEL window style if you want the selection to

be

displayed all the time.

--
- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.

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

Bill Witherspoon wrote:

Thanks for the reply.
What I'm trying to do is take some input from a text field (when
the user clicks the appropriate button), do something with that
data, and then upon the function returning, highlight the data that
was entered. ie. Give the text control the focus, so that the user
simply has to type (in my case) another order number. They don't
have to actually tab to the text field, or click on it again.

Any ideas? In VB, I would just set the focus to that text control.
Then do some type of selstart, sellength combo to select the text
that's already there.

So do the same thing in Python, using the SetFocus() method before you try to
set the selection.

Jeff Shannon
Technician/Programmer
Credit International

Now that you've said it exists, I looked harder, and realized its an
inherited method from wxWindow. (Naturally, when I didn't see
under the wxTextControl members I assumed it didn't exist).

Sheesh, if it wasn't for mailing lists, I'd have nowhere to make
myself look dumb. :wink:

Thanks for the help.
Bill.

···

----- Original Message -----
From: "Jeff Shannon" <jeff@ccvcorp.com>
To: <wxpython-users@lists.wxwindows.org>
Sent: Thursday, October 24, 2002 4:22 PM
Subject: Re: [wxPython] Newbie text ctrl question

Bill Witherspoon wrote:

> Thanks for the reply.
> What I'm trying to do is take some input from a text field (when
> the user clicks the appropriate button), do something with that
> data, and then upon the function returning, highlight the data that
> was entered. ie. Give the text control the focus, so that the user
> simply has to type (in my case) another order number. They don't
> have to actually tab to the text field, or click on it again.
>
> Any ideas? In VB, I would just set the focus to that text control.
> Then do some type of selstart, sellength combo to select the text
> that's already there.

So do the same thing in Python, using the SetFocus() method before you try

to

set the selection.

Jeff Shannon
Technician/Programmer
Credit International

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