简体   繁体   中英

New wxpython controls not displaying until resize

I have created a custom control (based on a panel) in wxPython that provides a list of custom controls on panel within it. The user needs to be able to add rows at will and have those rows displayed. I'm having trouble getting the new controls to actually appear after they are added. I know they are present, because they appear after a resize of the frame, or if I add them before Show() is called on the frame. I've convinced myself it's something basic, but I can't find the mistake.

The add function looks like this:

def addRow(self, id, reference, page, title, note):

    newRow = NoteListRow(self.listPanel, id, reference, page, title, note)
    self.listSizer.Add(newRow, flag=wx.EXPAND | wx.LEFT)
    self.rows.append(newRow)

    if len(self.rows) == 1:
        self.highliteRow(newRow)

    self.Refresh()
    self.Update()

    return newRow

I assume I'm missing something about how refresh and update are supposed to behave, so even a good extended reference on those would likely be helpful.

Try self.Layout()

Try self.GetParent().Layout()

Including a Refresh() .

Update() shouldn't be necessary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM