Python wx 模块,GridBagSizer() 实例源码

我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用wx.GridBagSizer()

项目:pyDataView    作者:edwardsmith999    | 项目源码 | 文件源码
def __init__(self,parent,**kwargs):
        wx.Panel.__init__(self,parent,**kwargs)

        self.componenttitle = wx.StaticText(self,-1,label='Component',size=(100,-1))
        self.componentcombobox = wx.ComboBox(self, size=(10,-1), value='0')

        choices = ['0','1','2']
        self.normaltitle = wx.StaticText(self,-1,label='Normal', size=(100,-1))
        self.normalcombobox = wx.ComboBox(self, choices=choices, size=(10,-1), 
                                          value='0')

        grid = wx.GridBagSizer(hgap=3)
        grid.Add(self.componenttitle,    (0,0), flag=wx.EXPAND)
        grid.Add(self.componentcombobox, (1,0), flag=wx.EXPAND)
        grid.Add(self.normaltitle,       (0,1), flag=wx.EXPAND)
        grid.Add(self.normalcombobox,    (1,1), flag=wx.EXPAND)
        grid.AddGrowableCol(0)
        grid.AddGrowableCol(1)
        self.SetSizer(grid)
项目:wxWize    作者:AndersMunch    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Dialog.__init__(self, parent, -1, title=u"Logon", style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
        vsizer = wx.BoxSizer(orient=wx.VERTICAL)
        gb = wx.GridBagSizer()
        gb.Add(wx.StaticText(self, -1, u"Username"), flag=wx.ALL|wx.EXPAND, border=10, pos=(0,0))
        self._name = wx.TextCtrl(self, -1)
        gb.Add(self._name, flag=wx.ALL|wx.EXPAND, border=10, pos=(0,1))
        gb.Add(wx.StaticText(self, -1, u"Password"), flag=wx.ALL|wx.EXPAND, pos=(1,0), border=10)
        self._pass = wx.TextCtrl(self, -1, style=wx.TE_PASSWORD)
        gb.Add(self._pass, border=10, flag=wx.EXPAND|wx.ALL, pos=(1,1))
        gb.AddGrowableCol(1)
        butsz = wx.StdDialogButtonSizer()
        okbut = wx.Button(self, wx.ID_OK, u"OK")
        butsz.AddButton(okbut)
        cbut = wx.Button(self, wx.ID_CANCEL, u"Cancel")
        butsz.AddButton(cbut)
        insp = wx.Button(self, wx.ID_HELP, u"Help")
        butsz.AddButton(insp)
        insp.Bind(wx.EVT_BUTTON, InspectionTool().Show)
        butsz.Realize()
        okbut.SetDefault()
        vsizer.Add(gb, 0, wx.EXPAND)
        vsizer.Add(butsz, 0, wx.EXPAND)
        self.SetSizer(vsizer)
        self.Fit()
项目:pywatch    作者:jackburridge    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"Background Task", pos=wx.DefaultPosition,
                          size=wx.Size(500, 300), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)

        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

        sizer = wx.BoxSizer(wx.VERTICAL)

        gb_sizer = wx.GridBagSizer(5, 5)
        gb_sizer.SetFlexibleDirection(wx.BOTH)
        gb_sizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        self.gauge = wx.Gauge(self, wx.ID_ANY, 10 ** 3, wx.DefaultPosition, wx.DefaultSize, wx.GA_HORIZONTAL)
        self.gauge.SetValue(0)
        gb_sizer.Add(self.gauge, wx.GBPosition(0, 0), wx.GBSpan(1, 1), wx.EXPAND, 0)

        self.button = wx.Button(self, wx.ID_ANY, u"Run", wx.DefaultPosition, wx.DefaultSize, 0)
        gb_sizer.Add(self.button, wx.GBPosition(1, 0), wx.GBSpan(1, 1), wx.EXPAND, 0)

        gb_sizer.AddGrowableCol(0)

        sizer.Add(gb_sizer, 1, wx.EXPAND | wx.ALL, 5)

        self.SetSizer(sizer)
        self.Layout()

        self.Centre(wx.BOTH)

        # Connect Events
        self.button.Bind(wx.EVT_BUTTON, self.on_run)
        self.model = WatchableDict()
        self.model["complete"] = 0
        pywatch.wx.ValueWatcher(self.gauge, self.model, "complete")


    # Virtual event handlers, overide them in your derived class
