wx.TE_MULTILINE|wx.TE_BESTWRAP don't

The wx.Choice() widget has 27 choices, some of which are _very_ long. When
a long choice is selected only the characters that fit in the window's width
are displayed, in the middle row of what appears to be a 5-row window
height. I would appreciate learning what the correct style specification (or
list formatting) should be. Here's the entire widget:

         nodataList = [
             'Value reported is the mean of two or more determinations.',
             'Results based upon colony counts outside the acceptable
range.',
             'Calculated. Value stored was not measured directly, but was
calculated from other data available.',
             'Field measurement. Measurement activities conducted in the
field are reported separately from results obtained from samples.',
             'Extra sample taken in compositing process.',
             'In the case of species, F indicates Female sex.',
             'Value reported is the maximum of two or more determinations.',
             'Value based on field kit determination; results may not be
             accurate.',
             'The value reported is less than the practical quantitation
             limit and greater than or equal to the method detection limit.',
             'Estimated. Value shown is not a result of analytical
             measurement.',
             'Off-scale low. Actual value not known, but known to be less
             than value shown. Not detected.',
             'Off-scale high. Actual value not known, but known to be greater
             than value shown. Above detection limit.',
             'Presence of material verified, but not quantified. Indicates a
             positive detection, at a level too low to permit accurate
             quantification. In the case of temperature or oxygen reduction
             potential, M indicates a negative value. In the case of species,
             M indicates Male sex.',
             'Presumptive evidence of presence of material.',
             'Sampled for, but analysis lost. Accompanying value is not
             meaningful for analysis.',
             'Too numerous to count.',
             'Sample held beyond normal holding time.',
             'Significant rain in the past 48 hours. (Several characteristics
             identify meteorological conditions at or near the time of
             sampling)',
             'Laboratory test.',
             'Value reported is less than the criteria of detection.',
             'Material was analyzed for, but not detected. Value stored is
             the limit of detection for the process in use. In the case of
             species, Undetermined sex.',
             'Indicates the analyte was detected in both the sample and
             associated method blank.',
             'Value observed is less than the lowest value reportable under
             remark above.',
             'Value is quasi vertically-integrated sample.',
             'Laboratory analysis from unpreserved sample. Data may not be
             accurate.',
             'Too many colonies were present to count (TNTC), the numeric
             value represents the filtration volume.',
             'Calculated by retrieval software. Numerical value was neither
             measured nor reported to the database, but was calculated from
             other data available during generation of the retrieval
             report.']
         lab = wx.StaticText(self, -1, "Missing data: ")
         self.nodata = wx.Choice(self, -1, size=(500, 100),
         style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.RAISED_BORDER|wx.TE_MULTILINE|wx.TE_BESTWRAP, choices = nodataList)
         self.Bind(wx.EVT_CHOICE, self.OnMissing, self.nodata)

Rich

You might be able to try ComboBox with CB_READONLY and then try to use this method on it:
http://wxpython.org/Phoenix/docs/html/ComboCtrl.html#ComboCtrl.SetCustomPaintWidth

I use CB_READONLY ComboBoxes for drop-down selection… I hadn’t heard of wx.Choice before now.

···

On Thursday, July 24, 2014 2:44:44 PM UTC-7, fuzzydoc wrote:

The wx.Choice() widget has 27 choices, some of which are very long. When

a long choice is selected only the characters that fit in the window’s width

are displayed, in the middle row of what appears to be a 5-row window

