我在 wxpython 中使用静态定位已经有一段时间了,但需要切换到使用 sizers,但我就是无法掌握它。下面是我使用静态定位的应用程序的精简版本。有人可以给我一些关于如何将这种布局转换为使用sizer的指示。我还将附上屏幕截图:
import wx
import wx.lib.agw.aui as aui
import wx.stc as stc
class MainWindow(wx.Frame):
def __init__(self, parent, id, title):
# Setup GUI...
wx.Frame.__init__(self, parent, id, title, size=(900, 740), style=wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER |
wx.RESIZE_BOX |
wx.MAXIMIZE_BOX))
style = aui.AUI_NB_DEFAULT_STYLE ^ aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
self.tabbed = aui.AuiNotebook(self, agwStyle=style)
self.submissions = SubmissionPane(self.tabbed)
self.tabbed.AddPage(self.submissions, "Submit Job")
self.Centre()
self.Show()
class SubmissionPane(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
modeList = ['Verify Mode', 'Upload Mode']
self.rb = wx.RadioBox(
self, -1, "", (35, 2), wx.DefaultSize,
modeList, 2, wx.RA_SPECIFY_COLS
)
tvbox = wx.StaticBox(self, -1, '', pos=(290, 2), size=(335, 41))
wx.StaticText(self, -1, ' Job Title', (317, 12), style=wx.ALIGN_CENTRE)
self.cb1 = wx.CheckBox(self, pos=(306, 12))
self.cb1.SetValue(False)
self.txtTitle = wx.TextCtrl(self, size=(215, 25), pos=(395, 10), style= wx.SUNKEN_BORDER, value="Enter job title here")
wx.StaticText(self, -1, ""'Drag n Drop itmsp folder'"", pos=(35, 60), style=wx.ALIGN_CENTRE)
self.tc_files = wx.TextCtrl(self, wx.ID_ANY, pos=(38, 80), size=(585, 25))
self.buttonGo = wx.Button(self, -1, "Submit", pos=(625, 78))
self.buttonClose = wx.Button(self, -1, "Quit Application", pos=(370,615))
self.index = 0
self.log_text22 = wx.ListCtrl(self, -1, pos=(35, 135), size=(800,275),
style=wx.LC_REPORT | wx.BORDER_SUNKEN | wx.LC_SINGLE_SEL | wx.LC_VRULES | wx.LC_HRULES)
font = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.log_text22.SetFont(font)
self.log_text22.InsertColumn(1, 'Job ID', width=50, format=wx.LIST_FORMAT_CENTRE)
self.log_text22.InsertColumn(2, 'Mode ', width=50, format=wx.LIST_FORMAT_CENTRE)
self.log_text22.InsertColumn(3, 'Title', width=183)
self.log_text22.InsertColumn(4, 'Package', width=227)
self.log_text22.InsertColumn(5, 'Submitted By', width=100)
self.log_text22.InsertColumn(6, 'Sumbit Time', width=85)
self.log_text22.InsertColumn(7, 'Process', width=50, format=wx.LIST_FORMAT_CENTRE)
self.log_text22.InsertColumn(8, 'Status ', width=50, format=wx.LIST_FORMAT_CENTRE)
self.running_log1 = wx.stc.StyledTextCtrl(self, -1, pos=(35, 420), size=(800,175))
self.running_log1.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font)
self.running_log1.SetMarginWidth(1, 0)
self.running_log1.StyleSetBackground(wx.stc.STC_STYLE_DEFAULT, (0,0,0))
self.running_log1.StyleClearAll()
self.running_log1.StyleSetForeground(wx.stc.STC_STYLE_DEFAULT, (0,255,0))
self.running_log1.StyleClearAll()
self.Show()
app = wx.App()
MainWindow(None, -1, 'Test App')
app.MainLoop()