开发者

How to update the UI of the sub Panel from a parent Frame in wxPython

I have a main frame (wx.Frame) containing a menu bar and a panel (wx.Panel). T开发者_高级运维he panel contains the main UI of the frame. I would like to update the UI of the panel when clicking a menu item.

I was trying self.Refresh(), self.panel.UpdateWindowUI(), self.UpdateWindowsUI(wxUPDATE_UI_RECURSE) in the event handler associating to the menu item but they don't work. I don't want to create new panels and add them back to the frame every times I clicked the menu item.

## =============== Event Handlers of the frame ===================        

def OnOpenConfig(self, event):
    """Open the configuration file for the application"""

    self.dir_name = os.getcwd()
    dlg = wx.FileDialog(self, "Choose a file", self.dir_name, "", "*.conf", wx.OPEN)
    if dlg.ShowModal() == wx.ID_OK:
        self.file_name = dlg.GetFilename()
        self.dir_name = dlg.GetDirectory()
    dlg.Destroy()
    print os.path.join(self.dir_name, self.file_name)

    # the sub panel is changed here because of the configuration file
    self.panel.LoadConfigFile(os.path.join(self.dir_name, self.file_name))

    # The update UI method should be here!!!!!!!
    self.panel.Refresh() 


Could you give some explanation of what self.panel.LoadConfigFile does? You could also try self.panel.Update() after the Refresh.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