User Adding Text in Multiline wx.TextCtrl

There are several places in my application where the user needs to enter a
list of strings (names of things, actually). Looking at the available
widgets, I've concluded that the wx.TextCtrl is the appropriate one to use,
with the wx.TE_MULTILINE and wx.HSCROLL styles.

   My question is how the user enters a new name to the list once the first
one has been entered and is displayed in the widget. My reading suggests that
the widget's window will expand vertically as needed, and a vertical scroll
bar will be added as appropriate, but what does the user do to add a second,
or third, or fourth name to the list?

Thanks,

Rich

···

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

wx.TextCtrl doesn't expand vertically unless you resize the widget. It
will offer scrollbars if you overflow the widget's space.

The wx.TextCtrl is the same text control you have seen in hundreds, if
not thousands of applications already. It does not natively support
'entering a list of names', though you can certainly type in a name, hit
enter, and type in another name. "selecting" a name from that "list"
will be a bit awkward.

If you want a list, and you want it to be editable, you have a few
options:
1. Use a wx.TextCtrl for adding names, with a wx.ListBox for selecting
added names.
2. Use a wx.ListCtrl with a single column and editable labels along with
an 'add item' button.
3. Use a wx.TreeCtrl with hidden root, editable labels, and an 'add item'
button.
4. Use a wx.Grid with a single column, etc.
5. Hack up the mouse-click handling on the text control to create an
editable wx.ListCtrl work-alike, though you'll probably only ever get it
to select one item at a time, unless you also change background colors
yourself.

Numbers 1-3 seem reasonable, 4 and 5 may be a bit of an overkill, though
5 may be exactly what you want. *shrug*

- Josiah

···

Rich Shepard <rshepard@appl-ecosys.com> wrote:

   There are several places in my application where the user needs to enter a
list of strings (names of things, actually). Looking at the available
widgets, I've concluded that the wx.TextCtrl is the appropriate one to use,
with the wx.TE_MULTILINE and wx.HSCROLL styles.

   My question is how the user enters a new name to the list once the first
one has been entered and is displayed in the widget. My reading suggests that
the widget's window will expand vertically as needed, and a vertical scroll
bar will be added as appropriate, but what does the user do to add a second,
or third, or fourth name to the list?

Josiah,

   This is probably what I want. I may use a pop-up dialog box to add the
label, then display them in a ListCtrl or ListBox.

Thanks,

Rich

···

On Sun, 4 Dec 2005, Josiah Carlson wrote:

The wx.TextCtrl is the same text control you have seen in hundreds, if not
thousands of applications already. It does not natively support 'entering a
list of names', though you can certainly type in a name, hit enter, and
type in another name. "selecting" a name from that "list" will be a bit
awkward.

2. Use a wx.ListCtrl with a single column and editable labels along with
an 'add item' button.

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Rich Shepard wrote:

  This is probably what I want. I may use a pop-up dialog box to add the
label, then display them in a ListCtrl or ListBox.

Have you looked at wx.ComboBox, which is a combination of a text entry control and a drop-down list?

···

--
Paul McNett
http://paulmcnett.com
http://dabodev.com

Paul,

   In other places, yes. Here, not yet.

Thanks very much,

Rich

···

On Sun, 4 Dec 2005, Paul McNett wrote:

Have you looked at wx.ComboBox, which is a combination of a text entry
control and a drop-down list?

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Paul,

   Yes, the wx.ComboBox will work just fine.

   I've added a button to allow the user to add text to the combo box, but I'm
having difficulty placing it properly on the panel.

   There are three widgets (with static text labels) within a
wx.StaticTextBox. The three fit nicely in there. What I want to do now is to
add the button in the center -- horizontally -- and below the existing
widgets in the StaticBoxSizer that holds the existing widgets. Actually, I'd
like it centered below the "Names: " comboBoc. My efforts put the button at
the right end of the row, rather than below it.

   What's the technique for having multiple rows in a static box sizer?

TIA,

Rich

example.py (2.06 KB)

···

On Sun, 4 Dec 2005, Paul McNett wrote:

Have you looked at wx.ComboBox, which is a combination of a text entry control and a drop-down list?

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Rich Shepard wrote:

  I've added a button to allow the user to add text to the combo box, but I'm
having difficulty placing it properly on the panel.

  There are three widgets (with static text labels) within a
wx.StaticTextBox. The three fit nicely in there. What I want to do now is to
add the button in the center -- horizontally -- and below the existing
widgets in the StaticBoxSizer that holds the existing widgets. Actually, I'd
like it centered below the "Names: " comboBoc. My efforts put the button at
the right end of the row, rather than below it.

  What's the technique for having multiple rows in a static box sizer?

Make the StaticBoxSizer an wx.VERTICAL sizer. Put your multiple rows in there. See enclosed code.

You may also want to use a FlexGridSizer

-Chris

example.py (1.93 KB)

···

--
Christopher Barker, Ph.D.
Oceanographer
                                          
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Chris,

   Thank you. I re-arranged the sizers, made the StaticBoxSizer vertical, and
that fixed the problem.

Rich

···

On Sun, 4 Dec 2005, Christopher Barker wrote:

Make the StaticBoxSizer an wx.VERTICAL sizer. Put your multiple rows in
there. See enclosed code.

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863