Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wxpython:未显示多个面板_Python_User Interface_Wxpython_Panel - Fatal编程技术网

Wxpython:未显示多个面板

Wxpython:未显示多个面板,python,user-interface,wxpython,panel,Python,User Interface,Wxpython,Panel,我正在制作一个预算程序,显示所有用户的费用。我希望这样,当用户单击ListUI时,它会显示关于该类别的所有数据。我可以让程序在两个类别面板之间切换,但是我无法让摘要页面正确显示。它只是一片空白,没有任何信息 (在列表界面旁边放置面板的额外积分,这是我想学习的东西,但我还没有学到。) 几件事:显示面板时不要创建面板。在之前创建并隐藏它。当你需要的时候,用信息填写并显示出来。我强烈建议您使用WxGlade使用wxPython构建图形部件。遗憾的是,您发布的代码片段只为我们提供了一包代码扳手。我不知道

我正在制作一个预算程序,显示所有用户的费用。我希望这样,当用户单击ListUI时,它会显示关于该类别的所有数据。我可以让程序在两个类别面板之间切换,但是我无法让摘要页面正确显示。它只是一片空白,没有任何信息

(在列表界面旁边放置面板的额外积分,这是我想学习的东西,但我还没有学到。)


几件事:显示面板时不要创建面板。在之前创建并隐藏它。当你需要的时候,用信息填写并显示出来。我强烈建议您使用WxGlade使用wxPython构建图形部件。遗憾的是,您发布的代码片段只为我们提供了一包代码扳手。我不知道这些事情是如何联系在一起的,我怀疑你会得到一个有用的答案。要么发布完整代码,要么
#In my budget module
    def displayBudget(self,panel,sizer):

        self.categoryListUI = wx.ListCtrl(panel, wx.ID_ANY,style = wx.LC_REPORT) 
        self.categoryPanelList = []
        self.categoryListUI.InsertColumn(0, 'Name',width = 75)
        self.categoryListUI.InsertColumn(1, 'Amount',width = 100)        
        self.categoryListUI.InsertColumn(2, 'Spending',width = 100)  
        self.categoryListUI.InsertColumn(3, 'Remaining',width = 100)

        index = 0
        self.insertListCtrlSummary(self.categoryListUI,index,panel)
        tempCatPanel = self.displaySummary(panel)
        tempCatPanel.Hide()
        self.categoryPanelList.append(tempCatPanel)

        index += 1
    
        for i in self.categoryArray:

            i.insertListCtrl(self.categoryListUI,index,panel)

            tempCatPanel = i.displayCategory(panel)
            tempCatPanel.Hide()
            self.categoryPanelList.append(tempCatPanel)

            index += 1

        panel.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnClick, self.categoryListUI)

        sizer.Add(self.categoryListUI,pos=(2, 0),span=(1, 100),flag = wx.EXPAND|wx.ALIGN_LEFT|wx.ALIGN_BOTTOM, border = 5)

        self.currentPanel = self.categoryPanelList[0]
        self.currentPanel.Update()
        self.currentPanel.Show()

        sizer.Add(self.currentPanel ,pos=(25, 25),span=(4, 8),flag = wx.EXPAND|wx.ALIGN_RIGHT|wx.ALL, border = 5)

        panel.SetSizerAndFit(sizer)
    
        print(len(self.categoryPanelList))

        return sizer

    def OnClick(self,event):

        if self.currentPanel != None:
            self.currentPanel.Hide()
        print(event.GetIndex())   
        self.currentPanel = self.categoryPanelList[event.GetIndex()]

        if self.currentPanel is None:

            wx.MessageBox('Could not display Category.', 'Error', wx.OK | wx.ICON_ERROR)

        else:

            self.currentPanel.Update()
            self.currentPanel.Show()

    def insertListCtrlSummary(self,uiList,index,panel):
        self.categoryListUI.InsertItem(index, "Summary")
        self.categoryListUI.SetItem(index, 1, "$ "+str(format(self.amount, '.2f')))
        self.categoryListUI.SetItem(index, 2, "$ "+str(format(self.totalSpending(), '.2f')))
        self.categoryListUI.SetItem(index, 3, "$ "+str(format(self.totalRemaining(), '.2f') ))

    def displaySummary(self,parent):

        panel = wx.Panel(parent)
        sizer = wx.GridBagSizer(5, 5)
        remainString = "Remaining: $ "+str(self.totalRemaining())
        remainStatic = wx.StaticText(panel, wx.ID_ANY, remainString)
        amountStatic = wx.StaticText(panel, wx.ID_ANY, "Amount: $ ") 
        amountDisplay = wx.TextCtrl(panel, wx.ID_ANY, str(self.amount))
        sizer.Add(amountStatic,pos=(0, 0),span=(1, 1),flag = wx.EXPAND|wx.ALIGN_LEFT, border = 5)
        sizer.Add(amountDisplay,pos=(0, 1),span=(1, 1),flag = wx.EXPAND|wx.ALIGN_LEFT, border = 5)
        sizer.Add(remainStatic,pos=(0, 4),span=(1, 3),flag = wx.EXPAND|wx.ALIGN_LEFT, border = 5)

        panel.SetSizerAndFit(sizer)
        
        panel.Show()

        return panel
#Category display stuff.

    def insertListCtrl(self,uiList,index,panel):
        uiList.InsertItem(index, self.name) 
        uiList.SetItem(index, 1, "$ "+str(format(self.amount, '.2f'))) 
        uiList.SetItem(index, 2, "$ "+str(format(self.calculateExpenses(), '.2f')))
        uiList.SetItem(index, 3, "$ "+str(format(self.calculateRemainingAmount(), '.2f')))

    def displayCategory(self,panelMaster):
        
        panel = wx.Panel(panelMaster)
        sizer = wx.GridBagSizer(5, 5)
        remainString = "Remaining: $ "+ str(format(self.calculateRemainingAmount(), '.2f'))
        remainStatic = wx.StaticText(panel, wx.ID_ANY, remainString)
        amountStatic = wx.StaticText(panel, wx.ID_ANY, "Amount: $ ") 
        amountDisplay = wx.TextCtrl(panel, wx.ID_ANY, str(format(self.amount, '.2f')))
        sizer.Add(amountStatic,pos=(0, 0),span=(1, 1),flag = wx.EXPAND|wx.ALIGN_LEFT, border = 5)
        sizer.Add(amountDisplay,pos=(0, 1),span=(1, 1),flag = wx.EXPAND|wx.ALIGN_LEFT, border = 5)
        sizer.Add(remainStatic,pos=(0, 4),span=(1, 3),flag = wx.EXPAND|wx.ALIGN_LEFT, border = 5)
        panel.SetSizerAndFit(sizer)

        return panel