Problem with called wxListCtrl::ClearAll() and then trying to populate the ListCtrl

I'm rather baffled...

I have a function, called "refreshListCtrl" that calls two member functions of a wx.ListCtrl class instance: ClearAll and Init.

The init function looks like this:
def Init(self):
        print "ListCtrl::Init Called!"
        members = wx.GetApp().server.lost.getMembers(wx.GetApp().server.lost.listMembers())
        print members
               for x in members:
            index = self.InsertStringItem(int(x['id']), x['id'])
            for y in self.columns:
                self.SetStringItem(index, y[0], x[y[2]])

        self.currentItem = 0

wx.GetApp().server returning a xmlrpclib.ServerProxy instance.

Columns being defined as: ([0, "ID", "id"], [1, "Name", "name"], [2, "Handle", "handle"], [3, "PvP Rank", "rank"], [4, "Position", "position"], [5, "Timestamp", "timestamp"], [6, "E-Mail", "email"])

Members look something like: [{'handle': 'Spider', 'name': 'Infernious Spider', 'timestamp': '1115092800', 'rank': '0', 'email': '', 'position': '0', 'id': '7'}, {'handle': 'Morek', 'name': 'Morek Nightwind', 'timestamp': '1124856000', 'rank': '0', 'email': '', 'position': '0', 'id': '6'}]

When the ListCtrl is instantiated, the Init function is called. This works as I expect it to, but when the refreshListCtrl function is called (just calling ClearAll and Init), the list is cleared, and the members array is printed to the console.... although the ListCtrl shows nothing, but has what appears to be a correctly sized scrollbar.

I thank any help... be it pushes in the right direction, RTFM (if applicable), etc.

--Robert Pierce

Hi Robert,

Robert Pierce wrote:

I'm rather baffled...

I have a function, called "refreshListCtrl" that calls two member functions of a wx.ListCtrl class instance: ClearAll and Init.

Do you really need to do a ClearAll? That will also clear your column headers.

What about doing just list.DeleteAllItems instead of ClearAll?

If you need ClearAll as your headers might change then your Init will have to build your columns again with e.g.
list.InsertColumnInfo(x, info) or similar.

Hope this helps
Werner

···

The init function looks like this:
def Init(self):
       print "ListCtrl::Init Called!"
       members = wx.GetApp().server.lost.getMembers(wx.GetApp().server.lost.listMembers())
       print members
             for x in members:
           index = self.InsertStringItem(int(x['id']), x['id'])
           for y in self.columns:
               self.SetStringItem(index, y[0], x[y[2]])

       self.currentItem = 0

wx.GetApp().server returning a xmlrpclib.ServerProxy instance.

Columns being defined as: ([0, "ID", "id"], [1, "Name", "name"], [2, "Handle", "handle"], [3, "PvP Rank", "rank"], [4, "Position", "position"], [5, "Timestamp", "timestamp"], [6, "E-Mail", "email"])

Members look something like: [{'handle': 'Spider', 'name': 'Infernious Spider', 'timestamp': '1115092800', 'rank': '0', 'email': '', 'position': '0', 'id': '7'}, {'handle': 'Morek', 'name': 'Morek Nightwind', 'timestamp': '1124856000', 'rank': '0', 'email': '', 'position': '0', 'id': '6'}]

When the ListCtrl is instantiated, the Init function is called. This works as I expect it to, but when the refreshListCtrl function is called (just calling ClearAll and Init), the list is cleared, and the members array is printed to the console.... although the ListCtrl shows nothing, but has what appears to be a correctly sized scrollbar.

I thank any help... be it pushes in the right direction, RTFM (if applicable), etc.

--Robert Pierce

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Robert Pierce wrote:

When the ListCtrl is instantiated, the Init function is called. This works as I expect it to, but when the refreshListCtrl function is called (just calling ClearAll and Init), the list is cleared, and the members array is printed to the console.... although the ListCtrl shows nothing, but has what appears to be a correctly sized scrollbar.

Try doing the clear and the repopulate in two separate steps, and don't do the 2nd step in the same event handler that does the clear. You don't mention the platform, but I've seen this on wxGTK before, where there is some internal functionality associated with the Clear or a DeleteAll that needs to happen after the items have been removed. You can schedule a delayed call your your repopulate function with wx.CallAfter.

···

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