0

3 つのパネルでフルスクリーン アプリを表示しようとしています。画面は最初に 2 つの垂直パネルに分割し、右側のパネルを 2 つの水平パネルに分割する必要があります。何かのようなもの:

____________________
|        |         |
|        |         |
|        |_________|
|        |         |
|        |         |
|________|_________|

問題は、サイザーに問題があるため、それがわからないことです。これは私の試みです:

import wx

class Input_Panel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        # Input variables
        self.tittle1 = wx.StaticText(self, label="Inputs:")    
        self.lblname1 = wx.StaticText(self, label="Input 1:")
        self.format1 = ['Option 1','Option 2']
        self.combo1 = wx.ComboBox(self, size=(200, -1),value='', choices=self.format1,style=wx.CB_DROPDOWN)
        self.lblname2 = wx.StaticText(self, label="Input 2")
        self.format2 = ['Option 1','Option 2', 'Option 3']
        self.combo2 = wx.ComboBox(self, size=(200, -1),value='', choices=self.format2, style=wx.CB_DROPDOWN)

        # Set sizer for the panel content
        self.sizer = wx.GridBagSizer(2, 2)
        self.sizer.Add(self.tittle1, (1, 2))
        self.sizer.Add(self.lblname1, (2, 1))
        self.sizer.Add(self.combo1, (2, 2))
        self.sizer.Add(self.lblname2, (3, 1))
        self.sizer.Add(self.combo2, (3, 2))
        self.SetSizer(self.sizer)

class Output_Panel1(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        # Output variables
        self.tittle2 = wx.StaticText(self, label="Outputs:")    
        self.lblname3 = wx.StaticText(self, label="Output1")
        self.result3 = wx.StaticText(self, label="", size=(100, -1))

        # Set sizer for the panel content
        self.sizer = wx.GridBagSizer(2, 2)
        self.sizer.Add(self.tittle2, (1, 2))
        self.sizer.Add(self.lblname3, (2, 1))
        self.sizer.Add(self.result3, (2, 2))
        self.SetSizer(self.sizer)

class Output_Panel2(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        # Output variables
        self.tittle2 = wx.StaticText(self, label="Outputs:")    
        self.lblname3 = wx.StaticText(self, label="Output1")
        self.result3 = wx.StaticText(self, label="", size=(100, -1))

        # Set sizer for the panel content
        self.sizer = wx.GridBagSizer(2, 2)
        self.sizer.Add(self.tittle2, (1, 2))
        self.sizer.Add(self.lblname3, (2, 1))
        self.sizer.Add(self.result3, (2, 2))
        self.SetSizer(self.sizer)



class Main_Window(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title = title, pos = (0, 0), size = wx.DisplaySize())

        # Set variable panels
        self.main_splitter = wx.SplitterWindow(self)
        self.out_splitter = wx.SplitterWindow(self.main_splitter)
        self.inputpanel = Input_Panel(self.main_splitter)
        self.inputpanel.SetBackgroundColour('#c4c4ff')
        self.outputpanel1 = Output_Panel1(self.out_splitter)
        self.outputpanel1.SetBackgroundColour('#c2f1f5')
        self.outputpanel2 = Output_Panel2(self.out_splitter)
        self.outputpanel2.SetBackgroundColour('#c2f1f5')
        self.main_splitter.SplitVertically(self.inputpanel, self.main_splitter)
        self.main_splitter.SplitHorizontally(self.outputpanel1, self.outputpanel2)

        # Set sizers
        self.windowSizer1 = wx.BoxSizer(wx.VERTICAL)
        self.windowSizer2 = wx.BoxSizer(wx.HORIZONTAL)
        self.windowSizer2.Add(self.out_splitter, 1, wx.ALL | wx.EXPAND)
        self.windowSizer1.Add(self.windowSizer2, 1, wx.ALL | wx.EXPAND)    
        self.SetSizer(self.windowSizer1)

def main():
    app = wx.App(False)
    frame = Main_Window(None, "App GUI")
    frame.Show()
    app.MainLoop()

if __name__ == "__main__" :
    main()
4

1 に答える 1

3

次の 2 行を削除します。

self.main_splitter.SplitVertically(self.inputpanel, self.main_splitter)
self.main_splitter.SplitHorizontally(self.outputpanel1, self.outputpanel2)

と:

self.main_splitter.SplitVertically(self.inputpanel, self.out_splitter)
self.out_splitter.SplitHorizontally(self.outputpanel1, self.outputpanel2)

これらの行の何が問題になっていますか:

  1. 最初の行で、コードは に渡さmain_splittermain_splitter.SplitVerticallyます。
  2. 2 行目は再び分割main_splitterされます。

次の行を削除します。

# Set sizers
self.windowSizer1 = wx.BoxSizer(wx.VERTICAL)
self.windowSizer2 = wx.BoxSizer(wx.HORIZONTAL)
self.windowSizer2.Add(self.out_splitter, 1, wx.ALL | wx.EXPAND)
self.windowSizer1.Add(self.windowSizer2, 1, wx.ALL | wx.EXPAND)    
self.SetSizer(self.windowSizer1)
于 2013-10-17T15:10:13.657 に答える