def DrawItem(self, mdc): # rect = self.GetRect() self.UpdateElementsPos(mdc) windowColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW) textColor = colorUtils.GetSuitableColor(windowColor, 1) mdc.SetTextForeground(textColor) mdc.DrawBitmap(self.dropShadowBitmap, self.shipBmpx + 1, self.shipBmpy + 1) mdc.DrawBitmap(self.shipBmp, self.shipBmpx, self.shipBmpy, 0) mdc.SetFont(self.fontBig) categoryName, fittings = self.fittingInfo mdc.DrawText(categoryName, self.catx, self.caty)
def OnPaint(self, evt): dc = wx.PaintDC(self) gc = wx.GraphicsContext.Create(dc) col1 = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DSHADOW) col2 = platebtn.AdjustColour(col1, -90) col1 = platebtn.AdjustColour(col1, 90) rect = self.GetClientRect() grad = gc.CreateLinearGradientBrush(0, 1, 0, rect.height - 1, col2, col1) pen_col = tuple( [min(190, x) for x in platebtn.AdjustColour(col1, -60)]) gc.SetPen(gc.CreatePen(wx.Pen(pen_col, 1))) gc.SetBrush(grad) gc.DrawRectangle(0, 1, rect.width - 0.5, rect.height - 0.5) evt.Skip()
def brushForNode(self, node, isSequentialNode=False, depth=0): ''' Create brush to use to display the given node ''' if node == self.selectedNode: color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT) else: color = self.adapter.background_color(node) if color: # The adapter returns a 3-tuple color = wx.Colour(*color) else: red = (depth * 10) % 255 green = 255 - ((depth * 10) % 255) blue = 200 color = wx.Colour(red, green, blue) if isSequentialNode: color.Set(color.Red(), color.Green(), color.Blue(), 128) return wx.Brush(color)
def Validate(self, win): textCtrl = self.GetWindow() text = textCtrl.GetValue() inRightFormat = self.checkEntry(text) if not inRightFormat: wx.MessageBox("Please check the format!", "Error") textCtrl.SetBackgroundColour("pink") textCtrl.SetFocus() textCtrl.Refresh() return False else: textCtrl.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) textCtrl.Refresh() return True
def Validate(self, win): """ Validate the contents of the given text control. """ textCtrl = self.GetWindow() text = textCtrl.GetValue() if self.stringlist.__contains__(text): textCtrl.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) textCtrl.Refresh() return True else: wx.MessageBox("The name is not defined!", "Error") textCtrl.SetBackgroundColour("pink") textCtrl.SetFocus() textCtrl.Refresh() return False
def Validate(self, win): """ Validate the contents of the given text control. """ textCtrl = self.GetWindow() text = textCtrl.GetValue() if len(text) == 0: wx.MessageBox("A text object must contain some text!", "Error") textCtrl.SetBackgroundColour("pink") textCtrl.SetFocus() textCtrl.Refresh() return False else: textCtrl.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) textCtrl.Refresh() return True
def default_draw(self, dc, rect, n): ''' If a subclass has not provided a "better" way to draw this item, use a default method of drawing here--which is just to str(the object) and draw an exapander arrow if the object is iterable. ''' # decide on a text color if self.IsSelected(n): fg = wx.SYS_COLOUR_HIGHLIGHTTEXT else: fg = wx.SYS_COLOUR_WINDOWTEXT dc.SetTextForeground(wx.SystemSettings_GetColour(fg)) # use GUI font font = default_font() dc.SetFont(font) # choose an expanded or collapsed triangle if self.model.is_expanded(n): tri = self.expandedTri else: tri = self.collapsedTri # triangles will be black dc.SetPen(wx.BLACK_PEN) dc.SetBrush(wx.BLACK_BRUSH) obj = self.model[n] xoffset = self.indent * self.model.depths[idfunc(obj)][0] yy = rect.y + (rect.height / 2) - (3) if hasattr(obj, 'expandable'): if obj.expandable(): dc.DrawPolygon([(x + rect.x + xoffset, y + yy) for (x, y) in tri]) else: if hasChildren(obj): dc.DrawPolygon([(x + rect.x + xoffset, y + yy) for (x, y) in tri]) icon = getattr(obj, 'icon', None) x = rect.x + 20 + xoffset if icon: dc.DrawBitmap(icon, rect.x + 20, rect.y + (rect.Height / 2 - icon.GetHeight() / 2)) x += icon.GetWidth() + 10 dc.DrawText(unicode(obj), x, rect.y + (rect.Height / 2 - GetFontHeight(font, dc) / 2))
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=CTRLBAR_STYLE_DEFAULT, name=CTRLBAR_NAME_STR): super(ControlBar, self).__init__(parent, id, pos, size, wx.TAB_TRAVERSAL | wx.NO_BORDER, name) tsz_orient = wx.HORIZONTAL msz_orient = wx.VERTICAL if style & CTRLBAR_STYLE_VERTICAL: tsz_orient = wx.VERTICAL msz_orient = wx.HORIZONTAL # Attributes self._style = style self._sizer = wx.BoxSizer(tsz_orient) self._tools = dict(simple=list()) self._spacing = (5, 5) # Drawing related color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE) if wx.Platform != '__WXMAC__': self._color2 = AdjustColour(color, 15) self._color = AdjustColour(color, -10) else: self._color2 = AdjustColour(color, 15) self._color = AdjustColour(color, -20) pcolor = tuple([min(190, x) for x in AdjustColour(self._color, -25)]) self._pen = wx.Pen(pcolor, 1) # Setup msizer = wx.BoxSizer(msz_orient) spacer = (0, 0) msizer.Add(spacer, 0) msizer.Add(self._sizer, 1, wx.EXPAND) msizer.Add(spacer, 0) self.SetSizer(msizer) # Event Handlers self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_BUTTON, self._DispatchEvent)
def SetProperties(self): # No resetting if the user is using the Settings Panel if self.useredited: return # Sets the colours for the two demos: called only if the user didn't # modify the colours and sizes using the Settings Panel bpArt = self.titleBar.GetBPArt() if self.agwStyle & bp.BP_USE_GRADIENT: # set the colour the text is drawn with bpArt.SetColour(bp.BP_TEXT_COLOUR, wx.WHITE) # These default to white and whatever is set in the system # settings for the wx.SYS_COLOUR_ACTIVECAPTION. We'll use # some specific settings to ensure a consistent look for the # demo. bpArt.SetColour(bp.BP_BORDER_COLOUR, wx.Colour(120, 23, 224)) bpArt.SetColour(bp.BP_GRADIENT_COLOUR_FROM, wx.Colour(60, 11, 112)) bpArt.SetColour(bp.BP_GRADIENT_COLOUR_TO, wx.Colour(120, 23, 224)) bpArt.SetColour(bp.BP_BUTTONTEXT_COLOUR, wx.Colour(70, 143, 255)) bpArt.SetColour(bp.BP_SEPARATOR_COLOUR, bp.BrightenColour(wx.Colour(60, 11, 112), 0.85)) bpArt.SetColour(bp.BP_SELECTION_BRUSH_COLOUR, wx.Colour(225, 225, 255)) bpArt.SetColour( bp.BP_SELECTION_PEN_COLOUR, wx.SystemSettings_GetColour(wx.SYS_COLOUR_ACTIVECAPTION)) else: background = self.titleBar.GetBackgroundColour() bpArt.SetColour(bp.BP_TEXT_COLOUR, wx.BLUE) bpArt.SetColour(bp.BP_BORDER_COLOUR, bp.BrightenColour(background, 0.85)) bpArt.SetColour(bp.BP_SEPARATOR_COLOUR, bp.BrightenColour(background, 0.85)) bpArt.SetColour(bp.BP_BUTTONTEXT_COLOUR, wx.BLACK) bpArt.SetColour(bp.BP_SELECTION_BRUSH_COLOUR, wx.Colour(242, 242, 235)) bpArt.SetColour(bp.BP_SELECTION_PEN_COLOUR, wx.Colour(206, 206, 195)) self.titleBar.SetStyle(self.agwStyle)
def Validate(self, widget): value = widget.GetValue() if value == "": widget.SetBackgroundColour("pink") widget.SetFocus() widget.Refresh() return u"\u2022 " + widget.GetName() + " es requerido \n" else: if not os.path.isdir(value): widget.SetBackgroundColour("pink") widget.SetFocus() widget.Refresh() return u"\u2022 " + widget.GetName() + " no existe\n" else: widget.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) widget.Refresh() return ""
def Validate(self, widget, min, max): value = widget.GetValue() if value == None: widget.SetBackgroundColour("pink") widget.SetFocus() widget.Refresh() return u"\u2022 " + widget.GetName() + " es requerido \n" else: if value < min or value > max: widget.SetBackgroundColour("pink") widget.SetFocus() widget.Refresh() return u"\u2022 " + widget.GetName() + " fuera de rango \n" else: widget.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) widget.Refresh() return ""
def set_background(self, value): oldval = self.background self.background = value if not self.widget: return value = value.strip() if value in ColorDialogProperty.str_to_colors: self.widget.SetBackgroundColour( wx.SystemSettings_GetColour( ColorDialogProperty.str_to_colors[value])) else: try: color = misc.string_to_color(value) self.widget.SetBackgroundColour(color) except: self.background = oldval self.properties['background'].set_value(self.get_background()) return self.widget.Refresh()
def OnDrawBackground(self, dc, rect, n): 'Draws the background for each item.' if self.native: if self.GetSelection() == n: dc.Brush = wx.Brush( wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT)) dc.Pen = wx.TRANSPARENT_PEN dc.DrawRectangleRect(rect) # s = 3 if self.GetSelection() == n else 1 # self.DrawNativeLike(dc,5,1,rect,self.DrawThemelessItemBG) else: if self.GetSelection() == n and self.selbg: self.selbg.Draw(dc, rect) elif self.itembg: self.itembg.Draw(dc, rect)
def ValidarUsuario(self, event): if self.frame.tc_usuario.GetValue() != "": self.mdlUsuarios.usuario = self.frame.tc_usuario.GetValue() if self.mdlUsuarios.existUser() == 1: self.frame.tc_usuario.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) self.frame.tc_usuario.Refresh() self.frame.tc_clave.SetFocus() else: self.frame.tc_usuario.SetBackgroundColour("pink") self.frame.tc_usuario.SetFocus() self.frame.tc_usuario.Refresh() else: self.frame.tc_usuario.SetBackgroundColour("pink") self.frame.tc_usuario.SetFocus() self.frame.tc_usuario.Refresh() event.Skip()
def Buscar(self, event): self.mdlArt.cam_anio = self.aCamp['anio'] self.mdlArt.cam_num = self.aCamp['numero'] cod = self.panelUno.tc_codigo.GetValue() self.mdlArt.cli_codigo = cod if self.mdlArt.exist(): self.panelUno.tc_codigo.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) self.panelUno.tc_codigo.SetFocus() self.panelUno.tc_codigo.Refresh() info = ControladorInformacion(self.frame, self.aCamp, cod) info.run() self.panelUno.tc_codigo.SelectAll() else: self.panelUno.tc_codigo.SetBackgroundColour("pink") self.panelUno.tc_codigo.SetFocus() self.panelUno.tc_codigo.Refresh() event.Skip()
def Enable(self, enable=True): if self.IsEnabled() is enable: return if self.IsEnabled(): self.__previous_enabled_bg_color = self.GetBackgroundColour() super(cPhraseWheelBase, self).Enable(enable) if enable is True: #self.SetBackgroundColour(color_prw_valid) self.SetBackgroundColour(self.__previous_enabled_bg_color) elif enable is False: self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BACKGROUND)) else: raise ValueError(u'<enable> must be True or False') self.Refresh()
def Validate(self, win): """ Validate the contents of the given text control. """ textCtrl = self.GetWindow() text = textCtrl.GetValue() if len(text) == 0: textCtrl.SetBackgroundColour("pink") textCtrl.Refresh() wx.MessageBox(self.msg, _("Error"), wx.ICON_ERROR) textCtrl.SetFocus() return False else: textCtrl.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) textCtrl.Refresh() return True
def __set_properties(self): # begin wxGlade: gui_lobby.__set_properties self.SetTitle("Omni - Not Connected") _icon = wx.EmptyIcon() _icon.CopyFromBitmap( wx.Bitmap("resource/spring-redlogo.png", wx.BITMAP_TYPE_ANY)) self.SetIcon(_icon) self.SetSize((804, 561)) self.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_BACKGROUND)) self.toolbar_lobby.SetToolBitmapSize((16, 16)) self.toolbar_lobby.Realize() self.list_lobby_1_games.SetMinSize((801, 150)) self.list_lobby_1_games.SetFont( wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Sans")) self.listbox_lobby_1_people.SetMinSize((200, 200)) self.button_lobby_1_send.Enable(False) self.button_lobby_1_send.SetDefault()
def Validate(self, win): print("doing Validate") textCtrl = self.GetWindow() text = textCtrl.GetValue() if len(text) == 0: print("textCtrl.Name:", textCtrl.Name) wx.MessageBox( "{} must contain some text!".format(str(textCtrl.Name)), "Error") textCtrl.SetBackgroundColour("pink") textCtrl.SetFocus() textCtrl.Refresh() return False else: textCtrl.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) textCtrl.Refresh() return True
def onScrollChanged(self, event): """ Change the scrolling coefficient, except if the validation fails. """ success = self.text_scroll.GetValidator().Validate(self.text_scroll) if success is False: return self.text_scroll.SetFocus() self.text_scroll.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) self.text_scroll.Refresh() try: v = float(self.text_scroll.GetValue()) self._prefsIO.SetValue('D_SCROLL', 'float', v) except Exception: pass
def Validate(self, win): tctrl = self.GetWindow() texto = tctrl.GetValue() if len(texto) == 0: tctrl.SetBackgroundColour("pink") tctrl.SetFocus() tctrl.Refresh() return False elif not self.isint(texto): tctrl.SetBackgroundColour("pink") tctrl.SetFocus() tctrl.Refresh() return False else: tctrl.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) tctrl.Refresh() return True
def onHZoomChanged(self, event): """ Change the horizontal zoom coefficient, except if the validation fails. """ success = self.text_h_zoom.GetValidator().Validate(self.text_h_zoom) if success is False: return self.text_h_zoom.SetFocus() self.text_h_zoom.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) self.text_h_zoom.Refresh() try: v = float(self.text_h_zoom.GetValue()) self._prefsIO.SetValue('D_H_ZOOM', 'float', v) except Exception: pass
def __init__(self, parent, handlerObj, model, id=wx.ID_ANY, **kwargs): self.parent = parent self.handlerObj = handlerObj self.showNotification = Signal('SearchModuleWindow.showNotification') wx.Panel.__init__(self, parent=parent, id=id, **kwargs) # tree self._tree = CTreeView(model=model, parent=self) self._tree.SetToolTipString( _("Double-click or Ctrl-Enter to run selected module")) # self._dataBox = wx.StaticBox(parent = self, id = wx.ID_ANY, # label = " %s " % _("Module tree")) # search widget self._search = SearchModuleWidget(parent=self, model=model, showChoice=False) self._search.showSearchResult.connect( lambda result: self._tree.Select(result)) self._search.showNotification.connect(self.showNotification) self._helpText = wx.StaticText( parent=self, id=wx.ID_ANY, label="Press Enter for next match, Ctrl+Enter to run command") self._helpText.SetForegroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_GRAYTEXT)) # buttons self._btnRun = wx.Button(self, id=wx.ID_OK, label=_("&Run")) self._btnRun.SetToolTipString(_("Run selected module from the tree")) # bindings self._btnRun.Bind(wx.EVT_BUTTON, lambda evt: self.Run()) self.Bind(wx.EVT_KEY_UP, self.OnKeyUp) self._tree.selectionChanged.connect(self.OnItemSelected) self._tree.itemActivated.connect(lambda node: self.Run(node)) self._layout() self._search.SetFocus()
def Validate(self, win): tctrl = self.GetWindow() texto = tctrl.GetValue() self.mdlUsuarios.usuario = texto if len(texto) == 0: tctrl.SetBackgroundColour("pink") tctrl.SetFocus() tctrl.Refresh() return False elif self.mdlUsuarios.existUser() != 1: tctrl.SetBackgroundColour("pink") tctrl.SetFocus() tctrl.Refresh() return False else: tctrl.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) tctrl.Refresh() return True
def onNameEntry(self, evt): tc = evt.GetEventObject() w = tc.GetValue().strip() if w == "": self.nameValid = False else: if w in self.names: self.nameValid = False else: self.nameValid = True if self.nameValid: tc.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) else: tc.SetBackgroundColour("pink") tc.Refresh() self.checkDlgValidity() evt.Skip()
def on_paint(self, event): color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE) dc = wx.BufferedPaintDC(self) dc.SetBackground(wx.Brush(color)) dc.Clear() dc = wx.GCDC(dc) if self.bitmap is None: return pad = 0 cw, ch = self.GetClientSize() dw, dh = cw - pad * 2, ch - pad * 2 bw, bh = self.bitmap.GetSize() xr, yr = float(dw) / float(bw), float(dh) / float(bh) ratio = min(xr, yr) ratio = min(ratio, 1) sw, sh = int(cw / ratio), int(ch / ratio) x, y = (sw - bw) / 2, (sh - bh) / 2 dc.SetUserScale(ratio, ratio) dc.DrawBitmap(self.bitmap, x, y)
def SetSelected(self, selected): self.Freeze() try: self.__selected = selected if selected: self.color = wx.SystemSettings_GetColour( wx.SYS_COLOUR_HIGHLIGHT) # On MS Windows, the selection background is very dark. If # the foreground color is too dark, invert it. r, g, b = self.task.foregroundColor() or (0, 0, 0) if r + g + b < 128 * 3: self.foreground = wx.Color(*(255 - r, 255 - g, 255 - b)) else: self.color = wx.Color( *(self.task.backgroundColor() or (255, 255, 255))) self.foreground = wx.Color( *(self.task.foregroundColor() or (0, 0, 0))) finally: self.Thaw()
def onTextDurationChanged(self, event): """ Change the displayed duration at start-up, except if the validation fails. """ success = self.text_duration.GetValidator().Validate( self.text_duration) if success is False: return self.text_duration.SetFocus() self.text_duration.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) self.text_duration.Refresh() try: v = float(self.text_duration.GetValue()) self._prefsIO.SetValue('D_TIME_MAX', 'float', v) except Exception: pass
def _create_content(self): self.filterpanel = SingleFilterPanel(self, self.preferences) self.tiername_layout = wx.BoxSizer(wx.HORIZONTAL) title_tiername = wx.StaticText(self, label="Name of filtered tier: ", style=wx.ALIGN_CENTER) title_tiername.SetFont( self.preferences.GetValue('M_FONT') ) self.text_tiername = wx.TextCtrl(self, size=(250, -1), validator=TextValidator()) self.text_tiername.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) self.text_tiername.SetForegroundColour(wx.Colour(128,128,128)) self.text_tiername.SetValue(DEFAULT_TIERNAME) self.text_tiername.Bind(wx.EVT_TEXT, self.OnTextChanged) self.text_tiername.Bind(wx.EVT_SET_FOCUS, self.OnTextClick) self.tiername_layout.Add(title_tiername, flag=wx.ALL|wx.wx.ALIGN_CENTER_VERTICAL, border=5) self.tiername_layout.Add(self.text_tiername, flag=wx.EXPAND|wx.ALL|wx.wx.ALIGN_CENTER_VERTICAL, border=5) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.filterpanel, 1, flag=wx.ALL|wx.EXPAND, border=0) vbox.Add(self.tiername_layout, 0, flag=wx.ALL|wx.EXPAND, border=0) return vbox
def __set_properties(self): # begin wxGlade: MyFrame.__set_properties self.SetTitle(_(u"\u5b57\u5e16\u751f\u6210\u5668")) self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE)) self.combo_box_mode.SetMinSize((300, -1)) self.combo_box_font.SetMinSize((300, -1)) self.text_ctrl_pages_limit.SetMinSize((60, -1)) self.combo_box_grid_type.SetMinSize((200, -1)) self.text_ctrl_repeat_times.SetMinSize((60, -1)) self.checkbox_output_page_num.SetValue(1) self.checkbox_output_foot_notes.SetValue(1) self.text_ctrl_foot_notes.SetMinSize((300, -1)) self.text_ctrl_input.SetMinSize((600, -1)) self.button_select_input.SetMinSize((40, 40)) self.text_ctrl_output.SetMinSize((600, -1)) self.text_ctrl_output.Enable(False) self.button_2.SetMinSize((120, -1)) self.button_2.SetDefault() self.button_1.SetMinSize((120, -1))