def __init__(self, parent, app): super(TopBarRight, self).__init__(parent) self._app = app self._settingsButton = TopBarButton(self, 'Settings') self._helpButton = TopBarButton(self, 'Help') self.SetBackgroundColour((214, 214, 214)) #TODO; extract this from a color setting file instead of hard coding it. sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(wx.Panel(self), 1, flag=wx.EXPAND) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(wx.Panel(self, size=(10, 1)), 0, flag=wx.EXPAND) sizer.Add(wx.StaticText(self, label='View settings'), 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.Panel(self, size=(10, 1)), 0, flag=wx.EXPAND) viewOptions = [_('Normal'), _('Toolpaths')] self._view_mode_combo = wx.ComboBox(self, value=viewOptions[0], choices=viewOptions, style=wx.CB_DROPDOWN|wx.CB_READONLY) sizer.Add(self._view_mode_combo, 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.Panel(self, size=(10, 1)), 0, flag=wx.EXPAND) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(self._settingsButton, 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(self._helpButton, 0, flag=wx.ALIGN_CENTER_VERTICAL) self.SetSizer(sizer) self.SetMinSize((-1, 39)) self._view_mode_combo.Bind(wx.EVT_COMBOBOX, self._onViewChange) self.Bind(wx.EVT_BUTTON, self.onPreferences, self._settingsButton)
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, style=wx.SIMPLE_BORDER) self._tools_panel.SetBackgroundColour((214, 214, 214)) sizer.Add(self._tools_panel, flag=wx.EXPAND) sizer = wx.BoxSizer(wx.HORIZONTAL) self._tools_panel.SetSizer(sizer) firstButton = True for tool in self._app.getTools(): if tool.hasActiveButton(): if firstButton: firstButton = False else: sizer.Add(wx.StaticBitmap(self._tools_panel, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) button = ToolButton(self._tools_panel, tool.getName(), tool.getButtonIconName(), size=(53,38)) button.tool = tool button.Bind(wx.EVT_BUTTON, self.onToolButton) sizer.Add(button) self._buttons.append(button)
def bind(self): if self._texture is None: global contextSource self._contextSource = contextSource self._texture = glGenTextures(1) glBindTexture(GL_TEXTURE_2D, self._texture) if self._filter == 'linear': glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) else: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) img = wx.ImageFromBitmap(getBitmap(self._filename)) rgbData = img.GetData() alphaData = img.GetAlphaData() if alphaData is not None: data = '' for i in xrange(0, len(alphaData)): data += rgbData[i * 3:i * 3 + 3] + alphaData[i] glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.GetWidth(), img.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, data) else: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.GetWidth(), img.GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, rgbData) glBindTexture(GL_TEXTURE_2D, 0) glEnable(GL_TEXTURE_2D) glBindTexture(GL_TEXTURE_2D, self._texture)
def __init__(self, parent, app): super(FileBrowserPanel, self).__init__(parent) self._app = app self.SetSize((185, 400)) self._local_file_panel = wx.Panel(self) self._machine_button = MachineButton(self, app) self._load_button = wx.StaticBitmap(self._local_file_panel, bitmap=getBitmap('icon_open_model.png')) self._local_file_list = wx.ListBox(self._local_file_panel, size=(164, 248)) sizer = wx.GridBagSizer(2, 2) sizer.Add(self._load_button, (0, 0), border=10, flag=wx.LEFT|wx.RIGHT|wx.TOP|wx.ALIGN_RIGHT) sizer.Add(self._local_file_list, (1, 0), border=10, flag=wx.LEFT|wx.RIGHT|wx.BOTTOM) self._local_file_panel.SetSizer(sizer) self._load_button.Bind(wx.EVT_LEFT_DOWN, self._onLoadFile) self._local_file_list.Bind(wx.EVT_LEFT_DCLICK, self._onLocalFileDoubleClick) sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) sizer.Add(InnerTitleBar(self, 'File browsing'), flag=wx.EXPAND) sizer.Add(self._local_file_panel) sizer.Add(self._machine_button, flag=wx.EXPAND) t = Thread(target=self._watchPathsThread) t.daemon = True t.start()
def __init__(self, parent, label, icon): icon = 'icon_resolution.png' self._icon = getBitmap(icon) self._small = False super(ProfileCategoryButton, self).__init__(parent, label=label, style=wx.BORDER_NONE) self.Bind(wx.EVT_ENTER_WINDOW, self._onEnter, self) self.Bind(wx.EVT_LEAVE_WINDOW, self._onExit, self)
def onEraseBackground(self, evt): dc = evt.GetDC() if not dc: dc = wx.ClientDC(self) rect = self.GetUpdateRegion().GetBox() dc.SetClippingRect(rect) w, h = self.GetSizeTuple() dc.DrawBitmap(getBitmap("InnerTitleBar.png"), 0, 0) if self._icon is not None: icon = getBitmap(self._icon) dc.DrawBitmap(icon, w - icon.GetSize().GetWidth() - 16, (h - icon.GetSize().GetHeight()) / 2) if not self._small: dc.SetTextForeground(wx.WHITE) dc.SetFont(wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)) tw, th = dc.GetTextExtent(self._caption) dc.DrawText(self._caption, (w - tw) / 2, (h - th) / 2)
def OnPaint(self, event): (width, height) = self.GetClientSizeTuple() dc = wx.PaintDC(self) brush = self.GetBackgroundBrush(dc) if brush is not None: dc.SetBackground(brush) dc.Clear() bitmap = getBitmap(self._image) dc.DrawBitmap(bitmap, (width - bitmap.GetWidth()) / 2, (height - bitmap.GetHeight()) / 2)
def __init__(self, parent, app): super(TopBarRight, self).__init__(parent) self._app = app self._settingsButton = TopBarButton(self, 'Settings') self._helpButton = TopBarButton(self, 'Help') self.SetBackgroundColour( (214, 214, 214) ) #TODO; extract this from a color setting file instead of hard coding it. sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(wx.Panel(self), 1, flag=wx.EXPAND) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(wx.Panel(self, size=(10, 1)), 0, flag=wx.EXPAND) sizer.Add(wx.StaticText(self, label='View settings'), 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.Panel(self, size=(10, 1)), 0, flag=wx.EXPAND) sizer.Add(wx.ComboBox(self, style=wx.CB_DROPDOWN | wx.CB_READONLY), 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.Panel(self, size=(10, 1)), 0, flag=wx.EXPAND) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(self._settingsButton, 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(self._helpButton, 0, flag=wx.ALIGN_CENTER_VERTICAL) self.SetSizer(sizer) self.SetMinSize((-1, 39)) self.Bind(wx.EVT_BUTTON, self.onPreferences, self._settingsButton)
def OnPaint(self, event): """ Rendering of the button. """ (width, height) = self.GetClientSizeTuple() dc = wx.BufferedPaintDC(self) brush = self.GetBackgroundBrush(dc) if brush is not None: dc.SetBackground(brush) dc.Clear() #Draw border around active categories if not self.up: b = getBitmap('category_select_left.png') dc.DrawBitmap(b, 9, (height - b.GetHeight()) / 2) b = getBitmap('category_select_right.png') dc.DrawBitmap(b, width - 12, (height - b.GetHeight()) / 2) b = getBitmap('category_select_background.png') for n in xrange(11, width - 12): dc.DrawBitmap(b, n, (height - b.GetHeight()) / 2) b = self._icon dc.DrawBitmap(b, 22 - b.GetWidth() / 2, (height - b.GetHeight()) / 2) if not self._small: self.DrawLabel(dc, width, height)
def __init__(self, parent, app): super(TopBarLeft, self).__init__(parent) self._app = app self._3dViewButton = TopBarButton(self, '3D', size=(38, 38)) self._rightViewButton = TopBarButton(self, 'Right', size=(38, 38)) self._frontViewButton = TopBarButton(self, 'Front', size=(38, 38)) self._topViewButton = TopBarButton(self, 'Top', size=(38, 38)) self._3dViewButton.SetValue(True) self.SetBackgroundColour( (214, 214, 214) ) #TODO; extract this from a color setting file instead of hard coding it. sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('small_logo.png')), 0, flag=wx.EXPAND) sizer.Add(wx.Panel(self, size=(100, 1)), 0, flag=wx.EXPAND) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(self._3dViewButton, 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(self._rightViewButton, 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(self._frontViewButton, 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(self._topViewButton, 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(wx.Panel(self), 1, flag=wx.EXPAND) self.SetSizer(sizer) self.SetMinSize((-1, 39)) self.Bind(wx.EVT_BUTTON, lambda e: self._setViewDirection('3D'), self._3dViewButton) self.Bind(wx.EVT_BUTTON, lambda e: self._setViewDirection('Right'), self._rightViewButton) self.Bind(wx.EVT_BUTTON, lambda e: self._setViewDirection('Front'), self._frontViewButton) self.Bind(wx.EVT_BUTTON, lambda e: self._setViewDirection('Top'), self._topViewButton)
def OnPaint(self, event): (width, height) = self.GetClientSizeTuple() dc = wx.BufferedPaintDC(self) fillWidth = width * self._fillAmount if fillWidth < width: dc.GradientFillLinear((fillWidth, 0, width - fillWidth, height), self._colorTopGray, self._colorBottomGray, wx.SOUTH) dc.GradientFillLinear((0, 0, fillWidth, height), self._colorTop, self._colorBottom, wx.SOUTH) dc.SetPen(wx.Pen((102, 102, 102))) dc.SetBrush(wx.Brush('#ffffff', wx.TRANSPARENT)) dc.DrawRectangle(0, 0, width, height) icon = getBitmap(self._icon) if not self._small: dc.SetFont(self.GetFont()) label = self.GetLabel() tw, th = dc.GetTextExtent(label) icon_spacing = 8 if self._icon_align == wx.ALIGN_RIGHT: x = (width - tw - icon.GetWidth() - icon_spacing) / 2 else: x = (width - tw - icon.GetWidth() - icon_spacing) / 2 + icon.GetWidth() + icon_spacing dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)) dc.DrawText(label, x + 1, (height-th)/2 + 1) if self.IsEnabled(): dc.SetTextForeground(self.GetForegroundColour()) else: dc.SetTextForeground((64, 64, 64)) dc.DrawText(label, x, (height-th)/2) dc.DrawText(label, x, (height-th)/2) if self._icon_align == wx.ALIGN_RIGHT: dc.DrawBitmap(icon, x + tw + icon_spacing, (height - icon.GetHeight()) / 2) else: dc.DrawBitmap(icon, x - icon.GetWidth() - icon_spacing, (height - icon.GetHeight()) / 2) else: dc.DrawBitmap(icon, (width - icon.GetWidth()) / 2, (height - icon.GetHeight()) / 2)
def __init__(self, parent, app): super(TopBarLeft, self).__init__(parent) self._app = app self._3dViewButton = TopBarButton(self, '3D', size=(38, 38)) self._rightViewButton = TopBarButton(self, 'Right', size=(38, 38)) self._frontViewButton = TopBarButton(self, 'Front', size=(38, 38)) self._topViewButton = TopBarButton(self, 'Top', size=(38, 38)) self._3dViewButton.SetValue(True) self.SetBackgroundColour((214, 214, 214)) #TODO; extract this from a color setting file instead of hard coding it. sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('small_logo.png')), 0, flag=wx.EXPAND) sizer.Add(wx.Panel(self, size=(100, 1)), 0, flag=wx.EXPAND) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(self._3dViewButton, 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(self._rightViewButton, 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(self._frontViewButton, 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(self._topViewButton, 0, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(wx.StaticBitmap(self, bitmap=getBitmap('top_bar_line.png')), 0, flag=wx.EXPAND) sizer.Add(wx.Panel(self), 1, flag=wx.EXPAND) self.SetSizer(sizer) self.SetMinSize((-1, 39)) self.Bind(wx.EVT_BUTTON, lambda e: self._setViewDirection('3D'), self._3dViewButton) self.Bind(wx.EVT_BUTTON, lambda e: self._setViewDirection('Right'), self._rightViewButton) self.Bind(wx.EVT_BUTTON, lambda e: self._setViewDirection('Front'), self._frontViewButton) self.Bind(wx.EVT_BUTTON, lambda e: self._setViewDirection('Top'), self._topViewButton)
def _addPrinterButton(self, image_name, next_page): printer = GenBitmapToggleButton(self, -1, getBitmap(image_name)) self.GetSizer().Add(printer, pos=(2 + int(len(self._printers) / 2), len(self._printers) % 2)) printer.Bind(wx.EVT_BUTTON, self._onPrinterSelect) printer.next_page = next_page self._printers.append(printer)
def __init__(self, parent, label, icon): icon = 'icon_resolution.png' self._icon = getBitmap(icon) self._small = False super(ProfileCategoryButton, self).__init__(parent, label=label, style=wx.BORDER_NONE)