第二个面板未显示在wxpython应用程序中



我想在另一个面板上并排(水平)放置两个面板,但第二个面板没有显示:

import wx
szflags = wx.EXPAND | wx.ALL
min_height = 50
height_ratio = 4
pborder = 10
lborder = 5
    class ChartPanel(wx.Panel):
        def __init__(self, *args, **kwargs):
            wx.Panel.__init__(self, *args, **kwargs)
            self.SetBackgroundColour(wx.Colour(226,226,226))
            self.st = wx.StaticText(self, label='CHART PANEL')
            #self.chart = bar_line.CanvasPanel(self, "320")
            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.Add(self.st, 1 , szflags , lborder)
            #sizer.Add(self.chart, 1 , szflags)
            self.SetSizer(sizer)

    class NotebookPage(wx.Panel):
        def __init__(self, *args, **kwargs):
            fleet = kwargs.pop('fleet_name', None)
            wx.Panel.__init__(self, *args, **kwargs)

            self.mainPanel = NotebookPage_MainPanel(self, name='Notebook_Page_MainPanel', fleet_name=fleet)
            self.chartPanel = ChartPanel(self, name='Notebook_Page_ChartPanel')
            sizer = wx.BoxSizer(wx.HORIZONTAL)
            sizer.Add(self.mainPanel, 1, wx.EXPAND|wx.ALL,border=10)
            sizer.Add(self.chartPanel, 1, wx.EXPAND|wx.ALL,border=10)
            self.SetSizer(sizer)

此处图表面板不显示。上面出了什么问题?

实际上,您需要创建一个Parent Panel并将其中两个面板添加到其中。。

创建主面板它包含两个子,即您的笔记本页面和图表面板

    class NotebookPage(wx.Panel):
    def __init__(self, *args, **kwargs):
        fleet = kwargs.pop('fleet_name', None)
        wx.Panel.__init__(self, *args, **kwargs)
        self.masterPanel=wx.Panel(self,-1)
        self.mainPanel = NotebookPage_MainPanel(self.masterpanel, name='Notebook_Page_MainPanel', fleet_name=fleet)
        self.chartPanel = ChartPanel(self.masterpanel, name='Notebook_Page_ChartPanel')
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.mainPanel, 1, wx.EXPAND|wx.ALL,border=10)
        sizer.Add(self.chartPanel, 1, wx.EXPAND|wx.ALL,border=10)
        self.SetSizer(sizer)

参考u可以看到这个链接

第二,他实现了相同的多面板链接

相关内容

  • 没有找到相关文章

最新更新