【发布时间】:2011-09-17 05:38:00
【问题描述】:
我有一个主框架 (wx.Frame),其中包含一个菜单栏和一个面板 (wx.Panel)。该面板包含框架的主 UI。我想在单击菜单项时更新面板的 UI。
我在与菜单项关联的事件处理程序中尝试了 self.Refresh()、self.panel.UpdateWindowUI()、self.UpdateWindowsUI(wxUPDATE_UI_RECURSE),但它们不起作用。每次单击菜单项时,我都不想创建新面板并将它们添加回框架。
## =============== 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()
【问题讨论】:
标签: wxpython