Python wx.RED Examples
The following are 22
code examples of wx.RED().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: window_dialog.py From wxGlade with MIT License | 6 votes |
def on_text(self, event): import re validation_re = re.compile(r'^[a-zA-Z_]+[\w:.0-9-]*$') name = event.GetString() OK = bool( validation_re.match( name ) ) if not OK: self.klass.SetBackgroundColour(wx.RED) compat.SetToolTip(self.klass, "Class name not valid") else: #if name in [c.widget.klass for c in common.root.children or []]: if self.toplevel and name in self.toplevel_names: self.klass.SetBackgroundColour( wx.RED ) compat.SetToolTip(self.klass, "Class name already in use for toplevel window") OK = False elif name in self.class_names: # if the class name is in use already, indicate in yellow self.klass.SetBackgroundColour( wx.Colour(255, 255, 0, 255) ) compat.SetToolTip(self.klass, "Class name not unique") if self.toplevel and name in self.toplevel_names: OK = False else: self.klass.SetBackgroundColour( compat.wx_SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW) ) compat.SetToolTip(self.klass, "") self.klass.Refresh() self.btnOK.Enable(OK) event.Skip()
Example #2
Source File: new_properties.py From wxGlade with MIT License | 6 votes |
def _on_text(self, event): if self.deactivated or self.blocked: return text = event.GetString() if not self.validation_re: if self.control_re.search(text): # strip most ASCII control characters self.text.SetValue(self.control_re.sub("", text)) wx.Bell() return elif self.check(text): self.text.SetBackgroundColour( compat.wx_SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW) ) self.text.Refresh() else: self.text.SetBackgroundColour(wx.RED) self.text.Refresh() event.Skip()
Example #3
Source File: menubar.py From wxGlade with MIT License | 6 votes |
def on_name_edited(self, event): value = self.name.GetValue() if not value or self.name_re.match(value): self.name.SetBackgroundColour( compat.wx_SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW) ) valid = True else: self.name.SetBackgroundColour(wx.RED) valid = False if value and valid and not self._ignore_events: # check for double names for i in range(self.items.GetItemCount()): if i==self.selected_index: continue if value == self._get_item_text(i, "name"): valid = False self.name.SetBackgroundColour( wx.Colour(255, 255, 0, 255) ) # YELLOW break self.name.Refresh() self._on_edited(event, "name", value, valid)
Example #4
Source File: new_properties.py From wxGlade with MIT License | 6 votes |
def _check(self, klass, ctrl=None): # called by _on_text and create_text_ctrl to validate and indicate if not self.text and not ctrl: return if ctrl is None: ctrl = self.text if not self.validation_re.match(klass): ctrl.SetBackgroundColour(wx.RED) compat.SetToolTip(ctrl, "Name is not valid.") else: msg = self._check_class_uniqueness(klass) if not msg: ctrl.SetBackgroundColour( compat.wx_SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW) ) compat.SetToolTip( ctrl, self._find_tooltip() ) else: ctrl.SetBackgroundColour( wx.Colour(255, 255, 0, 255) ) # YELLOW compat.SetToolTip(ctrl, msg) ctrl.Refresh()
Example #5
Source File: matplotlib_example.py From wxGlade with MIT License | 5 votes |
def on_button_plot(self, event): import numpy xmin = xmax = step = None try: xmin = float( self.text_xmin.GetValue() ) self.text_xmin.SetBackgroundColour(wx.WHITE) except: self.text_xmin.SetBackgroundColour(wx.RED) try: xmax = float( self.text_max.GetValue() ) self.text_max.SetBackgroundColour(wx.WHITE) except: self.text_max.SetBackgroundColour(wx.RED) try: step = float( self.text_xstep.GetValue() ) self.text_xstep.SetBackgroundColour(wx.WHITE) except: self.text_xstep.SetBackgroundColour(wx.RED) x = numpy.arange(xmin, xmax, step) # build globals with some functions g = {} for name in ["sin","cos","tan","ufunc","square"]: g[name] = getattr(numpy, name) y = eval(self.text_function.GetValue(), g, {"numpy":numpy, "x":x}) self.matplotlib_canvas.axes.plot(x,y) self.matplotlib_canvas.draw() event.Skip()
Example #6
Source File: OLVPrinter.py From bookhub with MIT License | 5 votes |
def run(self): printer = OLVPrinter(self.olv, "First ObjectListView Report") printer.ReportFormat = ReportFormat.Normal() #fmt.PageHeader.Font = wx.FFont(36, wx.FONTFAMILY_SWISS, face="Gill Sans") #fmt.PageHeader.Add(BackgroundDecoration(wx.BLUE)) #fmt.PageHeader.Add(LineDecoration(side=Decoration.TOP, pen=wx.Pen(wx.RED, 5), space=0)) #fmt.PageHeader.Add(LineDecoration(pen=wx.BLACK_PEN, space=0)) # #fmt.PageFooter.Font = wx.FFont(12, wx.FONTFAMILY_SWISS, face="Gill Sans") #fmt.PageFooter.Add(BackgroundDecoration(wx.GREEN)) #fmt.PageFooter.Add(LineDecoration(pen=wx.Pen(wx.BLUE, 5), space=0)) #fmt.PageFooter.Add(LineDecoration(side=Decoration.TOP, pen=wx.RED_PEN, space=0)) printer.PrintPreview(self)
Example #7
Source File: OLVPrinter.py From bookhub with MIT License | 5 votes |
def Normal(fontName="Arial"): """ Return a reasonable default format for a report """ fmt = ReportFormat() fmt.PageHeader.Font = wx.FFont(24, wx.FONTFAMILY_DEFAULT, face=fontName) fmt.PageHeader.TextAlignment = wx.ALIGN_CENTRE fmt.PageHeader.Add(FrameDecoration(pen=wx.Pen(wx.BLUE, 1), space=5)) #fmt.PageHeader.Add(LineDecoration(pen=wx.Pen(wx.BLUE, 2), space=5)) fmt.ReportHeader.Font = wx.FFont(36, wx.FONTFAMILY_DEFAULT, face=fontName) fmt.ReportHeader.TextColor = wx.RED fmt.ReportHeader.Padding = (0, 12, 0, 12) fmt.ListHeader.Add(LineDecoration(side=Decoration.BOTTOM, pen=wx.Pen(wx.GREEN, 1))) fmt.PageFooter.Font = wx.FFont(12, wx.FONTFAMILY_DEFAULT, face=fontName) fmt.PageFooter.TextAlignment = wx.ALIGN_RIGHT fmt.PageFooter.Add(LineDecoration(side=Decoration.TOP, pen=wx.Pen(wx.BLUE, 1), space=3)) fmt.Row.Font = wx.FFont(12, wx.FONTFAMILY_DEFAULT, face=fontName) #fmt.ColumnHeader.CellPadding=25 fmt.ColumnHeader.GridPen=wx.Pen(wx.RED, 1) fmt.Row.CellPadding=(10, 10, 0, 10) fmt.Row.GridPen=wx.Pen(wx.BLUE, 1) #fmt.ColumnHeader.Add(FrameDecoration(pen=wx.Pen(wx.RED, 1))) #fmt.Row.Add(FrameDecoration(pen=wx.Pen(wx.RED, 10))) #fmt.Row.Add(LineDecoration(side=Decoration.BOTTOM, pen=wx.Pen(wx.GREEN, 1))) return fmt #======================================================================
Example #8
Source File: GraphicCommons.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def DrawHighlightment(self, dc): scalex, scaley = dc.GetUserScale() dc.SetUserScale(1, 1) # If user trying to connect wire with wrong input, highlight will become red. if self.ErrHighlight and not self.EndConnected: highlightcolor = wx.RED else: highlightcolor = HIGHLIGHTCOLOR dc.SetPen(MiterPen(highlightcolor, (2 * scalex + 5))) dc.SetBrush(wx.Brush(highlightcolor)) dc.SetLogicalFunction(wx.AND) # Draw the start and end points if they are not connected or the mouse is over them if len(self.Points) > 0 and (not self.StartConnected or self.OverStart): dc.DrawCircle(round(self.Points[0].x * scalex), round(self.Points[0].y * scaley), (POINT_RADIUS + 1) * scalex + 2) if len(self.Points) > 1 and (not self.EndConnected or self.OverEnd): dc.DrawCircle(self.Points[-1].x * scalex, self.Points[-1].y * scaley, (POINT_RADIUS + 1) * scalex + 2) # Draw the wire lines and the last point (it seems that DrawLines stop before the last point) if len(self.Points) > 1: points = [wx.Point(round((self.Points[0].x - self.Segments[0][0]) * scalex), round((self.Points[0].y - self.Segments[0][1]) * scaley))] points.extend([wx.Point(round(point.x * scalex), round(point.y * scaley)) for point in self.Points[1:-1]]) points.append(wx.Point(round((self.Points[-1].x + self.Segments[-1][0]) * scalex), round((self.Points[-1].y + self.Segments[-1][1]) * scaley))) else: points = [] dc.DrawLines(points) dc.SetLogicalFunction(wx.COPY) dc.SetUserScale(scalex, scaley) if self.StartConnected is not None: self.StartConnected.DrawHighlightment(dc) self.StartConnected.Draw(dc) if self.EndConnected is not None: self.EndConnected.DrawHighlightment(dc) self.EndConnected.Draw(dc) # Draws the wire lines and points
Example #9
Source File: edit_sizers.py From wxGlade with MIT License | 5 votes |
def update_view(self, selected): if self._btn is None: return if selected: color = wx.RED else: color = compat.wx_SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE) self._btn.SetBackgroundColour(color) self._btn.Refresh(True) # add/insert/free slots; interface mainly from context menus #######################################################
Example #10
Source File: matplotlib_example.py From wxGlade with MIT License | 5 votes |
def on_button_plot(self, event): # wxGlade: MyFrame.<event_handler> import numpy xmin = xmax = step = None try: xmin = float( self.text_xmin.GetValue() ) self.text_xmin.SetBackgroundColour(wx.WHITE) except: self.text_xmin.SetBackgroundColour(wx.RED) try: xmax = float( self.text_max.GetValue() ) self.text_max.SetBackgroundColour(wx.WHITE) except: self.text_max.SetBackgroundColour(wx.RED) try: step = float( self.text_xstep.GetValue() ) self.text_xstep.SetBackgroundColour(wx.WHITE) except: self.text_xstep.SetBackgroundColour(wx.RED) x = numpy.arange(xmin, xmax, step) # build globals with some functions g = {} for name in ["sin","cos","tan","ufunc","square"]: g[name] = getattr(numpy, name) y = eval(self.text_function.GetValue(), g, {"numpy":numpy, "x":x}) self.matplotlib_axes.plot(x,y) self.matplotlib_canvas.draw() event.Skip() # end of class MyFrame
Example #11
Source File: toolbar.py From wxGlade with MIT License | 5 votes |
def on_event_handler_edited(self, event): value = self.handler.GetValue() if not value or self.handler_re.match(value): self.handler.SetBackgroundColour( compat.wx_SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW) ) valid = True else: self.handler.SetBackgroundColour(wx.RED) valid = False self.handler.Refresh() self._on_edited(event, "handler", value, valid)
Example #12
Source File: menubar.py From wxGlade with MIT License | 5 votes |
def on_event_handler_edited(self, event): value = self.event_handler.GetValue() if not value or self.handler_re.match(value): self.event_handler.SetBackgroundColour( compat.wx_SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW) ) valid = True else: self.event_handler.SetBackgroundColour(wx.RED) valid = False self.event_handler.Refresh() self._on_edited(event, "event_handler", value, valid)
Example #13
Source File: new_properties.py From wxGlade with MIT License | 5 votes |
def on_text_editor(self, event): # editor text control content changed; validate and display result / update values ctrl = event.GetEventObject() col = self.editors.index( ctrl ) if not self._validate(self.cur_row, col, event.GetString(), bell=False ): ctrl.SetBackgroundColour(wx.RED) return ctrl.SetBackgroundColour(wx.NullColour) event.Skip()
Example #14
Source File: new_properties.py From wxGlade with MIT License | 5 votes |
def _on_text(self, event): if self.deactivated or self.blocked: return name = event.GetString() match = self.validation_re.match(name) if match: if self._check_name_uniqueness(name): self.text.SetBackgroundColour( compat.wx_SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW) ) else: self.text.SetBackgroundColour( wx.Colour(255, 255, 0, 255) ) # YELLOW else: self.text.SetBackgroundColour(wx.RED) self.text.Refresh() event.Skip()
Example #15
Source File: new_properties.py From wxGlade with MIT License | 5 votes |
def update_display(self, start_editing=False): # when the value has changed if start_editing: self.editing = True if not self.editing: return checked = self.get_list_value() for i,checkbox in enumerate(self._choices): if checkbox is None: continue name = self._names[i] if checked[i] and not checkbox.GetValue(): checkbox.SetValue(True) elif not checked[i] and checkbox.GetValue(): checkbox.SetValue(False) # display included flags in grey and excluded flags red if self.EXCLUDES: excludes = self.EXCLUDES.get(name, []) else: excludes = self.style_defs[name].get("exclude",[]) default_color = wx.BLACK if not "rename_to" in self.style_defs[name] else wx.Colour(130,130,130) if checked[i] and not name in self.value_set: checkbox.SetForegroundColour(wx.Colour(120,120,100)) # grey elif self.value_set.intersection( excludes ): checkbox.SetForegroundColour(wx.RED) else: supported_by = self.style_defs.get(name, {}).get("supported_by", None) if supported_by: checkbox.SetForegroundColour(wx.BLUE) else: checkbox.SetForegroundColour(default_color) if self.EXCLUDES2 and name in self.EXCLUDES2: checkbox.SetForegroundColour(wx.RED) checkbox.Disable() elif self.EXCLUDES2 is not None: checkbox.Enable() checkbox.Refresh() #################################################################################################################### # helpers for CheckBox tooltips
Example #16
Source File: color_dialog.py From wxGlade with MIT License | 5 votes |
def __init__(self, colors_dict, parent=None): wx.Dialog.__init__(self, parent, -1, "") self.colors_dict = colors_dict choices = list( self.colors_dict.keys() ) choices.sort() self.panel_1 = wx.Panel(self, -1) self.use_null_color = wx.RadioButton( self.panel_1, -1, "wxNullColour", style=wx.RB_GROUP ) self.use_sys_color = wx.RadioButton( self.panel_1, -1, _("System Color") ) self.sys_color = wx.ComboBox( self.panel_1, -1, choices=choices, style=wx.CB_DROPDOWN | wx.CB_READONLY) self.sys_color_panel = wx.Panel(self.panel_1, -1, size=(250, 20)) self.sys_color_panel.SetBackgroundColour(wx.RED) self.use_chooser = wx.RadioButton(self.panel_1, -1, _("Custom Color")) self.color_chooser = PyColourChooser(self, -1) self.ok = wx.Button(self, wx.ID_OK, _("OK")) self.cancel = wx.Button(self, wx.ID_CANCEL, _("Cancel")) self.__set_properties() self.__do_layout() self.use_null_color.Bind(wx.EVT_RADIOBUTTON, self.on_use_null_color) self.use_sys_color.Bind(wx.EVT_RADIOBUTTON, self.on_use_sys_color) self.use_chooser.Bind(wx.EVT_RADIOBUTTON, self.on_use_chooser) self.sys_color.Bind(wx.EVT_COMBOBOX, self.display_sys_color) self.display_sys_color() for ctrl in (self.use_null_color, self.use_sys_color, self.use_chooser): ctrl.Bind(wx.EVT_LEFT_DCLICK, lambda evt: self.EndModal(wx.ID_OK) )
Example #17
Source File: matplotlib_example.py From wxGlade with MIT License | 5 votes |
def _get_float(self, control): # returns a float or None if not a valid float try: ret = float( control.GetValue() ) colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW) control.SetBackgroundColour(colour) except: control.SetBackgroundColour(wx.RED) wx.Bell() ret = None control.Refresh() return ret #################################################################################################################### # mouse actions
Example #18
Source File: matplotlib_example.py From wxGlade with MIT License | 5 votes |
def on_button_plot(self, event): # wxGlade: MyFrame.<event_handler> import numpy xmin = xmax = step = None try: xmin = float( self.text_xmin.GetValue() ) self.text_xmin.SetBackgroundColour(wx.WHITE) except: self.text_xmin.SetBackgroundColour(wx.RED) try: xmax = float( self.text_max.GetValue() ) self.text_max.SetBackgroundColour(wx.WHITE) except: self.text_max.SetBackgroundColour(wx.RED) try: step = float( self.text_xstep.GetValue() ) self.text_xstep.SetBackgroundColour(wx.WHITE) except: self.text_xstep.SetBackgroundColour(wx.RED) x = numpy.arange(xmin, xmax, step) # build globals with some functions g = {} for name in ["sin","cos","tan","ufunc","square"]: g[name] = getattr(numpy, name) y = eval(self.text_function.GetValue(), g, {"numpy":numpy, "x":x}) self.matplotlib_axes.plot(x,y) self.matplotlib_canvas.draw() event.Skip() # end of class MyFrame
Example #19
Source File: lib_plot_example.py From wxGlade with MIT License | 5 votes |
def on_button_plot(self, event): # wxGlade: MyFrame.<event_handler> import numpy xmin = xmax = step = None try: xmin = float( self.text_xmin.GetValue() ) self.text_xmin.SetBackgroundColour(wx.WHITE) except: self.text_xmin.SetBackgroundColour(wx.RED) try: xmax = float( self.text_max.GetValue() ) self.text_max.SetBackgroundColour(wx.WHITE) except: self.text_max.SetBackgroundColour(wx.RED) try: step = float( self.text_xstep.GetValue() ) self.text_xstep.SetBackgroundColour(wx.WHITE) except: self.text_xstep.SetBackgroundColour(wx.RED) # build globals for the eval() call with some functions g = {} for name in ["sin","cos","tan","ufunc","square"]: g[name] = getattr(numpy, name) # calculate the x and y values x = numpy.arange(xmin, xmax, step) y = eval(self.text_function.GetValue(), g, {"numpy":numpy, "x":x}) data = numpy.stack( (x,y), 1 ) # plot them lines = wx.lib.plot.PolyLine( data, colour=self.choice_colour.GetStringSelection() ) self.plot_datasets.append(lines) graphics = wx.lib.plot.PlotGraphics(self.plot_datasets, "Title", "X", "Y") self.plot_canvas.Draw(graphics) event.Skip() # end of class MyFrame
Example #20
Source File: app.py From thotkeeper with BSD 2-Clause "Simplified" License | 5 votes |
def SetDayAttr(self, day, has_event): if has_event: attr = CalendarDateAttr() attr.SetTextColour(wx.RED) self.SetAttr(day, attr) else: self.ResetAttr(day)
Example #21
Source File: Notebook_Test.py From topoflow with MIT License | 4 votes |
def __init__(self, parent, id, log): wx.Notebook.__init__(self, parent, id, size=(21,21), style= wx.BK_DEFAULT #wx.BK_TOP #wx.BK_BOTTOM #wx.BK_LEFT #wx.BK_RIGHT # | wx.NB_MULTILINE ) self.log = log win = self.makeColorPanel(wx.BLUE) self.AddPage(win, "Blue") st = wx.StaticText(win.win, -1, "You can put nearly any type of window here,\n" "and if the platform supports it then the\n" "tabs can be on any side of the notebook.", (10, 10)) st.SetForegroundColour(wx.WHITE) st.SetBackgroundColour(wx.BLUE) # Show how to put an image on one of the notebook tabs, # first make the image list: il = wx.ImageList(16, 16) idx1 = il.Add(images.getSmilesBitmap()) self.AssignImageList(il) # now put an image on the first tab we just created: self.SetPageImage(0, idx1) win = self.makeColorPanel(wx.RED) self.AddPage(win, "Red") win = ScrolledWindow.MyCanvas(self) self.AddPage(win, 'ScrolledWindow') win = self.makeColorPanel(wx.GREEN) self.AddPage(win, "Green") win = GridSimple.SimpleGrid(self, log) self.AddPage(win, "Grid") win = ListCtrl.TestListCtrlPanel(self, log) self.AddPage(win, 'List') win = self.makeColorPanel(wx.CYAN) self.AddPage(win, "Cyan") win = self.makeColorPanel(wx.NamedColour('Midnight Blue')) self.AddPage(win, "Midnight Blue") win = self.makeColorPanel(wx.NamedColour('Indian Red')) self.AddPage(win, "Indian Red") self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged) self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging)
Example #22
Source File: ListCtrlPrinter.py From bookhub with MIT License | 4 votes |
def TooMuch(headerFontName="Chiller", rowFontName="Gill Sans"): """ Return a reasonable default format for a report """ fmt = ReportFormat() fmt.IsShrinkToFit = False fmt.PageHeader.Font = wx.FFont(12, wx.FONTFAMILY_DECORATIVE, wx.FONTFLAG_BOLD, face=headerFontName) fmt.PageHeader.TextColor = wx.WHITE fmt.PageHeader.Background(wx.GREEN, wx.RED, space=(16, 4, 0, 4)) fmt.PageHeader.Padding = (0, 0, 0, 12) fmt.ListHeader.Font = wx.FFont(24, wx.FONTFAMILY_DECORATIVE, face=headerFontName) fmt.ListHeader.TextColor = wx.WHITE fmt.ListHeader.Padding = (0, 12, 0, 12) fmt.ListHeader.TextAlignment = wx.ALIGN_CENTER fmt.ListHeader.Background(wx.RED, wx.GREEN, space=(16, 4, 0, 4)) fmt.GroupTitle.Font = wx.FFont(14, wx.FONTFAMILY_DECORATIVE, wx.FONTFLAG_BOLD, face=headerFontName) fmt.GroupTitle.TextColor = wx.BLUE fmt.GroupTitle.Padding = (0, 12, 0, 12) fmt.GroupTitle.Line(wx.BOTTOM, wx.GREEN, 4, toColor=wx.WHITE, space=5) fmt.PageFooter.Font = wx.FFont(10, wx.FONTFAMILY_DECORATIVE, face=headerFontName) fmt.PageFooter.Line(wx.TOP, wx.GREEN, 2, toColor=wx.RED, space=3) fmt.PageFooter.Padding = (0, 16, 0, 0) fmt.ColumnHeader.Font = wx.FFont(14, wx.FONTFAMILY_SWISS, wx.FONTFLAG_BOLD, face=headerFontName) fmt.ColumnHeader.Background(wx.Colour(255, 215, 0)) fmt.ColumnHeader.CellPadding = 5 fmt.ColumnHeader.GridPen = wx.Pen(wx.Colour(192, 192, 192), 1) fmt.Row.Font = wx.FFont(12, wx.FONTFAMILY_SWISS, face=rowFontName) fmt.Row.CellPadding = 5 fmt.Row.GridPen = wx.Pen(wx.BLUE, 1, wx.DOT) fmt.Row.CanWrap = True fmt.Watermark.TextColor = wx.Colour(233, 150, 122) return fmt #----------------------------------------------------------------------------