プロジェクトの一部として、このGUIツールをwxpythonでビルドしようとしています。水平方向に分割されたスプリッターウィンドウ(wx.SplitterWindowオブジェクト)を持つ基本的なフレームがあります。アプリケーションを最初に開くと、スプリッターウィンドウとテキストが表示されます。また、それぞれのイベントハンドラーにバインドされているさまざまなメニュー項目を格納するメニューもあります。ここで、特定のメニュー項目を初めてクリックするときに、そのイベントハンドラーに関連する情報をホストするページで、既存のコンテンツに加えて、新しいwx.Notebookオブジェクトを作成する必要があります。フレーム(wx.SplitterWindowオブジェクト)。通常、ノートブックオブジェクトの親となる、古いコンテンツの上に新しいパネルを作成する必要があります。その後メニュー項目をクリックするたびに、ノートブックに新しいページが作成されます。これをどのように達成できるか教えてもらえますか?
これが私が書いた必要なコードスニペットですが、私はどこかでひどく間違っていることがよくあります:
このコードは、2つのパネルで構成される初期スプリッターウィンドウを作成します。
self.splitter = wx.SplitterWindow(self, id = wx.ID_ANY)
self.panel1 = wx.Panel(self.splitter, id = wx.ID_ANY)
self.panel2 = wx.Panel(self.splitter, id = wx.ID_ANY)
self.panel1.SetBackgroundColour(wx.LIGHT_GREY)
self.splitter.SplitHorizontally(self.panel1, self.panel2)
最初のメニュー項目クリックイベントのコード:
def displayNodes(self,event):
if hasattr(self, "notebook") == False: #If the notebook object has not been already created
#create notebook if it does not exitst already. This script should be present in every event handler
self.panel = wx.Panel(self,wx.ID_ANY)
self.notebook = NotebookDemo(self.panel)
#creating vertical sizer for the notebook
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.notebook, 1, wx.ALL|wx.EXPAND, 5)
self.panel.SetSizer(self.sizer)
self.nodesname = "nodes"
self.nodesinstance = wx.SingleInstanceChecker(self.nodesname)
if self.nodesinstance.IsAnotherRunning():
self.notebook.ChangeSelection(self.nodesindex)
else:
#creating a tab
self.nodesTab = TabPanel(self.notebook)
self.notebook.AddPage(self.nodesTab, "List of all the nodes")
self.nodes = wx.ListBox(self.nodesTab, 11, (10,40), (200,130), self.nodeslist, wx.LB_SINGLE)
self.nodesindex = self.notebook.GetPageCount() - 1
self.notebook.SetSelection(self.nodesindex)
#self.Bind(wx.EVT_CONTEXT_MENU, self.OnShowPopup)
PS:wxpythonに関する私の知識は限られており、まだ学んでいます!目的をはるかにエレガントな方法で達成できれば、とても幸せです!