我的框架带有2个面板的分割器。其中一个面板(右一个= choosePanel)有一个按钮,该按钮应在选择面板的同一位置打开一个新面板(infopanel)。我使用了这种技术(wxPython: Good way to overlay a wx.Panel on an existing wx.Panel)。
这部分有效。但是,infopanel没有正确调整大小。当我将这个面板硬编码添加到choosepanel的位置时,它就可以了。 但是当我使用叠加技术时会发生一些事情。
代码:
class Main(wx.Frame):
def __init__(self, parent=None, id=-1, notify_channel="browser_view",**kwargs):
wx.Frame.__init__(self, parent, id, config.programname)
self.parent = parent
self.notify_channel = notify_channel
pub.subscribe(self.on_message, notify_channel)
self.backgroundpanel = wx.Panel(self, wx.ID_ANY)
self.splitter = wx.SplitterWindow(self.backgroundpanel, wx.ID_ANY, style=wx.SP_LIVE_UPDATE | wx.SP_BORDER)# style=wwx.SP_LIVE_UPDATE : Don't draw XOR line but resize the child windows immediately.
self.filter = filter_view.Main(self.splitter, wx.ID_ANY, notify_channel=self.notify_channel)
self.menubar = menubar_view.Main(self, wx.ID_ANY, notify_channel=self.notify_channel)
self.statusbar = self.CreateStatusBar()
self.ChoosePanel = choosePanel_view.Main(self.splitter, wx.ID_ANY)
# self.ChoosePanel = cellinfo_view.Main(self.splitter, wx.ID_ANY, notify_channel="cellinfo_view")
self._do_layout()
self._do_bindings()
self.Maximize()
self.Show()
def _do_layout(self):
self.backgroundsizer = wx.BoxSizer()
self.sizer = wx.BoxSizer(wx.HORIZONTAL)
self.backgroundsizer.Add(self.backgroundpanel, 1, wx.EXPAND)
self.SetMenuBar(self.menubar)
self.sizer.Add(self.splitter, 1, wx.EXPAND)
self.backgroundpanel.SetSizer(self.sizer)
self.sizer.Fit(self.backgroundpanel)
self.SetSizer(self.backgroundsizer)
self.backgroundsizer.Fit(self)
self.splitter.SplitVertically(self.filter, self.ChoosePanel, 500)
self.splitter.SetMinimumPaneSize(50)
当我点击choosepanel中的按钮时,会有一条pubsub消息返回此文件:
def on_cellinfo_panel(self,message):
# print self.ChoosePanel.GetPosition()
self.ChoosePanel.Hide()
self.cellinfo = cellinfo_view.Main(self.splitter, wx.ID_ANY, notify_channel="cellinfo_view", style=wx.EXPAND)
self.cellinfo.SetPosition((504, 0))
self.cellinfo.Layout()
切换这两个:
self.ChoosePanel = choosePanel_view.Main(self.splitter, wx.ID_ANY)
# self.ChoosePanel = cellinfo_view.Main(self.splitter, wx.ID_ANY, notify_channel="cellinfo_view")