will wx.LIST_AUTOSIZE_USEHEADER resize dynamically?

Hey list,
Just a quick question. I'm told by sighted reviewers that my app looks
pretty good thanks to box sizers, but my list controls have text
that's cut off. Despite making them very wide, the columns are narrow,
and none of the space to the right is used. I just discovered the
style flag wx.LIST_AUTOSIZE_USEHEADER, which seems like the perfect
solution. My question, though, is whether this will cause the list to
dynamically resize itself each time the value of a column changes, or
if it happens at creation time and then must be called manually
somehow thereafter? Initially, for instance, one of my columns has the
word "never" in it, but that changes to display a date and time as
soon as a button is clicked. I'll want that column to expand to fit
the date/time as soon as it appears. What is the behavior of the list
with this flag set, and are there any gotchas I need to know? Thanks.

Hi,
there is a post about dynamically adjusting column width, using a
mixin listctrl in

however, I haven't used this approach myself.
In such cases, I just explicitly resize the column as needed:

my_list_ctrl.SetStringItem(1, 1, "qqweasdasdasdasdasdasdasdasd")
my_list_ctrl.SetColumnWidth(1, wx.LIST_AUTOSIZE)

It seems, you might need wx.LIST_AUTOSIZE to account for the cell
content rather than wx.LIST_AUTOSIZE_USEHEADER which generally only
reflect the header width (or some default value).

regards,
    vbr

···

2016-02-04 14:30 GMT+01:00 Alex Hall <ahall@autodist.com>:

Hey list,
Just a quick question. I'm told by sighted reviewers that my app looks
pretty good thanks to box sizers, but my list controls have text
that's cut off. Despite making them very wide, the columns are narrow,
and none of the space to the right is used. I just discovered the
style flag wx.LIST_AUTOSIZE_USEHEADER, which seems like the perfect
solution. My question, though, is whether this will cause the list to
dynamically resize itself each time the value of a column changes, or
if it happens at creation time and then must be called manually
somehow thereafter? Initially, for instance, one of my columns has the
word "never" in it, but that changes to display a date and time as
soon as a button is clicked. I'll want that column to expand to fit
the date/time as soon as it appears. What is the behavior of the list
with this flag set, and are there any gotchas I need to know? Thanks.

Hey list,
Just a quick question. I’m told by sighted reviewers that my app looks
pretty good thanks to box sizers, but my list controls have text
that’s cut off. Despite making them very wide, the columns are narrow,
and none of the space to the right is used. I just discovered the
style flag wx.LIST_AUTOSIZE_USEHEADER, which seems like the perfect
solution. My question, though, is whether this will cause the list to
dynamically resize itself each time the value of a column changes, or
if it happens at creation time and then must be called manually
somehow thereafter? Initially, for instance, one of my columns has the
word “never” in it, but that changes to display a date and time as
soon as a button is clicked. I’ll want that column to expand to fit
the date/time as soon as it appears. What is the behavior of the list
with this flag set, and are there any gotchas I need to know? Thanks.

Hi,
there is a post about dynamically adjusting column width, using a
mixin listctrl in
http://stackoverflow.com/questions/11314339/make-column-width-take-up-available-space-in-wxpython-listctrl
however, I haven’t used this approach myself.
In such cases, I just explicitly resize the column as needed:

my_list_ctrl.SetStringItem(1, 1, “qqweasdasdasdasdasdasdasdasd”)
my_list_ctrl.SetColumnWidth(1, wx.LIST_AUTOSIZE)

It seems, you might need wx.LIST_AUTOSIZE to account for the cell
content rather than wx.LIST_AUTOSIZE_USEHEADER which generally only
reflect the header width (or some default value).

Indeed. I looked at the docs again, and USEHEADER does just what it says–it uses the header. I assumed that AUTOSIZE_USEHEADER would be smart enough to use the content or header, whichever is larger, but that isn’t the case after all. Plus, while I don’t plan to run this anywhere but Windows for now, I’d hate to have that 80-pixel setting bite me when I don’t expect it should the company ever move to OS X or Linux.

That behavior, of using the larger width to determine the column’s width, is what I’m after. The way this app works, columns will have to re-size themselves with some regularity, so I can’t just hard-code values or assume that the column or value will be larger. That’s why I also asked if an update to a column’s string value would trigger a resize if the AUTOSIZE flag is used, or if I need to tell the column to size itself with every UI update.

···

On Feb 4, 2016, at 17:15, Vlastimil Brom vlastimil.brom@gmail.com wrote:
2016-02-04 14:30 GMT+01:00 Alex Hall ahall@autodist.com:

regards,
vbr


You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Hall

Automatic Distributors, IT Department

942-6769, Ext. 629

ahall@autodist.com

I think the LIST_AUTOSIZE is the way to go but if that doesn’t work out for you I posted a reply to another of your topics here in this group with a pastebin showing manual manuipulation of the listctrl’s column with, say when you resize your window.

But for even more control you would likely need to start using wx.Font GetTextExtent type functions. That could add unwanted overhead. Basically you would find the longest string in the column, pass it to a GetTextExtent-like function that returns the width in pixels of the string. Then set the listctrl’s columnwidth to it.