height. I would appreciate learning what the correct style specification (or

list formatting) should be. Here’s the entire widget:

     nodataList = [

         'Value reported is the mean of two or more determinations.',

         'Results based upon colony counts outside the acceptable

range.',

         'Calculated. Value stored was not measured directly, but was

calculated from other data available.',

         'Field measurement. Measurement activities conducted in the

field are reported separately from results obtained from samples.',

         'Extra sample taken in compositing process.',

         'In the case of species, F indicates Female sex.',

         'Value reported is the maximum of two or more determinations.',

         'Value based on field kit determination; results may not be

         accurate.',

         'The value reported is less than the practical quantitation

         limit and greater than or equal to the method detection limit.',

         'Estimated. Value shown is not a result of analytical

         measurement.',

         'Off-scale low. Actual value not known, but known to be less

         than value shown. Not detected.',

         'Off-scale high. Actual value not known, but known to be greater

         than value shown. Above detection limit.',

         'Presence of material verified, but not quantified. Indicates a

         positive detection, at a level too low to permit accurate

         quantification. In the case of temperature or oxygen reduction

         potential, M indicates a negative value. In the case of species,

         M indicates Male sex.',

         'Presumptive evidence of presence of material.',

         'Sampled for, but analysis lost. Accompanying value is not

         meaningful for analysis.',

         'Too numerous to count.',

         'Sample held beyond normal holding time.',

         'Significant rain in the past 48 hours. (Several characteristics

         identify meteorological conditions at or near the time of

         sampling)',

         'Laboratory test.',

         'Value reported is less than the criteria of detection.',

         'Material was analyzed for, but not detected. Value stored is

         the limit of detection for the process in use. In the case of

         species, Undetermined sex.',

         'Indicates the analyte was detected in both the sample and

         associated method blank.',

         'Value observed is less than the lowest value reportable under

         remark above.',

         'Value is quasi vertically-integrated sample.',

         'Laboratory analysis from unpreserved sample. Data may not be

         accurate.',

         'Too many colonies were present to count (TNTC), the numeric

         value represents the filtration volume.',

         'Calculated by retrieval software. Numerical value was neither

         measured nor reported to the database, but was calculated from

         other data available during generation of the retrieval

         report.']

     lab = wx.StaticText(self, -1, "Missing data: ")

     self.nodata = wx.Choice(self, -1, size=(500, 100),

     style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.RAISED_BORDER|wx.TE_MULTILINE|wx.TE_BESTWRAP, choices = nodataList)

     self.Bind(wx.EVT_CHOICE, self.OnMissing, self.nodata)

Rich

Nathan,

   I'll give that a try. For no particular reason I use wx.Choice quite a bit
in this application, only a few wx.ComboBox widgets.

Thanks,

Rich

···

On Thu, 24 Jul 2014, Nathan McCorkle wrote:

You might be able to try ComboBox with CB_READONLY and then try to use this
method on it:
http://wxpython.org/Phoenix/docs/html/ComboCtrl.html#ComboCtrl.SetCustomPaintWidth

I use CB_READONLY ComboBoxes for drop-down selection... I hadn't heard of
wx.Choice before now.

Nathan,

   CB_READONLY == CB_DROPDOWN. Anyway, in wxPython-3.0.0.0 there is no
SetCustomPaintWidth attribute.

   And regardless of the widget being a wx.Choice or wx.ComboBox, the long
selections are on a single line. One can scroll horizontally along the line
but it does not wrap so the entire sentence is visible at once. Sigh.

Thanks for the suggestion,

Rich

···

On Thu, 24 Jul 2014, Nathan McCorkle wrote:

You might be able to try ComboBox with CB_READONLY and then try to use this
method on it:
http://wxpython.org/Phoenix/docs/html/ComboCtrl.html#ComboCtrl.SetCustomPaintWidth

I am open to suggestions on how to present this list of 27 mostly long
sentences to users. It is a standardized list originally from the US EPA and
has a single character code (A-Z + $) associated with each sentence; that
makes for smaller rows in the database table.

   Ideally, the user should see a 2-column dropdown table (the single
charater abbreviation and the description, a Python dictionary). After
scrolling the list for the appropriate reason for missing data, the user
selects that row and when the 'Save' button is pressed that single character
is stored in the database table.

   I thought that a multiline, wrapped display was possible with a wx.Choice
