def __init__(self, parent, app): self._app = app self._active_tool = None self._buttons = [] super(ToolsPanel, self).__init__(parent) self._main_panel = wx.Panel(self) self.SetSizer(wx.BoxSizer()) self.GetSizer().Add(self._main_panel, 1, flag=wx.EXPAND) sizer = wx.BoxSizer(wx.VERTICAL) self._main_panel.SetSizer(sizer) # TODO: Get tool panel title from app. sizer.Add(InnerTitleBar(self._main_panel, 'Transform model'), flag=wx.EXPAND) self._tools_panel = wx.Panel(self._main_panel) sizer.Add(self._tools_panel, flag=wx.EXPAND) sizer = wx.BoxSizer(wx.HORIZONTAL) self._tools_panel.SetSizer(sizer) for tool in self._app.getTools(): if tool.hasActiveButton(): button = ToolButton(self._tools_panel, size=(53,38)) button.tool = tool button.Bind(wx.EVT_BUTTON, self.onToolButton) sizer.Add(button) self._buttons.append(button)
def __init__(self, parent, app, category): super(SettingPanel, self).__init__(parent) self._app = app sizer = wx.GridBagSizer(2, 2) sizer.Add(InnerTitleBar(self, category.getLabel()), pos=(0, 0), span=(1, 4), flag=wx.EXPAND) n = 1 for s in category.getSettings(): if not s.isVisible(): continue flag = wx.EXPAND if s.getType() == 'float' or s.getType() == 'int': ctrl = wx.TextCtrl(self, value=s.getValue()) ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange) elif s.getType() == 'bool': ctrl = wx.CheckBox(self, style=wx.ALIGN_RIGHT) ctrl.SetValue(s.getValue() == 'True') ctrl.Bind(wx.EVT_CHECKBOX, self.OnSettingChange) flag = 0 elif isinstance(s.getType(), dict): try: value = s.getType()[s.getValue()] except KeyError: value = s.getType().values()[0] ctrl = wx.ComboBox(self, value=value, choices=s.getType().values(), style=wx.CB_DROPDOWN | wx.CB_READONLY) ctrl.Bind(wx.EVT_COMBOBOX, self.OnSettingChange) ctrl.Bind(wx.EVT_LEFT_DOWN, self.OnMouseExit) else: print 'Unknown settings type:', s.getType() ctrl = wx.TextCtrl(self, value=s.getValue()) ctrl.setting = s sizer.Add(wx.Panel(self, size=(10, 10)), pos=(n, 0), span=(1, 1)) sizer.Add(wx.StaticText(self, label=s.getLabel()), pos=(n, 1), span=(1, 1), flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(ctrl, pos=(n, 2), span=(1, 1), flag=flag) sizer.Add(wx.Panel(self, size=(10, 10)), pos=(n, 3), span=(1, 1)) ctrl.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) ctrl.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseExit) n += 1 sizer.Add(wx.Panel(self, size=(3, 3)), pos=(n, 0), span=(1, 4)) self.SetSizer(sizer)
def __init__(self, parent, app): super(ProfilePanel, self).__init__(parent) self._app = app self._categoryButtons = [] sizer = wx.BoxSizer(wx.VERTICAL) self._titleBar = InnerTitleBar(self, 'Profile') self._titleBar.Bind(wx.EVT_LEFT_DOWN, self.onSmallToggle) sizer.Add(self._titleBar, flag=wx.EXPAND) n = 0 for c in self._app.getMachine().getSettingCategories(): if not c.isVisible(): continue # Filter out categories that do not have visible settings. if len(filter(lambda s: s.isVisible(), c.getSettings())) < 1: continue b = ProfileCategoryButton(self, c.getLabel(), c.getIcon()) b.category = c sizer.Add(b, flag=wx.EXPAND) b.Bind(wx.EVT_BUTTON, self.onCategoryButton) self._categoryButtons.append(b) n += 1 if n % 4 == 0: sizer.Add(wx.StaticLine(self), flag=wx.EXPAND) self._pluginsButton = ProfileCategoryButton(self, 'Plugins', 'icon_plugin.png') self._pluginsButton.Hide() self._loadProfileButton = ProfileCategoryButton( self, 'Load profile', 'icon_load_profile.png') self._saveButton = PrintSaveButton(self, app) self._pluginsButton.Bind(wx.EVT_BUTTON, self.onPluginButton) self._loadProfileButton.Bind(wx.EVT_BUTTON, self.onLoadProfileButton) sizer.Add(self._pluginsButton, flag=wx.EXPAND) sizer.Add(self._loadProfileButton, flag=wx.EXPAND) sizer.Add(self._saveButton, flag=wx.EXPAND) self.SetSizer(sizer) self.setSmall( preferences.getPreference('profile_small', 'False') == 'True')