def layoutComponent(self): sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.header, 0, wx.EXPAND) sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND) sizer.Add(self.navbar, 1, wx.EXPAND) sizer.Add(self.console, 1, wx.EXPAND) sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND) sizer.Add(self.footer, 0, wx.EXPAND) self.SetMinSize((400, 300)) self.SetSize(self.buildSpec['default_size']) self.SetSizer(sizer) self.console.Hide() self.Layout() if self.buildSpec.get('fullscreen', True): self.ShowFullScreen(True) # Program Icon (Windows) icon = wx.Icon(self.buildSpec['images']['programIcon'], wx.BITMAP_TYPE_PNG) self.SetIcon(icon) if sys.platform != 'win32': # OSX needs to have its taskbar icon explicitly set # bizarrely, wx requires the TaskBarIcon to be attached to the Frame # as instance data (self.). Otherwise, it will not render correctly. self.taskbarIcon = TaskBarIcon(iconType=wx.adv.TBI_DOCK) self.taskbarIcon.SetIcon(icon)
def _do_layout(self): sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.head_panel, 0, wx.EXPAND) sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND) if self.build_spec['layout_type'] == 'column': self.config_panel = layouts.ColumnLayout( self, build_spec=self.build_spec) sizer.Add(self.config_panel, 1, wx.EXPAND) else: self.config_panel = layouts.FlatLayout(self, build_spec=self.build_spec) sizer.Add(self.config_panel, 1, wx.EXPAND) sizer.Add(self.runtime_display, 1, wx.EXPAND) self.runtime_display.Hide() sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND) sizer.Add(self.foot_panel, 0, wx.EXPAND) self.SetSizer(sizer) self.sizer = sizer pub.subscribe(self.myListener, "panelListener") pub.subscribe(self.load_view, events.WINDOW_CHANGE)
def _do_layout(self): STD_LAYOUT = (0, wx.LEFT | wx.RIGHT | wx.EXPAND, PADDING) container = wx.BoxSizer(wx.VERTICAL) container.AddSpacer(15) if self.title: container.Add(wx_util.h0(self, self.title), 0, wx.LEFT | wx.RIGHT, PADDING) container.AddSpacer(30) if self.widgets.required_args: container.Add(wx_util.h1(self, i18n._("required_args_msg")), 0, wx.LEFT | wx.RIGHT, PADDING) container.AddSpacer(5) container.Add(wx_util.horizontal_rule(self), *STD_LAYOUT) container.AddSpacer(20) self.CreateComponentGrid(container, self.widgets.required_args, cols=self._num_req_cols) container.AddSpacer(10) if self.widgets.optional_args: # container.AddSpacer(10) container.Add(wx_util.h1(self, i18n._("optional_args_msg")), 0, wx.LEFT | wx.RIGHT, PADDING) container.AddSpacer(5) container.Add(wx_util.horizontal_rule(self), *STD_LAYOUT) container.AddSpacer(20) self.CreateComponentGrid(container, self.widgets.optional_args, cols=self._num_opt_cols) self.SetSizer(container)
def layoutComponent(self): sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.header, 0, wx.EXPAND) sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND) sizer.Add(self.navbar, 1, wx.EXPAND) sizer.Add(self.console, 1, wx.EXPAND) sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND) sizer.Add(self.footer, 0, wx.EXPAND) self.SetMinSize((400, 300)) self.SetSize(self.buildSpec['default_size']) self.SetSizer(sizer) self.console.Hide() self.Layout() self.SetIcon(wx.Icon(self.buildSpec['images']['programIcon'], wx.BITMAP_TYPE_ICO))
def layoutComponent(self): sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.header, 0, wx.EXPAND) sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND) sizer.Add(self.navbar, 1, wx.EXPAND) sizer.Add(self.console, 1, wx.EXPAND) sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND) sizer.Add(self.footer, 0, wx.EXPAND) self.SetMinSize((400, 300)) self.SetSize(self.buildSpec['default_size']) self.SetSizer(sizer) self.console.Hide() self.Layout() self.SetIcon( wx.Icon(self.buildSpec['images']['programIcon'], wx.BITMAP_TYPE_ICO))
def _do_layout(self): sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.head_panel, 0, wx.EXPAND) sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND) if self.layout_type == layouts.COLUMN: self.config_panel = layouts.ColumnLayout(self) else: self.config_panel = layouts.FlatLayout(self) sizer.Add(self.config_panel, 1, wx.EXPAND) sizer.Add(self.runtime_display, 1, wx.EXPAND) self.runtime_display.Hide() sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND) sizer.Add(self.foot_panel, 0, wx.EXPAND) self.SetSizer(sizer) self.sizer = sizer
def makeGroup(self, parent, thissizer, group, *args): ''' Messily builds the (potentially) nested and grouped layout Note! Mutates `self.reifiedWidgets` in place with the widgets as they're instantiated! I cannot figure out how to split out the creation of the widgets from their styling without WxPython violently exploding TODO: sort out the WX quirks and clean this up. ''' # determine the type of border , if any, the main sizer will use if getin(group, ['options', 'show_border'], False): boxDetails = wx.StaticBox(parent, -1, group['name'] or '') boxSizer = wx.StaticBoxSizer(boxDetails, wx.VERTICAL) else: boxSizer = wx.BoxSizer(wx.VERTICAL) boxSizer.AddSpacer(10) if group['name']: boxSizer.Add(wx_util.h1(parent, group['name'] or ''), 0, wx.TOP | wx.BOTTOM | wx.LEFT, 8) group_description = getin(group, ['description']) if group_description: description = wx.StaticText(parent, label=group_description) boxSizer.Add(description, 0, wx.EXPAND | wx.LEFT, 10) # apply an underline when a grouping border is not specified if not getin(group, ['options', 'show_border'], False) and group['name']: boxSizer.Add(wx_util.horizontal_rule(parent), 0, wx.EXPAND | wx.LEFT, 10) ui_groups = self.chunkWidgets(group) for uigroup in ui_groups: sizer = wx.BoxSizer(wx.HORIZONTAL) for item in uigroup: widget = self.reifyWidget(parent, item) # !Mutate the reifiedWidgets instance variable in place self.reifiedWidgets.append(widget) sizer.Add(widget, 1, wx.ALL, 5) boxSizer.Add(sizer, 0, wx.ALL | wx.EXPAND, 5) # apply the same layout rules recursively for subgroups hs = wx.BoxSizer(wx.HORIZONTAL) for e, subgroup in enumerate(group['groups']): self.makeGroup(parent, hs, subgroup, 1, wx.ALL | wx.EXPAND, 5) if e % getin(group, ['options', 'columns'], 2) \ or e == len(group['groups']): boxSizer.Add(hs, *args) hs = wx.BoxSizer(wx.HORIZONTAL) thissizer.Add(boxSizer, *args)
def _do_layout(self): sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.head_panel, 0, wx.EXPAND) sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND) if self.build_spec['layout_type'] == 'column': self.config_panel = layouts.ColumnLayout(self, build_spec=self.build_spec) sizer.Add(self.config_panel, 1, wx.EXPAND) else: self.config_panel = layouts.FlatLayout(self, build_spec=self.build_spec) sizer.Add(self.config_panel, 1, wx.EXPAND) sizer.Add(self.runtime_display, 1, wx.EXPAND) self.runtime_display.Hide() sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND) sizer.Add(self.foot_panel, 0, wx.EXPAND) self.SetSizer(sizer) self.sizer = sizer pub.subscribe(self.myListener, "panelListener") pub.subscribe(self.load_view, events.WINDOW_CHANGE)
def layout(self, num_columns): STD_LAYOUT = (0, wx.LEFT | wx.RIGHT | wx.EXPAND, PADDING) if self.title: self.container.Add(wx_util.h0(self, self.title), 0, wx.LEFT | wx.RIGHT, PADDING) self.container.AddSpacer(30) if self.widgets: self.container.Add(wx_util.h1(self, self.section_name), 0, wx.LEFT | wx.RIGHT, PADDING) self.container.AddSpacer(5) self.container.Add(wx_util.horizontal_rule(self), *STD_LAYOUT) self.container.AddSpacer(20) self.create_component_grid(self.container, self.widgets, cols=num_columns) self.container.AddSpacer(10)
def layout(self): STD_LAYOUT = (0, wx.LEFT | wx.RIGHT | wx.EXPAND, PADDING) if self.title: self.container.Add(wx_util.h0(self, self.title), 0, wx.LEFT | wx.RIGHT, PADDING) self.container.AddSpacer(30) if self.widgets: self.container.Add(wx_util.h1(self, self.section_name), 0, wx.LEFT | wx.RIGHT, PADDING) self.container.AddSpacer(5) self.container.Add(wx_util.horizontal_rule(self), *STD_LAYOUT) self.container.AddSpacer(20) self.create_component_grid(self.container, self.widgets, cols=2) self.container.AddSpacer(10)
def makeGroup(self, parent, thissizer, group, *args): ''' Messily builds the (potentially) nested and grouped layout Note! Mutates `self.reifiedWidgets` in place with the widgets as they're instantiated! I cannot figure out how to split out the creation of the widgets from their styling without WxPython violently exploding TODO: sort out the WX quirks and clean this up. ''' # determine the type of border , if any, the main sizer will use if getin(group, ['options', 'show_border'], False): boxDetails = wx.StaticBox(parent, -1, self.getName(group) or '') boxSizer = wx.StaticBoxSizer(boxDetails, wx.VERTICAL) else: boxSizer = wx.BoxSizer(wx.VERTICAL) boxSizer.AddSpacer(10) if group['name']: groupName = wx_util.h1(parent, self.getName(group) or '') groupName.SetForegroundColour(getin(group, ['options', 'label_color'])) groupName.Bind(wx.EVT_LEFT_DOWN, notifyMouseEvent) boxSizer.Add(groupName, 0, wx.TOP | wx.BOTTOM | wx.LEFT, 8) group_description = getin(group, ['description']) if group_description: description = AutoWrappedStaticText(parent, label=group_description, target=boxSizer) description.SetForegroundColour(getin(group, ['options', 'description_color'])) description.SetMinSize((0, -1)) description.Bind(wx.EVT_LEFT_DOWN, notifyMouseEvent) boxSizer.Add(description, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10) # apply an underline when a grouping border is not specified # unless the user specifically requests not to show it if not getin(group, ['options', 'show_border'], False) and group['name'] \ and getin(group, ['options', 'show_underline'], True): boxSizer.Add(wx_util.horizontal_rule(parent), 0, wx.EXPAND | wx.LEFT, 10) ui_groups = self.chunkWidgets(group) for uigroup in ui_groups: sizer = wx.BoxSizer(wx.HORIZONTAL) for item in uigroup: widget = self.reifyWidget(parent, item) if not getin(item, ['options', 'visible'], True): widget.Hide() # !Mutate the reifiedWidgets instance variable in place self.reifiedWidgets.append(widget) sizer.Add(widget, 1, wx.ALL | wx.EXPAND, 5) boxSizer.Add(sizer, 0, wx.ALL | wx.EXPAND, 5) # apply the same layout rules recursively for subgroups hs = wx.BoxSizer(wx.HORIZONTAL) for e, subgroup in enumerate(group['groups']): self.makeGroup(parent, hs, subgroup, 1, wx.EXPAND) if len(group['groups']) != e: hs.AddSpacer(5) # self.makeGroup(parent, hs, subgroup, 1, wx.ALL | wx.EXPAND, 5) itemsPerColumn = getin(group, ['options', 'columns'], 2) if e % itemsPerColumn or (e + 1) == len(group['groups']): boxSizer.Add(hs, *args) hs = wx.BoxSizer(wx.HORIZONTAL) group_top_margin = getin(group, ['options', 'margin_top'], 1) marginSizer = wx.BoxSizer(wx.VERTICAL) marginSizer.Add(boxSizer, 1, wx.EXPAND | wx.TOP, group_top_margin) thissizer.Add(marginSizer, *args)