先从wxPython开始吧

gat*_*ath 3 python wxpython

我在wxPython中使用sizer来设置我的表单时遇到了一些挑战,如果有人能像我一样在图像中显示我的表单,我会很感激.

样本表格

请分享消息来源.

谢谢

joa*_*uin 7

在设计复杂的gui时,我不会手动搞乱sizer.请,请使用wxglade并在之后手动定制.

这花了15分钟,包括错误(我没有填写列表控件,抱歉):

在此输入图像描述

这是我遵循的过程:

1) Add a Frame widget, select a wx.Frame.  

2) Customize wx.Frame properties:  
     Give the Frame a MenuBar (the property dialog for the menubar appears).  
     Customize MenuBar: Add File, Edit...  
     Go back to the Frame properties' View (click the Frame icon on the wxglade Tree View).  
     (not nice but it's the way I found to go in and out from Menu and StatusBar dialogs).  
     Give the wx.Frame a StatusBar. Go back (click the Frame icon in the wxglade Tree View).  

3) Create 3 vertical slots from the default BoxSizer (right-click on the sizer + add * 3)
      1st slot: 
          Add a BoxSizer with 5 horizontal slots
          Set proportion=0 to the sizer, set border=5 and mark wxALL
          Add 4 Buttons and a Spacer in those slots
          Mark EXPAND and set proportion=1 in the Spacer properties.

      2nd slot:
          Add a SplitterWindow. Select Vertical type.
          Optionally set border=5 with wxALL
          Add a BoxSizer to each section of the SplitterWindow
          At its left, add a ListCtrl
          At its right, add a NoteBook
          Customize NoteBook:
              Add 4 sheets.
              Add BoxSizer with 2 vertical slots to first notebook sheet.
                  1st slot: insert a wx.Panel.
                  2nd slot: add a BoxSizer with 3 horizontal slots.
                      Set proportion=0 to the sizer.
                      Add 2 buttons and 1 Spacer in those slots.
                      Mark EXPAND and set proportion=1 in the Spacer properties.

      3rd slot:
          Add a BoxSizer with 5 horizontal slots.
          Set proportion=0 to the sizer, set border=5 with wxALL
          Add 2 Buttons, 1 Spacer and 2 Buttons more.
          Mark EXPAND and set proportion=1 in the Spacer properties.

4) Give background colour to the Frame.
  (Choose wisely, you still have 5 minutes left of the 15 allotted).
Run Code Online (Sandbox Code Playgroud)

最后,自定义标签,大小调整器和窗口小部件名称等.
保存wxGlade文件以备将来更改并生成Python文件(在顶部的"应用程序"对话框中).
技巧:不要修改生成的文件,而是在另一个文件中导入和子类化Frame以编写其功能.

最后一点:根据我的经验,Linux和Windows在测量器和背景方面存在一些差异.在Linux中,不要使用步骤3中指示的默认Frame的BoxSizer.而是在其上添加一个wx.Panel,将BoxSizer添加到Panel并继续从此sizer构建.