wxListCtrl autowidth doesn't work with virtual list?

Hi list,

With a virtual listcontrol I want the columnwidth to be autoset with the
following statement:

  self.SetColumnWidth(colnr, wxLIST_AUTOSIZE)

with a NON-virtual list this works as expected, with a virtual list, it
doesn't work. The columns get the default size.

I am using wxPython 2.4.2.4 and Python 2.3.3

Cheers,
D. Kniep

Dick Kniep wrote:

Hi list,

With a virtual listcontrol I want the columnwidth to be autoset with the following statement:

  self.SetColumnWidth(colnr, wxLIST_AUTOSIZE)

with a NON-virtual list this works as expected, with a virtual list, it doesn't work. The columns get the default size.

One of the main design points of the virtual ListCtrl is that nothing should take O(n) time to do because not only could there be up to 2**32 (4 billion) items in the list, but depending on your data source all the items may not be available yet. An autosize has to visit and measure every item (taking O(n) time) so it is not allowed for a virtual list.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

I also noticed that InsertItem doesn't work. I think it should be mentioned in
the documentation.

Furthermore, the calculation of the width could be done in the code that
executes the OnGetItemText. Off course this will slow the execution down, but
not that much. I will add code for that in my own application. If it works
OK, I can send it to you.

Cheers,
Dick

···

On Friday 23 April 2004 17:58, Robin Dunn schreef: > Dick Kniep wrote:

> Hi list,
>
> With a virtual listcontrol I want the columnwidth to be autoset with the
> following statement:
>
> self.SetColumnWidth(colnr, wxLIST_AUTOSIZE)
>
> with a NON-virtual list this works as expected, with a virtual list, it
> doesn't work. The columns get the default size.

One of the main design points of the virtual ListCtrl is that nothing
should take O(n) time to do because not only could there be up to 2**32
(4 billion) items in the list, but depending on your data source all the
items may not be available yet. An autosize has to visit and measure
every item (taking O(n) time) so it is not allowed for a virtual list.

Dick Kniep wrote:

Hi list,

With a virtual listcontrol I want the columnwidth to be autoset with the
following statement:

self.SetColumnWidth(colnr, wxLIST_AUTOSIZE)

with a NON-virtual list this works as expected, with a virtual list, it
doesn't work. The columns get the default size.

One of the main design points of the virtual ListCtrl is that nothing
should take O(n) time to do because not only could there be up to 2**32
(4 billion) items in the list, but depending on your data source all the
items may not be available yet. An autosize has to visit and measure
every item (taking O(n) time) so it is not allowed for a virtual list.

I also noticed that InsertItem doesn't work.

What would it do? A virtual ListCtrl does not hold any data so what would it insert the new item into? You hold the data and just provide it to the ListCtrl when it needs it.

I think it should be mentioned in the documentation.

Granted.

Furthermore, the calculation of the width could be done in the code that executes the OnGetItemText. Off course this will slow the execution down, but not that much. I will add code for that in my own application. If it works OK, I can send it to you.

OnGetItemText will only be called when items become visible. Would you readjust the column widths on every page-down? What if the user has adjusted the column widths to something other than the autowidth of the first page?

···

On Friday 23 April 2004 17:58, Robin Dunn schreef: > >>Dick Kniep wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

>>>Hi list,
>>>
>>>With a virtual listcontrol I want the columnwidth to be autoset with the
>>>following statement:
>>>
>>> self.SetColumnWidth(colnr, wxLIST_AUTOSIZE)
>>>
>
> I also noticed that InsertItem doesn't work.

What would it do? A virtual ListCtrl does not hold any data so what
would it insert the new item into? You hold the data and just provide
it to the ListCtrl when it needs it.

Yep I understand.

> I think it should be mentioned in
> the documentation.

Granted.

> Furthermore, the calculation of the width could be done in the code that
> executes the OnGetItemText. Off course this will slow the execution down,
> but not that much. I will add code for that in my own application. If it
> works OK, I can send it to you.

OnGetItemText will only be called when items become visible. Would you
readjust the column widths on every page-down? What if the user has
adjusted the column widths to something other than the autowidth of the
first page?

Yep that's a problem. Currently I do that, and it works OK, the trick is to
make the calculation only the first time the pages are built. So after the
first page is shown, it can be adjusted by the user at will.

Cheers
Dick

···

On Monday 26 April 2004 22:07, Robin Dunn schreef: > Dick Kniep wrote:

> On Friday 23 April 2004 17:58, Robin Dunn schreef: > >>Dick Kniep wrote: