I have a wxListCtrl that is already filled with data.
When I want to use wxColumnSorterMixin, then this method requires
self.itemDataMap as a dictionary filled with all the ListCtrl data ...
What is the most easy way to populate itemDataMap dictionary with the
data
from the wxListCtrl ?
How can I iterate ove a wxListCtrl ?
Are there alternate ways of implementing a column sort method ?
I have a wxListCtrl that is already filled with data.
When I want to use wxColumnSorterMixin, then this method requires
self.itemDataMap as a dictionary filled with all the ListCtrl data ...
What is the most easy way to populate itemDataMap dictionary with the
data
from the wxListCtrl ?
Populate it at the same time that you populate the wxListCtrl
How can I iterate ove a wxListCtrl ?
Are there alternate ways of implementing a column sort method ?
Yes, just do what is in the wxColumnSorterMixin in your own class, and
instead of getting the data from the itemDataMap in the sort compare method
get it however you want. Be warned however that it will be slow if you
fetch the data in the sort compare method directly from the list contorl.
That is why a second copy in itemDataMap is used.
If you don't like the overhead of having a second copy of the data then you
can use the list control in virtual mode and not put any data in the list
control at all. You just have to implement some methods that fetch the data
as needed for display from your own data structures. wxColumnSorterMixin
won't work with it this way, but you can implement sorting just in your data
structures and then call list.Refresh to redisplay the items in sorted
order.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
-----Ursprüngliche Nachricht-----
Von: wxpython-users-admin@lists.wxwindows.org
[mailto:wxpython-users-admin@lists.wxwindows.org] Im Auftrag
von Robin Dunn
Gesendet: Montag, 29. Juli 2002 20:22
An: wxpython-users@lists.wxwindows.org
Betreff: Re: [wxPython] wxColumnSorterMixin, iterate over
wxListCtrl ...
> I have a wxListCtrl that is already filled with data.
> When I want to use wxColumnSorterMixin, then this method requires
> self.itemDataMap as a dictionary filled with all the
ListCtrl data ...
>
> What is the most easy way to populate itemDataMap
dictionary with the
> data
> from the wxListCtrl ?
Populate it at the same time that you populate the wxListCtrl
> How can I iterate ove a wxListCtrl ?
> Are there alternate ways of implementing a column sort method ?
Yes, just do what is in the wxColumnSorterMixin in your own class, and
instead of getting the data from the itemDataMap in the sort
compare method
get it however you want. Be warned however that it will be
slow if you
fetch the data in the sort compare method directly from the
list contorl.
That is why a second copy in itemDataMap is used.
If you don't like the overhead of having a second copy of the
data then you
can use the list control in virtual mode and not put any data
in the list
control at all. You just have to implement some methods that
fetch the data
as needed for display from your own data structures.
wxColumnSorterMixin
won't work with it this way, but you can implement sorting
just in your data
structures and then call list.Refresh to redisplay the items in sorted
order.
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
>
> Thank you very much in advance!
>
> Bye,
> Harald
>
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users@lists.wxwindows.org
> http://lists.wxwindows.org/mailman/listinfo/wxpython-users
>
>
>
OK .. got it! The solution stands in big letters in the demo:
if 0:
# for normal simple columns, you can add them like this:
self.list.InsertColumn(0, "Artist")
self.list.InsertColumn(1, "Title", wxLIST_FORMAT_RIGHT)
self.list.InsertColumn(2, "Genre")
else:
# but since we want images on the column header we have to
do it the hard way:
info = wxListItem()
info.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_IMAGE |
wxLIST_MASK_FORMAT
info.m_image = -1
info.m_format = 0
info.m_text = "Artist"
self.list.InsertColumnInfo(0, info)
> -----Ursprüngliche Nachricht-----
> Von: wxpython-users-admin@lists.wxwindows.org
> [mailto:wxpython-users-admin@lists.wxwindows.org] Im Auftrag
> von Robin Dunn
> Gesendet: Montag, 29. Juli 2002 20:22
> An: wxpython-users@lists.wxwindows.org
> Betreff: Re: [wxPython] wxColumnSorterMixin, iterate over
> wxListCtrl ...
>
>
> > I have a wxListCtrl that is already filled with data.
> > When I want to use wxColumnSorterMixin, then this method requires
> > self.itemDataMap as a dictionary filled with all the
> ListCtrl data ...
> >
> > What is the most easy way to populate itemDataMap
> dictionary with the
> > data
> > from the wxListCtrl ?
>
> Populate it at the same time that you populate the wxListCtrl
>
>
> > How can I iterate ove a wxListCtrl ?
>
>
>
> > Are there alternate ways of implementing a column sort method ?
>
> Yes, just do what is in the wxColumnSorterMixin in your own
class, and
> instead of getting the data from the itemDataMap in the sort
> compare method
> get it however you want. Be warned however that it will be
> slow if you
> fetch the data in the sort compare method directly from the
> list contorl.
> That is why a second copy in itemDataMap is used.
>
> If you don't like the overhead of having a second copy of the
> data then you
> can use the list control in virtual mode and not put any data
> in the list
> control at all. You just have to implement some methods that
> fetch the data
> as needed for display from your own data structures.
> wxColumnSorterMixin
> won't work with it this way, but you can implement sorting
> just in your data
> structures and then call list.Refresh to redisplay the
items in sorted
> order.
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org Java give you jitters? Relax with wxPython!
>
>
>
>
> >
> > Thank you very much in advance!
> >
> > Bye,
> > Harald
> >
> >
> > _______________________________________________
> > wxpython-users mailing list
> > wxpython-users@lists.wxwindows.org
> > http://lists.wxwindows.org/mailman/listinfo/wxpython-users
> >
> >
> >
>
>
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users@lists.wxwindows.org
> http://lists.wxwindows.org/mailman/listinfo/wxpython-users
>