Python wx.GridBagSizer() Examples
The following are 16
code examples of wx.GridBagSizer().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: optionsframe.py From youtube-dl-gui with The Unlicense | 6 votes |
def _build_playlist_sizer(self): playlist_box_sizer = wx.StaticBoxSizer(self.playlist_box, wx.VERTICAL) playlist_box_sizer.AddSpacer((-1, 10)) border = wx.GridBagSizer(5, 40) border.Add(self.playlist_start_label, (0, 0), flag=wx.ALIGN_CENTER_VERTICAL) border.Add(self.playlist_start_spinctrl, (0, 1)) border.Add(self.playlist_stop_label, (1, 0), flag=wx.ALIGN_CENTER_VERTICAL) border.Add(self.playlist_stop_spinctrl, (1, 1)) border.Add(self.playlist_max_label, (2, 0), flag=wx.ALIGN_CENTER_VERTICAL) border.Add(self.playlist_max_spinctrl, (2, 1)) playlist_box_sizer.Add(border, flag=wx.ALIGN_CENTER) return playlist_box_sizer
Example #2
Source File: optionsframe.py From youtube-dl-gui with The Unlicense | 6 votes |
def _build_filesize_sizer(self): filesize_box_sizer = wx.StaticBoxSizer(self.filesize_box, wx.VERTICAL) border = wx.GridBagSizer(5, 20) border.Add(self.filesize_max_label, (0, 0), (1, 2), wx.ALIGN_CENTER_HORIZONTAL) border.Add(self.filesize_max_spinctrl, (1, 0)) border.Add(self.filesize_max_sizeunit_combobox, (1, 1)) border.Add(self.filesize_min_label, (2, 0), (1, 2), wx.ALIGN_CENTER_HORIZONTAL) border.Add(self.filesize_min_spinctrl, (3, 0)) border.Add(self.filesize_min_sizeunit_combobox, (3, 1)) filesize_box_sizer.Add(border, flag=wx.ALIGN_CENTER) return filesize_box_sizer
Example #3
Source File: welcome.py From DeepLabCut with GNU Lesser General Public License v3.0 | 6 votes |
def __init__(self, parent, gui_size): h = gui_size[0] w = gui_size[1] wx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER, size=(h, w)) ## design the panel sizer = wx.GridBagSizer(10, 7) # Add image of DLC icon = wx.StaticBitmap(self, bitmap=wx.Bitmap(dlc)) sizer.Add(icon, pos=(0, 0), span=(0, 8), flag=wx.EXPAND | wx.BOTTOM, border=10) line = wx.StaticLine(self) sizer.Add(line, pos=(1, 0), span=(1, 8), flag=wx.EXPAND | wx.BOTTOM, border=10) # if editing this text make sure you add the '\n' to get the new line. The sizer is unable to format lines correctly. description = "DeepLabCut™ is an open source tool for markerless\npose estimation of user-defined body parts with deep learning.\nA. and M.W. Mathis Labs | http://www.deeplabcut.org\n \nWelcome to the DeepLabCut Project Manager GUI!\nTo get started, please click on the 'Manage Project'\n tab to create or load an existing project. \n " self.proj_name = wx.StaticText(self, label=description, style=wx.ALIGN_CENTRE) sizer.Add(self.proj_name, pos=(2, 3), border=10) sizer.AddGrowableCol(2) self.SetSizer(sizer) sizer.Fit(self)
Example #4
Source File: edit_sizers.py From wxGlade with MIT License | 6 votes |
def child_widget_created(self, child, level): "called from finish_widget_creation() to add widget to sizer widget" index = child.index if self._IS_GRIDBAG: # GridBagSizer: add at (row, col) position self.widget.Add( child.widget, index, child.span, child.flag, child.border, destroy=True ) else: # no GridBagSizer: add or insert at index position if index+self.widget._BTN_OFFSET>=len(self.widget.GetChildren()): self.widget.Add( child.widget, child.proportion, child.flag, child.border ) else: self.widget.Insert(index+self.widget._BTN_OFFSET, child.widget, child.proportion, child.flag, child.border) if child.check_prop("size"): # size has been set in set_size, so we can just use GetSize here self.set_item_best_size(child, size=child.widget.GetSize()) if self.widget: self.window.widget.Layout()
Example #5
Source File: ConfigPanel.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def AddGrid(self, grid, vgap=6, hgap=5): columns = self.maxRowNum sizer = wx.GridBagSizer(vgap, hgap) sizer.SetFlexibleDirection(wx.HORIZONTAL) rowFlagsGet = self.rowFlags.get colFlagsGet = self.colFlags.get for rowNum, (row, kwargs) in enumerate(grid): if kwargs.get("growable", False): sizer.AddGrowableRow(rowNum) for colNum, ctrl in enumerate(row): if ctrl is None: ctrl = (1, 1) elif type(ctrl) in types.StringTypes: ctrl = wx.StaticText(self, -1, ctrl) flags = rowFlagsGet(rowNum, 0) | colFlagsGet(colNum, 0) flags |= (wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT) sizer.Add(ctrl, (rowNum, colNum), (1, 1), flags) if colNum < columns - 1: sizer.SetItemSpan(ctrl, (1, columns - colNum + 1)) self.sizer.Add(sizer, 1, wx.EXPAND)
Example #6
Source File: guiminer.py From poclbm with GNU General Public License v3.0 | 5 votes |
def layout_init(self): """Create the sizers for this frame and set up the external text. Return the lowest row that is available. """ self.frame_sizer = wx.BoxSizer(wx.VERTICAL) self.frame_sizer.Add((20, 10), 0, wx.EXPAND, 0) # Controls top window size self.inner_sizer = wx.GridBagSizer(10, 5) # Controls inner window height, width self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) row = 0 # if self.is_external_miner: # self.inner_sizer.Add(self.external_lbl, (row, 0), flag=LBL_STYLE) # self.inner_sizer.Add(self.txt_external, (row, 1), span=(1, 3), flag=wx.EXPAND) # row += 1 return row
Example #7
Source File: live_demo.py From mr_saliency with GNU General Public License v2.0 | 5 votes |
def __init__(self,parent): wx.Panel.__init__(self,parent) #self.save = wx.Button(self,label="Save") #self.close = wx.Button(self,label="Close") self.close = wx.Button(self,wx.ID_CLOSE) self.close.Bind(wx.EVT_BUTTON, self.OnClose) self.sizer = wx.GridBagSizer(1,2) self.sizer.Add(self.close,(1,1)) #self.sizer.Add(self.close,(1,2,))
Example #8
Source File: edit_sizers.py From wxGlade with MIT License | 5 votes |
def set_overlap(self, overlapped=True, add_to_sizer=True): # interface from GridBagSizer; so self.parent is a sizer if overlapped==self.overlapped: return self.overlapped = overlapped sizer = self.parent if overlapped: if self.widget: self.parent.destroying_child_widget(self, self.index) self.destroy_widget(0) else: if sizer.widget and not self.widget: self.create_widget() if add_to_sizer: sizer.widget.Add(self.widget, self.index, self.span, wx.EXPAND, self.border) common.app_tree.refresh(self) # XXX indicate overlapped slots
Example #9
Source File: edit_sizers.py From wxGlade with MIT License | 5 votes |
def GetItem(self, widget): if hasattr(self._grid, "FindItem"): return self._grid.FindItem(widget) # GridBagSizer return self._grid.GetItem(widget)
Example #10
Source File: edit_sizers.py From wxGlade with MIT License | 5 votes |
def _create(self, rows, cols, vgap, hgap): self._grid = wx.GridBagSizer(vgap, hgap)
Example #11
Source File: systray.py From p2ptv-pi with MIT License | 4 votes |
def __init__(self, bgapp, icons): self.bgapp = bgapp self.user_profile = self.bgapp.user_profile wx.Dialog.__init__(self, None, -1, self.bgapp.appname + ' ' + self.bgapp.utility.lang.get('user_profile'), size=(400, 200), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.SetIcons(icons) grid = wx.GridBagSizer(hgap=5, vgap=8) grid.AddGrowableCol(1, 1) row = -1 row += 1 label = wx.StaticText(self, wx.ID_ANY, self.bgapp.utility.lang.get('gender')) self.ctrl_gender = wx.ComboBox(self, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN | wx.CB_READONLY) for id, name in self.user_profile.get_genders().iteritems(): name = self.bgapp.utility.lang.get(name) idx = self.ctrl_gender.Append(name, id) if id == self.user_profile.get_gender_id(): self.ctrl_gender.Select(idx) grid.Add(label, pos=(row, 0)) grid.Add(self.ctrl_gender, pos=(row, 1)) row += 1 label = wx.StaticText(self, wx.ID_ANY, self.bgapp.utility.lang.get('age')) self.ctrl_age = wx.ComboBox(self, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN | wx.CB_READONLY) ages = [] for id, name in self.user_profile.get_ages().iteritems(): if name.startswith('age_less'): priority = '' elif name.startswith('age_more'): priority = 'z' else: priority = name ages.append((priority, {'id': id, 'name': name})) for priority, age in sorted(ages): id = age['id'] name = age['name'] name = self.bgapp.utility.lang.get(name) idx = self.ctrl_age.Append(name, id) if id == self.user_profile.get_age_id(): self.ctrl_age.Select(idx) grid.Add(label, pos=(row, 0)) grid.Add(self.ctrl_age, pos=(row, 1)) btn_ok = wx.Button(self, wx.ID_OK, self.bgapp.utility.lang.get('ok')) btn_cancel = wx.Button(self, wx.ID_CANCEL, self.bgapp.utility.lang.get('cancel')) buttonbox = wx.BoxSizer(wx.HORIZONTAL) buttonbox.Add(btn_ok, 0, wx.ALL, 5) buttonbox.Add(btn_cancel, 0, wx.ALL, 5) mainbox = wx.BoxSizer(wx.VERTICAL) mainbox.Add(grid, 1, wx.EXPAND | wx.ALL, border=5) mainbox.Add(buttonbox, 0) self.SetSizerAndFit(mainbox) self.Show() self.Bind(wx.EVT_BUTTON, self.OnOK, btn_ok)
Example #12
Source File: optionsframe.py From youtube-dl-gui with The Unlicense | 4 votes |
def _set_layout(self): main_sizer = wx.BoxSizer(wx.HORIZONTAL) vertical_sizer = wx.BoxSizer(wx.VERTICAL) # Set up retries box retries_sizer = wx.BoxSizer(wx.HORIZONTAL) retries_sizer.Add(self.retries_label, flag=wx.ALIGN_CENTER_VERTICAL) retries_sizer.AddSpacer((20, -1)) retries_sizer.Add(self.retries_spinctrl) vertical_sizer.Add(retries_sizer, flag=wx.ALIGN_RIGHT | wx.TOP | wx.RIGHT, border=5) # Set up authentication box vertical_sizer.Add(self.auth_label, flag=wx.TOP, border=10) auth_sizer = wx.GridBagSizer(5, -1) auth_sizer.Add(self.username_label, (0, 0), flag=wx.ALIGN_CENTER_VERTICAL) auth_sizer.Add(self.username_textctrl, (0, 2)) auth_sizer.Add(self.password_label, (1, 0), flag=wx.ALIGN_CENTER_VERTICAL) auth_sizer.Add(self.password_textctrl, (1, 2)) auth_sizer.Add(self.video_pass_label, (2, 0), flag=wx.ALIGN_CENTER_VERTICAL) auth_sizer.Add(self.video_pass_textctrl, (2, 2)) auth_sizer.AddGrowableCol(1) vertical_sizer.Add(auth_sizer, flag=wx.EXPAND | wx.ALL, border=5) # Set up network box vertical_sizer.Add(self.network_label, flag=wx.TOP, border=10) network_sizer = wx.GridBagSizer(5, -1) network_sizer.Add(self.proxy_label, (0, 0), flag=wx.ALIGN_CENTER_VERTICAL) network_sizer.Add(self.proxy_textctrl, (0, 2)) network_sizer.Add(self.useragent_label, (1, 0), flag=wx.ALIGN_CENTER_VERTICAL) network_sizer.Add(self.useragent_textctrl, (1, 2)) network_sizer.Add(self.referer_label, (2, 0), flag=wx.ALIGN_CENTER_VERTICAL) network_sizer.Add(self.referer_textctrl, (2, 2)) network_sizer.AddGrowableCol(1) vertical_sizer.Add(network_sizer, flag=wx.EXPAND | wx.ALL, border=5) # Set up logging box vertical_sizer.Add(self.logging_label, flag=wx.TOP, border=10) logging_sizer = wx.BoxSizer(wx.HORIZONTAL) logging_sizer.Add(self.enable_log_checkbox) logging_sizer.AddSpacer((-1, -1), 1) logging_sizer.Add(self.view_log_button) logging_sizer.AddSpacer((5, -1)) logging_sizer.Add(self.clear_log_button) vertical_sizer.Add(logging_sizer, flag=wx.EXPAND | wx.ALL, border=5) main_sizer.Add(vertical_sizer, 1, wx.EXPAND | wx.ALL, border=5) self.SetSizer(main_sizer)
Example #13
Source File: activities_dashboard.py From grass-tangible-landscape with GNU General Public License v2.0 | 4 votes |
def __init__(self, parent, fontsize, maximum, title, formatting_string, vertical=False): wx.Frame.__init__(self, parent, style=wx.NO_BORDER) if isinstance(maximum, list): self.list_maximum = maximum self.list_title = title self.list_formatting_string = formatting_string else: self.list_maximum = [maximum] self.list_title = [title] self.list_formatting_string = [formatting_string] self.labels = [] self.titles = [] self.gauges = [] self.sizer = wx.GridBagSizer(5, 5) for i in range(len(self.list_maximum)): if vertical: if title: self.titles.append(wx.StaticText(self, label=self.list_title[i] + ':', style=wx.ALIGN_LEFT)) self.labels.append(wx.StaticText(self, style=wx.ALIGN_RIGHT)) self.gauges.append(wx.Gauge(self, range=self.list_maximum[i])) else: if title: self.titles.append(wx.StaticText(self, label=self.list_title[i], style=wx.ALIGN_CENTER)) self.labels.append(wx.StaticText(self, style=wx.ALIGN_CENTRE_HORIZONTAL)) self.gauges.append(wx.Gauge(self, range=self.list_maximum[i], style=wx.GA_VERTICAL)) font = wx.Font(fontsize, wx.DEFAULT, wx.NORMAL, wx.BOLD) self.labels[i].SetFont(font) if title: self.titles[i].SetFont(font) if vertical: if title: self.sizer.Add(self.titles[i], pos=(i, 0), flag=wx.ALL|wx.ALIGN_BOTTOM) self.sizer.Add(self.gauges[i], pos=(i, 1), flag=wx.ALL|wx.EXPAND) self.sizer.Add(self.labels[i], pos=(i, 2), flag=wx.ALL|wx.ALIGN_BOTTOM) else: if title: self.sizer.Add(self.titles[i], pos=(0, i), flag=wx.ALL|wx.ALIGN_CENTER) extra = wx.BoxSizer(wx.HORIZONTAL) extra.AddStretchSpacer() extra.Add(self.gauges[i], flag=wx.EXPAND) extra.AddStretchSpacer() self.sizer.Add(extra, pos=(1, i), flag=wx.ALL|wx.EXPAND) self.sizer.Add(self.labels[i], pos=(2, i), flag=wx.ALL|wx.ALIGN_CENTER) self.sizer.AddGrowableCol(i, 0) if vertical: self.sizer.AddGrowableCol(1, 1) else: self.sizer.AddGrowableRow(1) self.SetSizer(self.sizer) self.sizer.Fit(self)
Example #14
Source File: Slider.py From EventGhost with GNU General Public License v2.0 | 4 votes |
def __init__( self, parent, id = -1, value = None, min = None, max = None, pos = wx.DefaultPosition, size = wx.DefaultSize, style = 0, valueLabel = None, minLabel = None, maxLabel = None, levelCallback = None ): if minLabel is None: minLabel = str(min) if maxLabel is None: maxLabel = str(max) if valueLabel is None: valueLabel = "%(1)i" self.valueLabel = valueLabel self.levelCallback = levelCallback wx.Window.__init__(self, parent, id, pos, size, style) self.slider = wx.Slider( self, -1, value, min, max, style = style ) st1 = wx.StaticText(self, -1, minLabel) self.valueLabelCtrl = wx.StaticText(self, -1, valueLabel) st2 = wx.StaticText(self, -1, maxLabel) sizer = wx.GridBagSizer() sizer.AddMany([ (self.slider, (0, 0), (1, 3), wx.EXPAND), (st1, (1, 0), (1, 1), wx.ALIGN_LEFT), (self.valueLabelCtrl, (1, 1), (1, 1), wx.ALIGN_CENTER_HORIZONTAL), (st2, (1, 2), (1, 1), wx.ALIGN_RIGHT), ]) sizer.AddGrowableCol(1, 1) self.SetSizer(sizer) self.SetAutoLayout(True) sizer.Fit(self) self.Layout() self.SetMinSize(self.GetSize()) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_SCROLL, self.OnScrollChanged) self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus) self.OnScrollChanged()
Example #15
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 4 votes |
def __init__( self, parent, wxId=wx.ID_ANY, value=None, minValue=None, maxValue=None, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, valueLabel=None, minLabel=None, maxLabel=None, ): self.valueLabel = valueLabel wx.Window.__init__(self, parent, wxId, pos, size, style) sizer = wx.GridBagSizer() self.slider = wx.Slider( self, wx.ID_ANY, value, minValue, maxValue, style=style ) sizer.Add(self.slider, (0, 0), (1, 3), wx.EXPAND) st = wx.StaticText(self, wx.ID_ANY, minLabel) sizer.Add(st, (1, 0), (1, 1), wx.ALIGN_LEFT) self.valueLabelCtrl = wx.StaticText(self, wx.ID_ANY, valueLabel) sizer.Add( self.valueLabelCtrl, (1, 1), (1, 1), wx.ALIGN_CENTER_HORIZONTAL ) st = wx.StaticText(self, wx.ID_ANY, maxLabel) sizer.Add(st, (1, 2), (1, 1), wx.ALIGN_RIGHT) sizer.AddGrowableCol(1, 1) self.SetSizer(sizer) self.SetAutoLayout(True) sizer.Fit(self) self.Layout() self.SetMinSize(self.GetSize()) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_SCROLL, self.OnScrollChanged) self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus) self.OnScrollChanged()
Example #16
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 4 votes |
def Configure(self, x=0, y=0, displayNumber = None): text = self.text panel = eg.ConfigPanel() # enableDisplay = displayNumber is not None enableX = x is not None enableY = y is not None displayLabel = wx.StaticText(panel, -1, text.display) # displayCheckBox = wx.CheckBox(panel, -1, text.display) # displayCheckBox.SetValue(enableDisplay) if displayNumber is None: displayNumber = 0 displayChoice = eg.DisplayChoice(panel, displayNumber) # displayChoice.Enable(enableDisplay) xCheckBox = wx.CheckBox(panel, -1, text.text1) xCheckBox.SetValue(enableX) xCtrl = eg.SpinIntCtrl(panel, -1, 0 if not enableX else x, min=-32768, max=32767) xCtrl.Enable(enableX) yCheckBox = wx.CheckBox(panel, -1, text.text3) yCheckBox.SetValue(enableY) yCtrl = eg.SpinIntCtrl(panel, -1, 0 if not enableY else y, min=-32768, max=32767) yCtrl.Enable(enableY) monsCtrl = eg.MonitorsCtrl(panel, background = (224, 238, 238)) sizer = wx.GridBagSizer(vgap = 6, hgap = 5) sizer.Add(xCheckBox, (0, 0), (1, 1)) sizer.Add(xCtrl, (0, 1), (1, 1)) sizer.Add(wx.StaticText(panel, -1, text.text2), (0, 2), (1, 1)) sizer.Add(yCheckBox, (1, 0), (1, 1)) sizer.Add(yCtrl, (1, 1), (1, 1)) sizer.Add(wx.StaticText(panel, -1, text.text2), (1, 2), (1, 1)) sizer.Add(displayLabel, (2, 0), (1, 1), flag = wx.TOP, border = 18) sizer.Add(displayChoice, (2, 1), (1, 2), flag = wx.TOP, border = 17) panel.sizer.Add(sizer, 1, wx.EXPAND) panel.sizer.Add(monsCtrl) def HandleXCheckBox(event): xCtrl.Enable(event.IsChecked()) event.Skip() xCheckBox.Bind(wx.EVT_CHECKBOX, HandleXCheckBox) def HandleYCheckBox(event): yCtrl.Enable(event.IsChecked()) event.Skip() yCheckBox.Bind(wx.EVT_CHECKBOX, HandleYCheckBox) while panel.Affirmed(): panel.SetResult( xCtrl.GetValue() if xCtrl.IsEnabled() else None, yCtrl.GetValue() if yCtrl.IsEnabled() else None, displayChoice.GetValue() )