项目:pywatch    作者:jackburridge    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"Background Logging", pos=wx.DefaultPosition,
                          size=wx.Size(500, 300), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)

        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

        sizer = wx.BoxSizer(wx.VERTICAL)

        gb_sizer = wx.GridBagSizer(5, 5)
        gb_sizer.SetFlexibleDirection(wx.BOTH)
        gb_sizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        list_boxChoices = []
        self.list_box = wx.ListBox(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, list_boxChoices, 0)
        gb_sizer.Add(self.list_box, wx.GBPosition(0, 0), wx.GBSpan(1, 1), wx.EXPAND, 0)

        self.button = wx.Button(self, wx.ID_ANY, u"Run", wx.DefaultPosition, wx.DefaultSize, 0)
        gb_sizer.Add(self.button, wx.GBPosition(1, 0), wx.GBSpan(1, 1), wx.EXPAND, 0)

        gb_sizer.AddGrowableCol(0)
        gb_sizer.AddGrowableRow(0)

        sizer.Add(gb_sizer, 1, wx.EXPAND | wx.ALL, 5)

        self.SetSizer(sizer)
        self.Layout()

        self.Centre(wx.BOTH)

        # Connect Events
        self.button.Bind(wx.EVT_BUTTON, self.on_run)

        self.model = WatchableDict()
        self.model["logs"] = []
        pywatch.wx.ItemContainerItemWatcher(self.list_box, self.model, "logs")



        # Virtual event handlers, overide them in your derived class
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def initializeUI(self, title):
        # create grid layout manager
        self.sizer = wx.GridBagSizer()
        self.SetSizerAndFit(self.sizer)
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def initializeUI(self, title):
        # create grid layout manager
        self.sizer = wx.GridBagSizer()
        self.SetSizer(self.sizer)
项目:wxWize    作者:AndersMunch    | 项目源码 | 文件源码
def create_preorder(self):
        self.w = self.sized = (self.w or wx.GridBagSizer(self.vgap, self.hgap))
项目:padherder_proxy    作者:jgoldshlag    | 项目源码 | 文件源码
def __init__(self, parent):
        self.us_to_jp_map = {}
        self.monster_data = {}
        wx.Panel.__init__(self, parent)
        grid = wx.GridBagSizer(hgap=5, vgap=10)

        config = wx.ConfigBase.Get()
        host = config.Read("host") or socket.gethostbyname(socket.gethostname())

        start_instructions = wx.StaticText(self, label="Just the first time, you need to add the HTTPS certificate to your iOS/Android device. To do this, go to your wifi settings and set up a manual HTTP proxy. Set the server to '%s' and the port to 8080. Then visit http://mitm.it in Safari/Chrome, click the link for your device, and install the configuration profile when asked. After this is done, turn off the HTTP proxy." % host)
        start_instructions.Wrap(580)
        grid.Add(start_instructions, pos=(0,0))

        dns_instructions = wx.StaticText(self, label="To synchronize your box with padherder, enter your padherder username and password in Settings. Then go to your wifi settings and change your DNS server to '%s'. Then press the home button. If you switch to the DNS Proxy Log tab, you should see a bunch of log lines. Make sure Puzzle and Dragons is completely closed, and re-open it. Once you get in game, close PAD completely again and restore your DNS settings." % host)
        dns_instructions.Wrap(580)
        grid.Add(dns_instructions, pos=(1,0))

        status_label = wx.StaticText(self, label="Status:")
        grid.Add(status_label, pos=(2,0))

        self.status_ctrl = wx.TextCtrl(self, wx.ID_ANY, size=(400,300),
                          style = wx.TE_MULTILINE|wx.TE_READONLY)
        self.Bind(custom_events.EVT_STATUS_EVENT, self.onStatusEvent)
        if not config.Read("username"):
            self.status_ctrl.AppendText("You need to set your padherder username in Settings\n")
        if not config.Read("password"):
            self.status_ctrl.AppendText("You need to set your padherder password in Settings\n")

        grid.Add(self.status_ctrl, pos=(3,0), span=(1,2))

        if is_out_of_date(self):
            updateCtrl = HyperLinkCtrl(self, wx.ID_ANY, label="An updated version is available", URL="https://github.com/jgoldshlag/padherder_proxy")
            grid.Add(updateCtrl, pos=(4,0), span=(1,2))

        self.SetSizer(grid)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def CreateContainer(self, container_type_name, *args, **kwargs):
        try:
            if container_type_name == 'BoxSizer':
                container_class = BoxSizerContainer
            elif container_type_name == 'GridSizer':
                container_class = GridSizerContainer
            elif container_type_name == 'FlexGridSizer':
                container_class = FlexGridSizerContainer            
            elif container_type_name == 'GridBagSizer':
                container_class = GridBagSizerContainer             
            elif container_type_name == 'StaticBox':
                container_class = StaticBoxContainer   
            elif container_type_name == 'WarpSizer':
                container_class = WarpSizerContainer  
            else:
                raise Exception('Unregistered container.')          
            #print 'CreateContainer:', container_class, args, kwargs
            if not args:
                #print 'self.mainpanel:', self.mainpanel
                parent = self.mainpanel
            else:
                parent = args[0]
            container = container_class(parent, **kwargs)
            #print 'CreateContainer fim'
            return container
        except:
            raise
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs): 
        if not kwargs:
            kwargs = {'sizer_class': wx.GridBagSizer}
        else:
            kwargs['sizer_class'] = wx.GridBagSizer
        super(GridBagSizerContainer, self).__init__(*args, **kwargs)