or wx.ComboBox in 'classic' wxPython, but neither honors those styles. Those
of you who have spent more time writing wxPython UIs than I have might have
valuable ideas for me on how best to present users with the choices.

TIA,

Rich

···

On Thu, 24 Jul 2014, Rich Shepard wrote:

And regardless of the widget being a wx.Choice or wx.ComboBox, the long
selections are on a single line. One can scroll horizontally along the
line but it does not wrap so the entire sentence is visible at once. Sigh.

It looks like HtmlListBox will wrap, but it might require \n

I bet it wouldn’t be too much work to figure out where to insert \n using something like dc.GetMultiLineTextExtent(somestring)

http://www.wxpython.org/docs/api/wx.DC-class.html#GetMultiLineTextExtent

Something like, call dc.GetMultiLineTextExtent(somestring) and compare the width it returns to the width of the HtmlListBox widget, convert those numbers to a ratio, get the length of the string and multiply it with the ratio to get a string index approximately where a \n needs to be inserted… then find the nearest (lower index) with whitespace or comma/period and insert the \n there. Then split the string on \n and apply the same logic to the last token (in case you need a second \n, to make the long string into three lines)

···

On Thursday, July 24, 2014 3:56:57 PM UTC-7, fuzzydoc wrote:

On Thu, 24 Jul 2014, Rich Shepard wrote:

And regardless of the widget being a wx.Choice or wx.ComboBox, the long

selections are on a single line. One can scroll horizontally along the

line but it does not wrap so the entire sentence is visible at once. Sigh.

I am open to suggestions on how to present this list of 27 mostly long

sentences to users. It is a standardized list originally from the US EPA and

has a single character code (A-Z + $) associated with each sentence; that

makes for smaller rows in the database table.

Ideally, the user should see a 2-column dropdown table (the single

charater abbreviation and the description, a Python dictionary). After

scrolling the list for the appropriate reason for missing data, the user

selects that row and when the ‘Save’ button is pressed that single character

is stored in the database table.

I thought that a multiline, wrapped display was possible with a wx.Choice

or wx.ComboBox in ‘classic’ wxPython, but neither honors those styles. Those

of you who have spent more time writing wxPython UIs than I have might have

valuable ideas for me on how best to present users with the choices.

TIA,

Rich

D’oh, I forgot you wanted a drop-down… I guess you’ll have to look at replacing the VListBox with HtmlListBox in OwnerDrawnComboBox

···

On Thursday, July 24, 2014 5:14:06 PM UTC-7, Nathan McCorkle wrote:

It looks like HtmlListBox will wrap, but it might require \n

I bet it wouldn’t be too much work to figure out where to insert \n using something like dc.GetMultiLineTextExtent(somestring)

http://www.wxpython.org/docs/api/wx.DC-class.html#GetMultiLineTextExtent

Something like, call dc.GetMultiLineTextExtent(somestring) and compare the width it returns to the width of the HtmlListBox widget, convert those numbers to a ratio, get the length of the string and multiply it with the ratio to get a string index approximately where a \n needs to be inserted… then find the nearest (lower index) with whitespace or comma/period and insert the \n there. Then split the string on \n and apply the same logic to the last token (in case you need a second \n, to make the long string into three lines)

On Thursday, July 24, 2014 3:56:57 PM UTC-7, fuzzydoc wrote:

On Thu, 24 Jul 2014, Rich Shepard wrote:

And regardless of the widget being a wx.Choice or wx.ComboBox, the long

selections are on a single line. One can scroll horizontally along the

line but it does not wrap so the entire sentence is visible at once. Sigh.

I am open to suggestions on how to present this list of 27 mostly long

sentences to users. It is a standardized list originally from the US EPA and

has a single character code (A-Z + $) associated with each sentence; that

makes for smaller rows in the database table.

Ideally, the user should see a 2-column dropdown table (the single

charater abbreviation and the description, a Python dictionary). After

scrolling the list for the appropriate reason for missing data, the user

selects that row and when the ‘Save’ button is pressed that single character

