我们从Python开源项目中,提取了以下17个代码示例,用于说明如何使用wx.WHITE。
def _updateColAttrs(self, grid): """ wx.grid.Grid -> update the column attributes to add the appropriate renderer given the column name. Otherwise default to the default renderer. """ for row in range(self.GetNumberRows()): row_highlights = self.Highlights.get(row, {}) for col in range(self.GetNumberCols()): colname = self.GetColLabelValue(col, False) grid.SetReadOnly(row, col, True) grid.SetCellEditor(row, col, None) grid.SetCellRenderer(row, col, None) highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1] grid.SetCellBackgroundColour(row, col, highlight_colours[0]) grid.SetCellTextColour(row, col, highlight_colours[1]) self.ResizeRow(grid, row)
def Get(self,l,r): s=""+self.s_line for i in range(5): if i<(5-l): sl = self.sl_off else: sl = self.sl_on if i<(5-r): sr = self.sr_off else: sr = self.sr_on s+=self.s_border+sl+self.s_point+sr+self.s_point s+=self.s_border+sl+self.s_point+sr+self.s_point s+=self.s_line image = wx.EmptyImage(16,16) image.SetData(s) bmp = image.ConvertToBitmap() bmp.SetMask(wx.Mask(bmp, wx.WHITE)) #sets the transparency colour to white icon = wx.EmptyIcon() icon.CopyFromBitmap(bmp) return icon ## # The TaskBarIcon class #
def __init__(self, parent, window, items=[]): """ Constructor @param parent: Parent wx.Window of DebugVariableText @param window: Reference to the Debug Variable Panel @param items: List of DebugVariableItem displayed by Viewer """ DebugVariableViewer.__init__(self, window, items) wx.Panel.__init__(self, parent) # Set panel background colour self.SetBackgroundColour(wx.WHITE) # Define panel drop target self.SetDropTarget(DebugVariableTextDropTarget(self, window)) # Bind events self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) self.Bind(wx.EVT_SIZE, self.OnResize) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_PAINT, self.OnPaint) # Define panel min size for parent sizer layout self.SetMinSize(wx.Size(0, 25)) # Add buttons to Viewer for bitmap, callback in [("force", self.OnForceButton), ("release", self.OnReleaseButton), ("delete_graph", self.OnCloseButton)]: self.Buttons.append(GraphButton(0, 0, bitmap, callback))
def _updateColAttrs(self, grid): """ wx.grid.Grid -> update the column attributes to add the appropriate renderer given the column name. Otherwise default to the default renderer. """ for row in range(self.GetNumberRows()): row_highlights = self.Highlights.get(row, {}) for col in range(self.GetNumberCols()): editor = None renderer = None colname = self.GetColLabelValue(col, False) if col != 0: grid.SetReadOnly(row, col, False) if colname == "Name": editor = wx.grid.GridCellTextEditor() renderer = wx.grid.GridCellStringRenderer() elif colname == "Initial Value": editor = wx.grid.GridCellTextEditor() renderer = wx.grid.GridCellStringRenderer() elif colname == "Type": editor = wx.grid.GridCellTextEditor() else: grid.SetReadOnly(row, col, True) grid.SetCellEditor(row, col, editor) grid.SetCellRenderer(row, col, renderer) highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1] grid.SetCellBackgroundColour(row, col, highlight_colours[0]) grid.SetCellTextColour(row, col, highlight_colours[1]) self.ResizeRow(grid, row)
def _updateColAttrs(self, grid): """ wxGrid -> update the column attributes to add the appropriate renderer given the column name. Otherwise default to the default renderer. """ typelist = None accesslist = None for row in range(self.GetNumberRows()): for col in range(self.GetNumberCols()): editor = None renderer = None colname = self.GetColLabelValue(col, False) if colname in ["Name", "Initial", "Description", "OnChange", "Options"]: editor = wx.grid.GridCellTextEditor() elif colname == "Class": editor = wx.grid.GridCellChoiceEditor() editor.SetParameters("input,memory,output") elif colname == "Type": pass else: grid.SetReadOnly(row, col, True) grid.SetCellEditor(row, col, editor) grid.SetCellRenderer(row, col, renderer) grid.SetCellBackgroundColour(row, col, wx.WHITE) self.ResizeRow(grid, row)
def __init__(self, parent, ID): wx.Panel.__init__(self, parent, ID) box = wx.StaticBox(self, -1, "relabelling key") sizer = wx.StaticBoxSizer(box, wx.VERTICAL) self.real = wx.StaticText(self, label="REAL") self.real.SetBackgroundColour(wx.WHITE) self.real.SetForegroundColour("#3366FF") self.bogus = wx.StaticText(self, label="BOGUS") self.bogus.SetBackgroundColour(wx.WHITE) self.bogus.SetForegroundColour("#FF0066") self.ghost = wx.StaticText(self, label="GHOST") self.ghost.SetBackgroundColour(wx.WHITE) self.ghost.SetForegroundColour("#9933FF") manual_box = wx.BoxSizer(wx.HORIZONTAL) manual_box.Add(self.real, flag=wx.ALIGN_CENTER_VERTICAL) manual_box.Add(self.bogus, flag=wx.ALIGN_CENTER_VERTICAL) manual_box.Add(self.ghost, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(manual_box, 0, wx.ALL, 10) self.SetSizer(sizer) sizer.Fit(self)
def __init__( self, parent=None, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL|wx.NO_BORDER|wx.FULL_REPAINT_ON_RESIZE, name='SquareMap', model = None, adapter = None, labels = True, # set to True to draw textual labels within the boxes highlight = True, # set to False to turn of highlighting padding = 2, # amount to reduce the children's box from the parent's box ): super( SquareMap, self ).__init__( parent, id, pos, size, style, name ) self.model = model self.padding = padding self.labels = labels self.highlight = highlight self.selectedNode = None self.highlightedNode = None self.Bind( wx.EVT_PAINT, self.OnPaint) self.Bind( wx.EVT_SIZE, self.OnSize ) if highlight: self.Bind( wx.EVT_MOTION, self.OnMouse ) self.Bind( wx.EVT_LEFT_UP, self.OnClickRelease ) self.Bind( wx.EVT_LEFT_DCLICK, self.OnDoubleClick ) self.Bind( wx.EVT_KEY_UP, self.OnKeyUp ) self.hot_map = [] self.adapter = adapter or DefaultAdapter() self.DEFAULT_PEN = wx.Pen( wx.BLACK, 1, wx.SOLID ) self.SELECTED_PEN = wx.Pen( wx.WHITE, 2, wx.SOLID ) self.OnSize(None)
def __init__( self, parent=None, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL|wx.NO_BORDER|wx.FULL_REPAINT_ON_RESIZE, name='SquareMap', model = None, adapter = None, labels = True, highlight = True, padding = 2, margin = 0, square_style = False, ): """Initialise the SquareMap adapter -- a DefaultAdapter or same-interface instance providing SquareMap data api labels -- set to True (default) to draw textual labels within the boxes highlight -- set to True (default) to highlight nodes on mouse-over padding -- spacing within each square and its children (within the square's border) margin -- spacing around each square (on all sides) square_style -- use a more-recursive, less-linear, more "square" layout style which works better on objects with large numbers of children, such as Meliae memory dumps, works fine on profile views as well, but the layout is less obvious wrt what node is "next" "previous" etc. """ super( SquareMap, self ).__init__( parent, id, pos, size, style, name ) self.model = model self.padding = padding self.square_style = square_style self.margin = margin self.labels = labels self.highlight = highlight self.selectedNode = None self.highlightedNode = None self._buffer = wx.Bitmap(20, 20) # Have a default buffer ready self.Bind( wx.EVT_PAINT, self.OnPaint) self.Bind( wx.EVT_SIZE, self.OnSize ) if highlight: self.Bind( wx.EVT_MOTION, self.OnMouse ) self.Bind( wx.EVT_LEFT_UP, self.OnClickRelease ) self.Bind( wx.EVT_LEFT_DCLICK, self.OnDoubleClick ) self.Bind( wx.EVT_KEY_UP, self.OnKeyUp ) self.hot_map = [] self.adapter = adapter or DefaultAdapter() self.DEFAULT_PEN = wx.Pen( wx.BLACK, 1, wx.SOLID ) self.SELECTED_PEN = wx.Pen( wx.WHITE, 2, wx.SOLID ) self.OnSize(None)
def InitUI(self): self.panel = wx.Panel(self, wx.ID_ANY) # Info Text infotext = _(u'Close all open Applications, it is possible that programs will be closed without a warning ' u'and system could reboot without further confirmation.') infobox = wx.StaticBox(self.panel, -1, _(u'Attention')) infoboxbsizer = wx.StaticBoxSizer(infobox, wx.VERTICAL) info = wx.StaticText(self.panel, label=infotext) info.Wrap(380) infoboxbsizer.Add(info, 0) self.gauge = wx.Gauge(self.panel, size=(24, 26)) self.update_label = wx.StaticText(self.panel, label=_(u'Current Progress:')) self.update_box = wx.TextCtrl(self.panel, style=wx.TE_READONLY) self.update_box.SetBackgroundColour(wx.WHITE) self.chk_shutdown = wx.CheckBox(self.panel, size=(160,20), label=_(u"Shutdown after update")) self.logButton = wx.Button(self.panel, size=(54,26), label="LOG") self.logButton.SetToolTip(wx.ToolTip(_(u'Open WPKG Log'))) self.logButton.SetBitmap(img.get('log')) self.startButton = wx.Button(self.panel, label=_(u"Update")) self.abortButton = wx.Button(self.panel, label=_(u"Cancel")) self.logButton.Disable() self.abortButton.Disable() self.line = wx.StaticLine(self.panel, -1, size=(2,2), style=wx.LI_HORIZONTAL) self.startButton.Bind(wx.EVT_BUTTON, self.OnStartButton) self.abortButton.Bind(wx.EVT_BUTTON, self.OnAbortButton) self.logButton.Bind(wx.EVT_BUTTON, self.OnLogButton) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) self.sizer.Add(infoboxbsizer, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.gauge, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.update_label, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.update_box, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.line, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.chk_shutdown, 0, wx.LEFT | wx.EXPAND, 7) self.sizer2.Add(self.logButton, 0) self.sizer2.AddStretchSpacer() self.sizer2.Add(self.startButton, 0)#, wx.RIGHT, 2) self.sizer2.Add(self.abortButton, 0) self.sizer.Add(self.sizer2, 0, wx.ALL | wx.EXPAND, 5) self.panel.SetSizerAndFit(self.sizer) self.Center()
def _updateColAttrs(self, grid): """ wx.Grid -> update the column attributes to add the appropriate renderer given the column name. Otherwise default to the default renderer. """ for row in range(self.GetNumberRows()): for col in range(self.GetNumberCols()): editor = None renderer = None readonly = False colname = self.GetColLabelValue(col, False) if colname == "Qualifier": editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.QualifierList) if colname == "Duration": editor = wx.grid.GridCellTextEditor() renderer = wx.grid.GridCellStringRenderer() readonly = not self.Parent.DurationList[self.data[row].qualifier] elif colname == "Type": editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.TypeList) elif colname == "Value": value_type = self.data[row].type if value_type == "Action": editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.ActionList) elif value_type == "Variable": editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.VariableList) elif value_type == "Inline": editor = wx.grid.GridCellTextEditor() renderer = wx.grid.GridCellStringRenderer() elif colname == "Indicator": editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.VariableList) grid.SetCellEditor(row, col, editor) grid.SetCellRenderer(row, col, renderer) grid.SetReadOnly(row, col, readonly) grid.SetCellBackgroundColour(row, col, wx.WHITE) self.ResizeRow(grid, row) # ------------------------------------------------------------------------------- # Action Block Dialog # -------------------------------------------------------------------------------
def __init__(self, parent, controller, tagname, title): """ Constructor @param parent: Parent wx.Window of dialog for modal @param controller: Reference to project controller @param tagname: Tagname of project POU edited @param title: Title of dialog frame """ wx.Dialog.__init__(self, parent, title=title) # Save reference to self.Controller = controller self.TagName = tagname # Label for preview self.PreviewLabel = wx.StaticText(self, label=_('Preview:')) # Create Preview panel self.Preview = wx.Panel(self, style=wx.SIMPLE_BORDER) self.Preview.SetBackgroundColour(wx.WHITE) # Add function to preview panel so that it answers to graphic elements # like Viewer setattr(self.Preview, "GetDrawingMode", lambda: FREEDRAWING_MODE) setattr(self.Preview, "GetScaling", lambda: None) setattr(self.Preview, "GetBlockType", controller.GetBlockType) setattr(self.Preview, "IsOfType", controller.IsOfType) # Bind paint event on Preview panel self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) # Add default dialog buttons sizer self.ButtonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE) self.Bind(wx.EVT_BUTTON, self.OnOK, self.ButtonSizer.GetAffirmativeButton()) self.Element = None # Graphic element to display in preview self.MinElementSize = None # Graphic element minimal size # Variable containing the graphic element name when dialog is opened self.DefaultElementName = None self.Fit() # List of variables defined in POU {var_name: (var_class, var_type),...} self.VariableList = {}
def GenerateSearchResultsTreeBranch(self, root, infos): to_delete = [] if infos["name"] == "body": item_name = "%d:" % infos["data"][1][0] else: item_name = infos["name"] self.SearchResultsTree.SetItemText(root, item_name) self.SearchResultsTree.SetPyData(root, infos["data"]) self.SearchResultsTree.SetItemBackgroundColour(root, wx.WHITE) self.SearchResultsTree.SetItemTextColour(root, wx.BLACK) if infos["type"] is not None: if infos["type"] == ITEM_POU: self.SearchResultsTree.SetItemImage(root, self.TreeImageDict[self.ParentWindow.Controler.GetPouType(infos["name"])]) else: self.SearchResultsTree.SetItemImage(root, self.TreeImageDict[infos["type"]]) text = None if infos["text"] is not None: text = infos["text"] start, end = infos["data"][1:3] text_lines = infos["text"].splitlines() start_idx = start[1] end_idx = reduce(lambda x, y: x + y, map(lambda x: len(x) + 1, text_lines[:end[0] - start[0]]), end[1] + 1) style = wx.TextAttr(wx.BLACK, wx.Colour(206, 204, 247)) elif infos["type"] is not None and infos["matches"] > 1: text = _("(%d matches)") % infos["matches"] start_idx, end_idx = 0, len(text) style = wx.TextAttr(wx.Colour(0, 127, 174)) if text is not None: text_ctrl_style = wx.BORDER_NONE | wx.TE_READONLY | wx.TE_RICH2 if wx.Platform != '__WXMSW__' or len(text.splitlines()) > 1: text_ctrl_style |= wx.TE_MULTILINE text_ctrl = wx.TextCtrl(id=-1, parent=self.SearchResultsTree, pos=wx.Point(0, 0), value=text, style=text_ctrl_style) width, height = text_ctrl.GetTextExtent(text) text_ctrl.SetClientSize(wx.Size(width + 1, height)) text_ctrl.SetBackgroundColour(self.SearchResultsTree.GetBackgroundColour()) text_ctrl.Bind(wx.EVT_LEFT_DOWN, self.GetTextCtrlClickFunction(root)) text_ctrl.Bind(wx.EVT_LEFT_DCLICK, self.GetTextCtrlDClickFunction(root)) text_ctrl.SetInsertionPoint(0) text_ctrl.SetStyle(start_idx, end_idx, style) self.SearchResultsTree.SetItemWindow(root, text_ctrl) if wx.VERSION >= (2, 6, 0): item, root_cookie = self.SearchResultsTree.GetFirstChild(root) else: item, root_cookie = self.SearchResultsTree.GetFirstChild(root, 0) for child in infos["children"]: if item is None: item = self.SearchResultsTree.AppendItem(root, "") item, root_cookie = self.SearchResultsTree.GetNextChild(root, root_cookie) self.GenerateSearchResultsTreeBranch(item, child) item, root_cookie = self.SearchResultsTree.GetNextChild(root, root_cookie)
def Set_ReadOnly(self): #print "cols n rows",self.grid_1.GetNumberCols(),self.grid_1.GetNumberRows() for i in range(1,self.grid_1.GetNumberCols(),1): if self.grid_1.GetNumberCols()>8:# =="Basic Science": for j in range(0,self.grid_1.GetNumberRows(),1): if i==9: self.grid_1.SetCellBackgroundColour(j, i, wx.RED) self.grid_1.SetCellTextColour(j,i, wx.BLACK) self.grid_1.SetReadOnly(j,i, True) elif i==10: self.grid_1.SetCellBackgroundColour(j, i, wx.GREEN) self.grid_1.SetCellTextColour(j,i, wx.BLACK) self.grid_1.SetReadOnly(j,i, True) elif i==11: self.grid_1.SetCellBackgroundColour(j, i, wx.BLUE) self.grid_1.SetCellTextColour(j,i, wx.WHITE) self.grid_1.SetReadOnly(j,i, True) elif i==12: self.grid_1.SetCellBackgroundColour(j, i, wx.BLACK) self.grid_1.SetCellTextColour(j,i, wx.WHITE) self.grid_1.SetReadOnly(j,i, True) else: self.grid_1.SetCellBackgroundColour(j, i, wx.WHITE) self.grid_1.SetCellTextColour(j,i, wx.BLACK) self.grid_1.SetReadOnly(j,i, False) else: for j in range(0,self.grid_1.GetNumberRows(),1): if i==5: self.grid_1.SetCellBackgroundColour(j, i, wx.BLUE) self.grid_1.SetCellTextColour(j,i, wx.WHITE) self.grid_1.SetReadOnly(j,i, True) elif i==6: self.grid_1.SetCellBackgroundColour(j, i, wx.BLACK) self.grid_1.SetCellTextColour(j,i, wx.WHITE) self.grid_1.SetReadOnly(j,i, True) else: self.grid_1.SetCellBackgroundColour(j, i, wx.WHITE) self.grid_1.SetCellTextColour(j,i, wx.BLACK) self.grid_1.SetReadOnly(j,i, False)
def create_main_panel(self): self.panel = wx.Panel(self) self.set_text = wx.StaticText(self.panel, -1, label="Showing : All (%d examples)" % self.m) self.set_text.SetBackgroundColour(wx.WHITE) font = wx.Font(20, wx.MODERN, wx.NORMAL, wx.BOLD) self.set_text.SetFont(font) self.hbox1 = wx.BoxSizer(wx.HORIZONTAL) self.hbox1.Add(self.set_text, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.draw_fig(True) self.canvas = FigCanvas(self.panel, -1, self.fig) # Bind the 'click' event for clicking on one of the axes self.canvas.mpl_connect('button_press_event', self.on_click) self.navigation_control = NavigationControlBox(self.panel, self, -1, "navigation control") #self.label_key_box = LabelKeyBox(self.panel,-1) self.data_set_control = DataSetControlBox(self.panel,self,-1) self.build_button = wx.Button(self.panel, -1, label="Build") self.build_button.Bind(wx.EVT_BUTTON, self.on_build) self.reset_button = wx.Button(self.panel, -1, label="Reset") self.reset_button.Bind(wx.EVT_BUTTON, self.on_reset) self.exit_button = wx.Button(self.panel, -1, label="Exit") self.exit_button.Bind(wx.EVT_BUTTON, self.on_exit) self.vbox1 = wx.BoxSizer(wx.VERTICAL) self.vbox1.Add(self.build_button, 0, flag=wx.CENTER | wx.BOTTOM) self.vbox1.Add(self.reset_button, 0, flag=wx.CENTER | wx.BOTTOM) self.vbox1.Add(self.exit_button, 0, flag=wx.CENTER | wx.BOTTOM) self.hbox2 = wx.BoxSizer(wx.HORIZONTAL) #self.hbox2.Add(self.label_key_box, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.hbox2.Add(self.data_set_control, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.hbox2.Add(self.navigation_control, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.hbox2.Add(self.vbox1, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.vbox2 = wx.BoxSizer(wx.VERTICAL) self.vbox2.Add(self.hbox1, 0, flag=wx.CENTER | wx.TOP) self.vbox2.Add(self.canvas, 1, flag=wx.CENTER | wx.CENTER | wx.GROW) self.vbox2.Add(self.hbox2, 0, flag=wx.LEFT | wx.TOP) self.panel.SetSizer(self.vbox2) self.vbox2.Fit(self)