not recognizing updates to data on 2nd edit in ObjectListView / Python

16 Views Asked by At
I'm new to python and trying to make a simple list that can be inserted into a system via APIs we call.

right now im working on front end with ObjectListView.

I can get it to capture changes after I press Save button.

In the even handler method (updateControl) the initial input is taken and append with a dict with 3 new blank rows.

After the first save and when editing the blank rows from the UI and clicking the Save button, the changes are not captured.

I wanted to see the second set of changes in the Save event handler method.

Any help would be great. Thanks in advance.

def init(self, parent): wx.Panel.init(self, parent=parent, id=wx.ID_ANY) self.books = [Book("ABCD", "Robin Hood", "1932394621", "Manning"), Book("Red Riding Hood", "Big Bird", "1933988495", "Manning"), Book(" ", " ", " ", " "), ]

    self.dataOlv = ObjectListView(self, wx.ID_ANY, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
    self.setBooks()
    # Allow the cell values to be edited when double-clicked
    self.dataOlv.cellEditMode = ObjectListView.CELLEDIT_DOUBLECLICK
    

    # create an SAVE button
    saveBtn = wx.Button(self, wx.ID_ANY, "SAVE")

    saveBtn.Bind(wx.EVT_BUTTON, self.updateControl)
    # Create some sizers
    mainSizer = wx.BoxSizer(wx.VERTICAL)        
    mainSizer.Add(self.dataOlv, 1, wx.ALL|wx.EXPAND, 5)
    mainSizer.Add(saveBtn, 0, wx.ALL|wx.CENTER, 5)
    self.SetSizer(mainSizer)

. . .

def updateControl(self, event):
    
    book_dict = [{"title":"", "author":"",
                     "isbn":"", "mfg":""},

                    {"title":"", "author":"",
                     "isbn":"", "mfg":""},

                     {"title":"", "author":"",
                     "isbn":"", "mfg":""}
                    ]
    
    data = self.books + book_dict
    self.dataOlv.SetObjects(data)
0

There are 0 best solutions below