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): 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')
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._buttons = [] self._panels = [] 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 b.Bind(wx.EVT_BUTTON, self.onCategoryButton) self._buttons.append(b) p = SettingPanel(self, self._app, c) self._panels.append(p) # 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._loadProfileButton.Hide() 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') self._updateSizer()
class ProfilePanel(FloatingPanel): """ Always visible side panel which contains all the categories from the machine settings. This panel can be collapsed into icons or used normal sized to have text as well as icons. """ def __init__(self, parent, app): super(ProfilePanel, self).__init__(parent) self._app = app self._buttons = [] self._panels = [] 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 b.Bind(wx.EVT_BUTTON, self.onCategoryButton) self._buttons.append(b) p = SettingPanel(self, self._app, c) self._panels.append(p) # 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._loadProfileButton.Hide() 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') self._updateSizer() def _updateSizer(self): sizer = self.GetSizer() for item in sizer.GetChildren(): sizer.Detach(item.GetWindow()) sizer.Add(self._titleBar, flag=wx.EXPAND) for n in xrange(0, len(self._buttons)): if not self._buttons[n].IsShown(): continue sizer.Add(self._buttons[n], flag=wx.EXPAND) if self._buttons[n].GetValue(): sizer.Add(self._panels[n], flag=wx.EXPAND) self._panels[n].Layout() self._panels[n].Show() else: self._panels[n].Hide() sizer.Add(self._saveButton, flag=wx.EXPAND) self.Parent.Layout() self.Layout() #because on linux the layout stuff doesn't bubble down. Screw you wxwidgets. def onSmallToggle(self, e): self.setSmall(not self._titleBar.isSmall()) self.Fit() self.Parent.Layout() self.Layout() #because on linux the layout stuff doesn't bubble down. Screw you wxwidgets. def setSmall(self, small): self._titleBar.setSmall(small) for button in self._buttons: button.setSmall(small) self._pluginsButton.setSmall(small) self._loadProfileButton.setSmall(small) self._saveButton.setSmall(small) if small: self._titleBar.setIcon('inner_title_bar_open_arrow.png') else: self._titleBar.setIcon('inner_title_bar_close_arrow.png') preferences.setPreference('profile_small', str(small)) def onCategoryButton(self, e): self._updateSizer() def onPluginButton(self, e): if self._pluginsButton.GetValue(): pass def onLoadProfileButton(self, e): self._loadProfileButton.SetValue(False)
class ProfilePanel(FloatingPanel): """ Always visible side panel which contains all the categories from the machine settings. This panel can be collapsed into icons or used normal sized to have text as well as icons. """ 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') def onSmallToggle(self, e): self.setSmall(not self._titleBar.isSmall()) self.Fit() self.Parent.Layout() self.Layout( ) #because on linux the layout stuff doesn't bubble down. Screw you wxwidgets. def setSmall(self, small): self._titleBar.setSmall(small) for button in self._categoryButtons: button.setSmall(small) self._pluginsButton.setSmall(small) self._loadProfileButton.setSmall(small) self._saveButton.setSmall(small) if small: self._titleBar.setIcon('inner_title_bar_open_arrow.png') else: self._titleBar.setIcon('inner_title_bar_close_arrow.png') preferences.setPreference('profile_small', str(small)) def onCategoryButton(self, e): button = e.GetEventObject() if not button.GetValue(): button = None for b in self._categoryButtons: if b != button: b.SetValue(False) self._pluginsButton.SetValue(False) if button is None: self._app.getMainWindow().closeSettings() else: self._app.getMainWindow().openSettingCategory(button) def onPluginButton(self, e): for b in self._categoryButtons: b.SetValue(False) self._app.getMainWindow().closeSettings() if self._pluginsButton.GetValue(): pass def onLoadProfileButton(self, e): self._loadProfileButton.SetValue(False)