Hi, thanks for the reply, but I'm afraid I'm getting the same result. I was
indeed setting the index into the ItemData. I tried using the FindItemData,
but I'm not sure what parameters to give it and all I get returned is the
index of the item, so I wonder what the data part is good for anyway. I
already know the index. Is there any other code I could look at? I can tell
just by looking at this mess that there has got to be a better way to do this:
def ColumnSorter(self, key1, key2):
item1 = self.ulist.GetItem( self.ulist.FindItemData(key1, key1),
self.currentCol).GetText()
It's very frustrating to do this when I can't find any documentation. =( Is
there anwhere I can read how it really works? The demo uses a dictionary to
hold the real data, while I am operating on the data that's in the list
itself. Is that the problem? Thanks if anyone can help.
···
From: Riaan Booysen <riaan@e.co.za>
Subject: Re: [wxPython] Sorting columns on a wxListCtrl
Mike Miller wrote:
>
> Hi,
>
> Can anyone help me with sorting the columns of my list control? I've tried
> copying the demo source as close as possible, but it still doesn't work right
> for me. The event works and it does change the order, but it comes out
> wrong. I don't truly understand how its supposed to work so can't tell what's
> the problem is. Is there something special I have to load in the SetItemData
> call?
Indeed yes, the values passed to your ColumnSorter method are the
ItemData's of the two wxListItems, NOT the indexes.
Note that you may only store integers with SetItemData.
I suggest you store the original index in the list in ItemData and
use FindItemData to get the items for comparison.
--
Riaan >>> a='a=%s;a%%`a`';a%`a`
___________________________________________________
Boa Constructor - RAD GUI building IDE for wxPython
http://boa-constructor.sourceforge.net
Mike Miller wrote:
Hi, thanks for the reply, but I'm afraid I'm getting the same result. I was
indeed setting the index into the ItemData. I tried using the FindItemData,
but I'm not sure what parameters to give it and all I get returned is the
index of the item, so I wonder what the data part is good for anyway. I
already know the index. Is there any other code I could look at? I can tell
just by looking at this mess that there has got to be a better way to do this:
def ColumnSorter(self, key1, key2):
item1 = self.ulist.GetItem( self.ulist.FindItemData(key1, key1),
^^^^
self.currentCol).GetText()
The first parameter to FindItemData should be the index from
which to search, -1 to search from start.
It's very frustrating to do this when I can't find any documentation. =( Is
wxListCtrl's documentation was good enough to get me going.
···
there anwhere I can read how it really works? The demo uses a dictionary to
hold the real data, while I am operating on the data that's in the list
itself. Is that the problem? Thanks if anyone can help.
--
Riaan >>> a='a=%s;a%%`a`';a%`a`
___________________________________________________
Boa Constructor - RAD GUI building IDE for wxPython
http://boa-constructor.sourceforge.net
Woohoo, it works!! Thank you very much. I've even got it doing the reverse
sort on the second-click. Very cool.
The first parameter to FindItemData should be the index from
which to search, -1 to search from start.
>
> It's very frustrating to do this when I can't find any documentation. =( Is
wxListCtrl's documentation was good enough to get me going.
Doh! I agree the docs are good enough to get simple things working very
quickly. It's just been that last 10% of polish my app needs to make it feel
robust, that has been difficult.
For instance, now I need to figure out how to process the items from multiple
selections on the same ListCtrl. I'd like to run a command on each
selection. I see that the TreeCtrl has something called GetSelections, but
nothing in the ListCtrl looks similar. I've searched the archives, the demo,
and the api listing, but I can't find anything to help.
I realize wxPython is still being finished though, so I look forward to the
future.
-Mike
Mike Miller wrote:
[...]
For instance, now I need to figure out how to process the items from multiple
selections on the same ListCtrl. I'd like to run a command on each
selection. I see that the TreeCtrl has something called GetSelections, but
nothing in the ListCtrl looks similar. I've searched the archives, the demo,
and the api listing, but I can't find anything to help.
Again wxListCtrl's docs tells you how to do this, see the docs for the
SetItem method for a description of this and other state flags.
This little class does what you want.
class MikesListCtrl(wxListCtrl):
def GetSelections(self, state = wxLIST_STATE_SELECTED):
result =
for itemIdx in range(self.GetItemCount()):
if self.GetItemState(itemIdx, 0) & state:
result.append(itemIdx)
return result
···
--
Riaan >>> a='a=%s;a%%`a`';a%`a`
___________________________________________________
Boa Constructor - RAD GUI building IDE for wxPython
http://boa-constructor.sourceforge.net
Hi,
I am experiencing a _very_ strange problem by wxPython.
I installed the latest versions of the relevant libraries.
glib 1.2.7
gtk+ 1.2.7
wxGTK 2.1.15
wxPython 2.1.15
I compiled all the .src.rpm's myself.
The problem is that wxPython is _extremely_ slow. For example, when
calling up a wxFileDialog it takes 10-15 seconds before the dialog appears
on the screen. During that time, the CPU load of the process goes to 90%.
(And yes, the .pyc and .pyo files _are_ present in site-packages/wxPython)
The machine is a Pentium II 400 MHz, 64Mb, Matrox G200.
The same code on a much slower machine (P130) but using older versions of
wx* runs perfectly. On a PIII 500Mhz, 128Mb, G400, using wx* version
2.1.13, the file dialog appears instantaneously as well.
I also tried running the demo.py program on the 400MHz machine. Choosing
wxPythonLibrary/FileBrowseButton _completely_ brought the machine to its
knees, with only an occasional whirr from the diskdrive. I waited for 20
minutes before I gave and flicked the power switch...
I am very puzzled by this problem. I am hoping somebody can give me a clue
how to solve it!!
/Morten
···
--
Morten Kjeldgaard <mok@imsb.au.dk> | Phone : +45 89 42 50 26
Institute of Molecular and Structural Biology | Fax : +45 86 12 31 78
Aarhus University | Home : +45 86 18 81 80
Gustav Wieds Vej 10 C, DK-8000 Aarhus C, Denmark | icq : 27224900