ultimatelistctrl and wx.LC_VIRTUAL problem

Hi everyone,

I'm trying to use the class ultimatelistctrl (win xp, python 2.6, wx
2.8), but I'm encountering some problems....my aim is to realize an
editable virtual list. So far I've written the following code:

import wx
try:
    from agw import ultimatelistctrl as ULC
except ImportError: # if it's not there locally, try the wxPython lib.
    from wx.lib.agw import ultimatelistctrl as ULC

class AttListCtrl(ULC.UltimateListCtrl) :
    def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=0,
                 agwStyle=0) :
        ULC.UltimateListCtrl.__init__(self, parent, id, pos, size,
style, agwStyle)

        self.InsertColumn(0, "Name")
        self.InsertColumn(1, "Event")
        self.InsertColumn(2, "Source")
        self.SetColumnWidth(0, 120)
        self.SetColumnWidth(1, 500)
        self.SetColumnWidth(2, 150)

        self.SetItemCount(10)

    def OnGetItemText(self, item, col):
        return "Item %d, column %d" % (item, col)

    def ResetView(self) :
        self.SetItemCount(10)
        self.Refresh()

class AttDescWin(wx.Frame) :
    def __init__(self, parent) :
        wx.Frame.__init__(self, parent, -1, size=wx.Size(1050, 750))
        self.att_list_ulc = AttListCtrl(self, -1,
                                        agwStyle=wx.LC_REPORT
                                        > wx.LC_VIRTUAL
                                        #| wx.BORDER_SUNKEN
                                        #| wx.BORDER_NONE
                                        > wx.ULC_EDIT_LABELS
                                        #| wx.LC_SORT_ASCENDING
                                        #| wx.LC_NO_HEADER
                                        #| wx.LC_VRULES
                                        #| wx.LC_HRULES
                                        #| wx.LC_SINGLE_SEL
                                        #|
ULC.ULC_HAS_VARIABLE_ROW_HEIGHT
                                        )

class MyApp(wx.App) :
    def OnInit(self) :
        frame = AttDescWin(None)
        frame.Show(True)
        self.SetTopWindow(frame)
        return True

app = MyApp(0)
app.MainLoop()

The list is correctly created, but the items are not editable in spite
of the flag wx.ULC_EDIT_LABELS. Am I doing something wrong or are
virtual list not intended to be editable? Thanks in advance for your
help!

Hi, with the virtual ULC, all of the Items contents are determined by the different methods that you set up for the text.

def OnGetItemText(self, item, col):

return “Item %d, column %d” % (item, col)

puts the same text in every item. there are more advanced stuff that you can do, but really, the virtual ULC is not for interactive use. I tried to do that once, and I ended up just using a regular ULC.

Virtual ULCs are useful for really long lists, but unless you are going to have like, 1000 items, you really don’t need a virtual list.

I hope I didn’t confuse you.

···


Hi, I will kill all ads in google gmail.
They will all be dead and gone for all my emails to you. HA HA bye bye ads I just massacred you!!!

It looks like a bug to me, I have the same problem with the wxPython
demo. I'm looking at the code, but I don't see anything wrong. I'll
write up a ticket.

Micah - In virtual mode you keep track of the data yourself, but the
list will send an EDIT event so that you can catch it and modify what
you return in the OnGetItemText function. But yeah you don't need a
virtual list, if you don't use virtual the list itself keeps track of
the data for you and will modify itself when the user edits the
label. Anyway the bug exists in virtual and not virtual looks like.

Mark

http://trac.wxwidgets.org/ticket/12657

Heres the ticket in case someone posts a workaround until the fix gets
released.

Mark

···

On Nov 5, 5:34 am, Mark <markree...@gmail.com> wrote:

It looks like a bug to me, I have the same problem with the wxPython
demo. I'm looking at the code, but I don't see anything wrong. I'll
write up a ticket.

Micah - In virtual mode you keep track of the data yourself, but the
list will send an EDIT event so that you can catch it and modify what
you return in the OnGetItemText function. But yeah you don't need a
virtual list, if you don't use virtual the list itself keeps track of
the data for you and will modify itself when the user edits the
label. Anyway the bug exists in virtual and not virtual looks like.

Mark

Oh, So that’s how it works. Man, now I understand those thing so much better!

···


Hi, I will kill all ads in google gmail.
They will all be dead and gone for all my emails to you. HA HA bye bye ads I just massacred you!!!