is stored in the database table.

I thought that a multiline, wrapped display was possible with a wx.Choice

or wx.ComboBox in ‘classic’ wxPython, but neither honors those styles. Those

of you who have spent more time writing wxPython UIs than I have might have

valuable ideas for me on how best to present users with the choices.

TIA,

Rich

Looks like there is some useful code in the ComboCtrl.py demo… it subclasses ListCtrl… so presumably you could swap HtmlListBox for that… but it doesn’t seem trivial (I’ve been playing with it for 20 minutes or so and am getting weird errors.

Setting Custom Popup for ComboCtrl

http://wxpython.org/Phoenix/docs/html/ComboCtrl.html#comboctrl

http://wxpython.org/Phoenix/docs/html/ComboPopup.html

···

On Thursday, July 24, 2014 5:27:02 PM UTC-7, Nathan McCorkle wrote:

D’oh, I forgot you wanted a drop-down… I guess you’ll have to look at replacing the VListBox with HtmlListBox in OwnerDrawnComboBox

What I originally thought to do was to keep that list in a database table
and have a widget that would display it (perhaps a listctrl) upon demand.
The user could refer to the list and enter the appropriate one-character
code in the textctrl. The table would likely take up less room in the
database than hard-coded in the class.

   Reading the docs for wx.ListCtrl did not clarify whether a user could
select a row from that which would be assigned to the value of the
appropriate variable. Could something of this nature be easier to
manipulate?

   I also have a table with state/province abbreviations and names which
would be used in several tabs. The same solution could be used for both.

Thanks,

Rich

···

On Thu, 24 Jul 2014, Nathan McCorkle wrote:

D'oh, I forgot you wanted a drop-down... I guess you'll have to look at
replacing the VListBox with HtmlListBox in OwnerDrawnComboBox

I looked at the 3.0.0.0 demo for ComboBox several times, but did not
closely study it. I'll look more closely, but a ListCtrl presents the entire
list at one time and that takes up a lot of room on the panel.

Thanks again,

Rich

···

On Thu, 24 Jul 2014, Nathan McCorkle wrote:

Looks like there is some useful code in the ComboCtrl.py demo.

I believe the point of ComboCtrl is that it displays the scroll bars too. Maybe I’m wrong, but I believe so, since it’s a pop-up list.

···

On Thursday, July 24, 2014 6:14:39 PM UTC-7, fuzzydoc wrote:

On Thu, 24 Jul 2014, Nathan McCorkle wrote:

Looks like there is some useful code in the ComboCtrl.py demo.

I looked at the 3.0.0.0 demo for ComboBox several times, but did not

closely study it. I’ll look more closely, but a ListCtrl presents the entire

list at one time and that takes up a lot of room on the panel.

Thanks again,

Rich

Nathan,

   I did not see a ComboCtrl in 3.0.0.0 but I'll look again. Based on what
you've seen it will almost certainly do the job.

Thanks,

Rich

···

On Fri, 25 Jul 2014, Nathan McCorkle wrote:

I believe the point of ComboCtrl is that it displays the scroll bars too.
Maybe I'm wrong, but I believe so, since it's a pop-up list.

It’s in the demos:

···

On Friday, July 25, 2014 5:53:03 AM UTC-7, fuzzydoc wrote:

On Fri, 25 Jul 2014, Nathan McCorkle wrote:

I believe the point of ComboCtrl is that it displays the scroll bars too.

Maybe I’m wrong, but I believe so, since it’s a pop-up list.

Nathan,

I did not see a ComboCtrl in 3.0.0.0 but I’ll look again. Based on what

you’ve seen it will almost certainly do the job.

Thanks,

Rich

Nathan,

   Today I found something that will be extremely useful for my application
and may also be of value to you: the ObjectListView
<http://objectlistview.sourceforge.net/&gt;\. It's a wrapper around wx.ListCtrl
that automates much of the effort of creating a list control/view.

   I found this when my search for learning about MVC (might as well make
this new project better organized than the previous ones) found a hit to
Mike's Mouse and Python blog on integrating SQLAlchemy with wxPython. The
ObjectListView is the display/add/edit/delete widget for his example
application and will certainly work for my multi-table application.

   Just reading the docs now and I expect to learn how to make it read-only
so it can serve as a lookup table.

Regards,

Rich

···

On Thu, 24 Jul 2014, Nathan McCorkle wrote:

You might be able to try ComboBox with CB_READONLY and then try to use this
method on it:
http://wxpython.org/Phoenix/docs/html/ComboCtrl.html#ComboCtrl.SetCustomPaintWidth

I use CB_READONLY ComboBoxes for drop-down selection... I hadn't heard of
wx.Choice before now.

Rich,
The wxPython equivalent of Object List View, (which is a C++ class),
is Data View Controls, (DVC), which you will find in the demo if you
are running a reasonably recent version of wxPython, (>2.9.0).
The Phoenix docs are .
Hope that is a help
Screen shot from the demo:
Screen Shot of change to demo code to make Artist read only:
Gadget/Steve

···

On 27/07/14 00:51, Rich Shepard wrote:

  On Thu, 24 Jul 2014, Nathan McCorkle wrote:
    You might be able to try ComboBox with

CB_READONLY and then try to use this

    method on it:





    I use CB_READONLY ComboBoxes for drop-down selection... I hadn't

heard of
wx.Choice before now.

  Nathan,




    Today I found something that will be extremely useful for my

application

  and may also be of value to you: the ObjectListView


  . It's a wrapper

around wx.ListCtrl
that automates much of the effort of creating a list control/view.
I found this when my search for learning about MVC (might as
well make
this new project better organized than the previous ones) found a
hit to
Mike’s Mouse and Python blog on integrating SQLAlchemy with
wxPython. The
ObjectListView is the display/add/edit/delete widget for his
example
application and will certainly work for my multi-table
application.
Just reading the docs now and I expect to learn how to make it
read-only
so it can serve as a lookup table.
Regards,
Rich

here

http://wxpython.org/Phoenix/docs/html/ComboCtrl.html#ComboCtrl.SetCustomPaintWidth

http://objectlistview.sourceforge.net/

Hi Rich,

You might be able to try ComboBox with CB_READONLY and then try to use this
method on it:
http://wxpython.org/Phoenix/docs/html/ComboCtrl.html#ComboCtrl.SetCustomPaintWidth

I use CB_READONLY ComboBoxes for drop-down selection... I hadn't heard of
wx.Choice before now.

Nathan,

  Today I found something that will be extremely useful for my application
and may also be of value to you: the ObjectListView
<http://objectlistview.sourceforge.net/&gt;\. It's a wrapper around wx.ListCtrl
that automates much of the effort of creating a list control/view.

  I found this when my search for learning about MVC (might as well make
this new project better organized than the previous ones) found a hit to
Mike's Mouse and Python blog on integrating SQLAlchemy with wxPython. The
ObjectListView is the display/add/edit/delete widget for his example
application and will certainly work for my multi-table application.

  Just reading the docs now and I expect to learn how to make it read-only
so it can serve as a lookup table.

Yeap, that is what I use as it allows to show more then a normal ComboBox.

Some years ago Mike and I used it in the sample application we did showing SQLAlchemy and wxPython use - MediaLocker.

https://bitbucket.org/driscollis/medialocker/overview

The dropdown to select an Author in the following is the medialocker.libui.searchctrl which uses an ObjectListView. The columns are stored in the table 'olvlist' which means the user can reorder and resize the columns and save the new layout by using the context menu.

The above repo also includes a version of the OLV which is compatible with wxPython 2.9.5+ and there is a branch which is Phoenix/Py3 compatible.

Werner

P.S.
MediaLocker could use some tender care, but no time at this point.

···

On 7/27/2014 1:51, Rich Shepard wrote:

On Thu, 24 Jul 2014, Nathan McCorkle wrote:

Gadget/Steve,

   Yes, that does help. I'm running wxPython-3.0.0.0 and I'll look for that
demo and code.

   From what I've read in the OLV docs it seems to be useful, in read-only
mode, as a lookup table. The user would display it with a button click,
scroll to find the appropriate row, enter the abbreviation in a wx.TextCtrl,
then close the lookup window.

   A second use would be as a replacement for the individual data entry
widgets on each panel's notebook tab as this would allow the user to see
already-entered data, too.

   The third use would be as a view of all entries in a database table.

   It is going to take me time and much thought to figure out how to control
what users can do based on their roles, but a single widget applied to each
table should eventually make life easier for me and for the users.

Thanks for pointing me to the wxPython version,

Rich

···

On Sun, 27 Jul 2014, Steve Barnes wrote:

The wxPython equivalent of Object List View, (which is a C++ class), is
Data View Controls, (DVC), which you will find in the demo if you are
running a reasonably recent version of wxPython, (>2.9.0). The Phoenix
docs are here
<http://wxpython.org/Phoenix/docs/html/dataview.DataViewCtrl.html#dataview-dataviewctrl&gt;\.

Hope that is a help

I was under the impression you wanted a drop-down box. Are you changing direction?

···

On Sunday, July 27, 2014 6:14:10 AM UTC-7, fuzzydoc wrote:

On Sun, 27 Jul 2014, Steve Barnes wrote:

The wxPython equivalent of Object List View, (which is a C++ class), is

Data View Controls, (DVC), which you will find in the demo if you are

running a reasonably recent version of wxPython, (>2.9.0). The Phoenix

docs are here

<http://wxpython.org/Phoenix/docs/html/dataview.DataViewCtrl.html#dataview-dataviewctrl>.

Hope that is a help

Gadget/Steve,

Yes, that does help. I’m running wxPython-3.0.0.0 and I’ll look for that

demo and code.

From what I’ve read in the OLV docs it seems to be useful, in read-only

mode, as a lookup table. The user would display it with a button click,

scroll to find the appropriate row, enter the abbreviation in a wx.TextCtrl,

then close the lookup window.

A second use would be as a replacement for the individual data entry

widgets on each panel’s notebook tab as this would allow the user to see

already-entered data, too.

The third use would be as a view of all entries in a database table.

It is going to take me time and much thought to figure out how to control

what users can do based on their roles, but a single widget applied to each

table should eventually make life easier for me and for the users.

Thanks for pointing me to the wxPython version,

Rich

Nathan,

   Yes. My design was based on previous wxPython applicatoins which used
SQLite as the backend. This new application has to be multiuser so
PostgreSQL will be the back end and SQLAlchemy will be the interface. The
SQLAlchemy/wxPython information I've read uses OLV as the main widget.

   Thinking about this from both the user's perspective and mine (as the
application developer) a flavor of list control makes sense. The one widget
can be used to add new rows, edit and remove existing ones, and display a
scrolling list of all rows in that database table. The way I had been
writing it would display the contents of only 1 row at a time and I'd need a
separate class to display all rows in a table.

   If I'm not correct in these assumptions then please offer suggestions. I
will not pretend to know the best way to organize, present, and write this
tool.

Thanks,

Rich

···

On Sun, 27 Jul 2014, Nathan McCorkle wrote:

I was under the impression you wanted a drop-down box. Are you changing
direction?

So I ended up wanting this functionality myself (wrapping long text in a drop-down list)… so I coded it using a VListBox (which respects \n) and the ComboCtrl using the SetPopupControl method. Attached is a sample (which could use some cleaning up, removing of debug lines, maybe I didn’t remove unused methods, etc).

Let me know if this works for you or anyone else!

I tried using the HtmlListBox, but it didn’t implement the tags or zero-width-space unicode character… so setting the width on an element essentially had no word-wrap/word-break effect.

tcc3.py (8.4 KB)