项目:pywatch    作者:jackburridge    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"Selection Frame", pos=wx.DefaultPosition,
                          size=wx.Size(500, 300), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
        self.model = WatchableDict()
        self.model["selection"] = 1
        self.model["list"] = [u"One", u"Two", u"Three"]
        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

        sizer = wx.BoxSizer(wx.VERTICAL)

        gb_sizer = wx.GridBagSizer(5, 5)
        gb_sizer.SetFlexibleDirection(wx.BOTH)
        gb_sizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        choices = []
        self.combo_box = wx.ComboBox(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize,
                                     choices, 0)
        gb_sizer.Add(self.combo_box, wx.GBPosition(0, 0), wx.GBSpan(1, 1), wx.EXPAND, 5)
        pywatch.wx.ItemContainerItemWatcher(self.combo_box, self.model, "list")
        pywatch.wx.SelectionChanger(self.combo_box, self.model, "selection")

        self.choice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choices, 0)
        self.choice.SetSelection(0)
        gb_sizer.Add(self.choice, wx.GBPosition(1, 0), wx.GBSpan(1, 1), wx.EXPAND, 5)
        pywatch.wx.ItemContainerItemWatcher(self.choice, self.model, "list")
        pywatch.wx.SelectionChanger(self.choice, self.model, "selection")

        self.list_box = wx.ListBox(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choices, 0)
        gb_sizer.Add(self.list_box, wx.GBPosition(2, 0), wx.GBSpan(1, 1), wx.EXPAND, 5)
        pywatch.wx.ItemContainerItemWatcher(self.list_box, self.model, "list")
        pywatch.wx.SelectionChanger(self.list_box, self.model, "selection")

        self.radio_box = wx.RadioBox(self, wx.ID_ANY, u"Radio Box", wx.DefaultPosition, wx.DefaultSize,
                                     [u"One", u"Two", u"Three"], 1, wx.RA_SPECIFY_COLS)
        self.radio_box.SetSelection(0)
        gb_sizer.Add(self.radio_box, wx.GBPosition(3, 0), wx.GBSpan(1, 1), wx.EXPAND, 5)
        pywatch.wx.SelectionChanger(self.radio_box, self.model, "selection")


        gb_sizer.AddGrowableCol(0)
        gb_sizer.AddGrowableRow(2)

        sizer.Add(gb_sizer, 1, wx.EXPAND | wx.ALL, 5)

        self.SetSizer(sizer)
        self.Layout()

        self.Centre(wx.BOTH)
