List Info

Thread: Issues setting items for a multicolumn listctrl




Issues setting items for a multicolumn listctrl
user name
2007-10-01 13:36:15
Inserting items with:

            if col:
                self.InsertColumnItem(col, item)
            else:
                self.InsertItem(item)

In a loop. The items have Text associated with them, but
once they've
been added, only the first item, added via InsertItem has
Text. The
others have u'' as the Text. I retain a reference to the
actual
ListItem object and I can still call item.Text afterwards
and verify
that it has Text, but the item in the ListCtrl does not.

What's going on here?

Thanks,
-Dan

------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


Re: Issues setting items for a multicolumn listctrl
country flaguser name
United States
2007-10-01 15:01:18
Dan Eloff wrote:
> Inserting items with:
> 
>             if col:
>                 self.InsertColumnItem(col, item)
>             else:
>                 self.InsertItem(item)
> 
> In a loop. The items have Text associated with them,
but once they've
> been added, only the first item, added via InsertItem
has Text. The
> others have u'' as the Text. I retain a reference to
the actual
> ListItem object and I can still call item.Text
afterwards and verify
> that it has Text, but the item in the ListCtrl does
not.
> 
> What's going on here?

You are mixing apples and oranges...  In report mode an item
is the 
whole row so first you insert the item and then you can set
the text for 
the other columns of the same item.  Since the API of
wx.ListCtrl is so 
strange (thank you Microsoft) this fact can easily be
confused or lost. 
   So normally you would use one of the the Insert*Item
methods to add 
the new item and then one of the Set*Item methods to set the
text for 
the other columns of the same item.  Since you are using the
plain Item 
version of the methods then you can save the return value of
InsertItem 
so you know what the ID (the index) of the item is, and then
set the ID 
and col in the wx.ListItem you pass to SetItem for the other
columns.

The InsertColumItem is for inserting a new column for the
whole wx.ListCtrl.



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


------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


RE: Issues setting items for a multicolumn listctrl
country flaguser name
United States
2007-10-01 15:33:56
Hi Dan, 

> -----Original Message-----
> From: Dan Eloff [mailto:dan.eloffgmail.com] 
> Sent: Monday, October 01, 2007 1:36 PM
> To: wxPython-userslists.wxwidgets.org
> Subject: Issues setting items for a multicolumn
listctrl
> 
> Inserting items with:
> 
>             if col:
>                 self.InsertColumnItem(col, item)
>             else:
>                 self.InsertItem(item)
> 
> In a loop. The items have Text associated with them,
but once 
> they've been added, only the first item, added via
InsertItem 
> has Text. The others have u'' as the Text. I retain a 
> reference to the actual ListItem object and I can still
call 
> item.Text afterwards and verify that it has Text, but
the 
> item in the ListCtrl does not.
> 
> What's going on here?
> 
> Thanks,
> -Dan
> 

I use InsertStringItem() to insert an item and
SetStringItem() method to
put text into specific "columns" in the
wx.ListCtrl. The WIA book says
that  InsertItem is used internally by the list control to
manage
information. I don't really understand it all, but I don't
think it's what
you want. It seems to retain previously created items in
memory and that's
why I assume you can query your text. If you have the book,
see page 403.

Mike


------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )