微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Wxpython:多个面板不显示

如何解决Wxpython:多个面板不显示

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

(用于将面板放置在List UI旁边的奖励点,我想学习购买的东西还没有。)

#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,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,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(),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,remainString)
        amountStatic = wx.StaticText(panel,"Amount: $ ") 
        amountdisplay = wx.TextCtrl(panel,str(self.amount))
        sizer.Add(amountStatic,pos=(0,1),flag = wx.EXPAND|wx.ALIGN_LEFT,border = 5)
        sizer.Add(amountdisplay,border = 5)
        sizer.Add(remainStatic,4),3),border = 5)

        panel.SetSizerAndFit(sizer)
        
        panel.Show()

        return panel
#Category display stuff.

    def insertListCtrl(self,panel):
        uiList.InsertItem(index,self.name) 
        uiList.SetItem(index,'.2f'))) 
        uiList.SetItem(index,"$ "+str(format(self.calculateExpenses(),'.2f')))
        uiList.SetItem(index,"$ "+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,str(format(self.amount,'.2f')))
        sizer.Add(amountStatic,border = 5)
        panel.SetSizerAndFit(sizer)

        return panel

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。