项目:pywatch    作者:jackburridge    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"List Editor", pos=wx.DefaultPosition,
                          size=wx.Size(500, 300), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)

        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

        sizer = wx.BoxSizer(wx.VERTICAL)

        gb_sizer = wx.GridBagSizer(5, 5)
        gb_sizer.SetFlexibleDirection(wx.BOTH)
        gb_sizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        list_boxChoices = []
        self.list_box = wx.ListBox(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, list_boxChoices, 0)
        gb_sizer.Add(self.list_box, wx.GBPosition(0, 0), wx.GBSpan(1, 2), wx.EXPAND, 0)

        self.add_button = wx.Button(self, wx.ID_ANY, u"Add", wx.DefaultPosition, wx.DefaultSize, 0)
        gb_sizer.Add(self.add_button, wx.GBPosition(1, 0), wx.GBSpan(1, 1), wx.EXPAND, 0)

        self.remove_button = wx.Button(self, wx.ID_ANY, u"Remove", wx.DefaultPosition, wx.DefaultSize, 0)
        gb_sizer.Add(self.remove_button, wx.GBPosition(1, 1), wx.GBSpan(1, 1), wx.EXPAND, 0)

        self.text_ctrl = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
        gb_sizer.Add(self.text_ctrl, wx.GBPosition(2, 0), wx.GBSpan(1, 2), wx.EXPAND, 0)

        gb_sizer.AddGrowableCol(0)
        gb_sizer.AddGrowableCol(1)
        gb_sizer.AddGrowableRow(0)

        sizer.Add(gb_sizer, 1, wx.EXPAND | wx.ALL, 5)

        self.SetSizer(sizer)
        self.Layout()

        self.Centre(wx.BOTH)

        self.add_button.Bind(wx.EVT_BUTTON, self.on_add)
        self.remove_button.Bind(wx.EVT_BUTTON, self.on_remove)

        self.model = WatchableDict()
        self.model["list"] = ["one", "two", "three", "four"]
        self.model["selection"] = 0

        pywatch.wx.ItemContainerItemWatcher(self.list_box, self.model, "list")
        pywatch.wx.SelectionChanger(self.list_box, self.model, "selection")

        def getter():
            return self.model["list"][self.model["selection"]]

        def setter(value):
            self.model["list"][self.model["selection"]] = value

        pywatch.wx.ValueChanger(self.text_ctrl, self.model, ("list", "selection", setter, getter))
项目:pywatch    作者:jackburridge    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"List Frame", pos=wx.DefaultPosition,
                          size=wx.Size(500, 300), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)

        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

        sizer = wx.BoxSizer(wx.VERTICAL)

        gb_sizer = wx.GridBagSizer(5, 5)
        gb_sizer.SetFlexibleDirection(wx.BOTH)
        gb_sizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        list_boxChoices = []
        self.list_box = wx.ListBox(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, list_boxChoices, 0)
        gb_sizer.Add(self.list_box, wx.GBPosition(0, 0), wx.GBSpan(1, 2), wx.EXPAND, 0)

        combo_boxChoices = []
        self.combo_box = wx.ComboBox(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize,
                                     combo_boxChoices, 0)
        gb_sizer.Add(self.combo_box, wx.GBPosition(1, 0), wx.GBSpan(1, 2), wx.EXPAND, 0)

        choiceChoices = []
        self.choice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choiceChoices, 0)
        self.choice.SetSelection(0)
        gb_sizer.Add(self.choice, wx.GBPosition(2, 0), wx.GBSpan(1, 2), wx.EXPAND, 0)

        self.text_ctrl = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize,
                                     wx.TE_PROCESS_ENTER)
        gb_sizer.Add(self.text_ctrl, wx.GBPosition(3, 0), wx.GBSpan(1, 1), wx.EXPAND, 0)

        self.button = wx.Button(self, wx.ID_ANY, u"Add", wx.DefaultPosition, wx.DefaultSize, 0)
        gb_sizer.Add(self.button, wx.GBPosition(3, 1), wx.GBSpan(1, 1), wx.ALL, 0)

        gb_sizer.AddGrowableCol(0)
        gb_sizer.AddGrowableRow(0)

        sizer.Add(gb_sizer, 1, wx.EXPAND | wx.ALL, 5)

        self.SetSizer(sizer)
        self.Layout()

        self.Centre(wx.BOTH)

        # Connect Events
        self.button.Bind(wx.EVT_BUTTON, self.on_add)
        self.text_ctrl.Bind(wx.EVT_TEXT_ENTER, self.on_add)

        self.model = WatchableDict()
        self.model["list"] = []
        self.model["text"] = ""
        pywatch.wx.ValueChanger(self.text_ctrl, self.model, "text")
        pywatch.wx.ItemContainerItemWatcher(self.list_box, self.model, "list")
        pywatch.wx.ItemContainerItemWatcher(self.choice, self.model, "list")
        pywatch.wx.ItemContainerItemWatcher(self.combo_box, self.model, "list")

    # Virtual event handlers, overide them in your derived class