Add Items to a UltimateListCtrl

Hello

I am using a UltimateListCtrl object for the first time & I am trying
to figure out how to add a row to it?

I have a ULC that has 5 columns & I want to add a row that contains 4
wx.StaticText objects & 1 wx.RadioBox object.

From what I know you dont add rows, but you add items(correct?), so if
I want to add all the 5 items/objects mentioned above I need to do
this:

def add_row():

    row_items = ( wx.UltimateListItem( wx.StaticText( parent =
list_ctrl, ... ) ),
                          wx.UltimateListItem( wx.StaticText( ... ) ),
                          wx.UltimateListItem( wx.StaticText( ... ) ),
                          wx.UltimateListItem( wx.StaticText( ... ) ),
                          wx.UltimateListItem( wx.RadioBox( ... ) ) )

    column_index = 0

    for item in row_items:

        list_ctrl.CreateListItem( item, column_index )
        column_index += 1

But I get an error when I create the 1st element in row_items. It
says...

" File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw
\ultimatelistctrl.py", line 1285, in __init__
    self._mask = item._mask # Indicates what fields are
valid
AttributeError: 'StaticText' object has no attribute '_mask' "

So how do I add items( or a row) to a UltimateListCtrl?

Did you look at the sample in the demo?

···

On 10/4/10 1:31 AM, Sascha wrote:

Hello

I am using a UltimateListCtrl object for the first time& I am trying
to figure out how to add a row to it?

I have a ULC that has 5 columns& I want to add a row that contains 4
wx.StaticText objects& 1 wx.RadioBox object.

From what I know you dont add rows, but you add items(correct?), so if
I want to add all the 5 items/objects mentioned above I need to do
this:

def add_row():

     row_items = ( wx.UltimateListItem( wx.StaticText( parent =
list_ctrl, ... ) ),
                           wx.UltimateListItem( wx.StaticText( ... ) ),
                           wx.UltimateListItem( wx.RadioBox( ... ) ) )

     column_index = 0

     for item in row_items:

         list_ctrl.CreateListItem( item, column_index )
         column_index += 1

But I get an error when I create the 1st element in row_items. It
says...

" File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw
\ultimatelistctrl.py", line 1285, in __init__
     self._mask = item._mask # Indicates what fields are
valid
AttributeError: 'StaticText' object has no attribute '_mask' "

So how do I add items( or a row) to a UltimateListCtrl?

--
Robin Dunn
Software Craftsman

hi, what you are looking for is Append, It takes a string, and adds a
row (or item) with the string in the first column, then you use code
like this to add widgets to the ULC
#here is where you pick which item to add the widget to
#I use a variable that holds the number of items(or "length") in the
ULC
#that way I can pick the last one in the list, the last number here is
the column here, I'm adding a widget to the second (number 1)
column
timer=self.GetItem(self.length, 1)
#any widget can be placed in an ULC, not just a TextCtrl
textctrl = wx.TextCtrl(self, -1, "00:00:00")
timer.SetWindow(textctrl)
self.SetItem(timer)

I hope this helps!