我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用wx.NullColour()。
def __init__(self): app = wx.App() self.frame = MainWindow(None, "Bonsu - The Interactive Phase Retrieval Suite") self.nb = wx.Notebook(self.frame) self.nb.AddPage(PanelPhase(self.nb), "Phasing Pipeline") self.nb.AddPage(PanelVisual(self.nb), "Visualisation") self.nb.AddPage(PanelGraph(self.nb), "Graph") self.nb.AddPage(PanelScript(self.nb), "Python Prompt") self.nb.AddPage(PanelStdOut(self.nb), "Log") self.frame.nb = self.nb self.frame.sizer.Add(self.nb, 1, wx.ALL|wx.EXPAND, 5) self.frame.SetBackgroundColour(wx.NullColour) self.frame.SetSizer(self.frame.sizer) self.frame.Fit() self.frame.Show() self.frame.OnFileArg() app.MainLoop()
def ClearHighlights(self, highlight_type=None): if highlight_type is None: self.Highlights = [] else: self.Highlights = [(infos, start, end, highlight) for (infos, start, end, highlight) in self.Highlights if highlight != highlight_type] for control in self.HighlightControls.itervalues(): if isinstance(control, (wx.ComboBox, wx.SpinCtrl)): control.SetBackgroundColour(wx.NullColour) control.SetForegroundColour(wx.NullColour) elif isinstance(control, wx.TextCtrl): value = control.GetValue() control.SetStyle(0, len(value), wx.TextAttr(wx.NullColour)) elif isinstance(control, wx.gizmos.EditableListBox): listctrl = control.GetListCtrl() for i in xrange(listctrl.GetItemCount()): listctrl.SetItemBackgroundColour(i, wx.NullColour) listctrl.SetItemTextColour(i, wx.NullColour) self.StructureElementsTable.ClearHighlights(highlight_type) self.RefreshView()
def __init__(self, parent, name, init, stextwidth): def OnEdit(event): text = event.GetString() point = self.value.GetInsertionPoint() if (IsNumber(self.value.GetValue()) == False): self.value.SetBackgroundColour( "Pink" ) self.value.SetForegroundColour( "Black" ) else: self.value.SetBackgroundColour(wx.NullColour) self.value.SetForegroundColour(wx.NullColour) self.value.ChangeValue(text) self.value.SetInsertionPoint(point) fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize() self.font = wx.Font(fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) wx.BoxSizer.__init__(self, wx.HORIZONTAL) dc = wx.ScreenDC() dc.SetFont(self.font) textw,texth = dc.GetTextExtent(name) if textw > stextwidth: labelw = textw else: labelw = stextwidth self.label = StaticTextNew(parent, -1, name, style =wx.ALIGN_RIGHT, size=(labelw,-1) ) self.label.SetFont(self.font) self.Add( self.label, 0, wx.CENTER ) self.value = TextCtrlNew(parent, value=str(init), style=wx.TE_PROCESS_ENTER) self.value.SetWindowStyle(wx.TE_RIGHT) self.value.SetFont(self.font) self.value.Bind(wx.EVT_TEXT, OnEdit) self.Add( self.value, 1, wx.CENTER|wx.EXPAND )
def onReset(self, event): """ Reset the color of the panel to the default color """ self.panel.SetBackgroundColour(wx.NullColour) self.txt.SetBackgroundColour(wx.NullColour) self.panel.Refresh()
def darkMode(self, normalPanelColor): """ Toggles dark mode """ widgets = getWidgets(self) panel = widgets[0] if normalPanelColor == panel.GetBackgroundColour(): dark_mode = True else: dark_mode = False for widget in widgets: if dark_mode: if isinstance(widget, ObjectListView) or isinstance(widget, wx.ListCtrl): darkRowFormatter(widget, dark=True) widget.SetBackgroundColour("Dark Grey") widget.SetForegroundColour("White") else: if isinstance(widget, ObjectListView) or isinstance(widget, wx.ListCtrl): darkRowFormatter(widget) widget.SetBackgroundColour("White") widget.SetForegroundColour("Black") continue widget.SetBackgroundColour(wx.NullColour) widget.SetForegroundColour("Black") self.Refresh() return dark_mode
def SetBackgroundColour(self,color): wx.PyPanel.SetBackgroundColour(self,color) self._drawSashInBackgroundColour = True if wx.NullColour == color: self._drawSashInBackgroundColour = False
def __init__(self, parent, name, smax, smin, sinc, sinit, stextwidth, swidth): if abs(sinc) < 1.0: self.precision = "%."+str(str(sinc)[::-1].find('.'))+"f" else: self.precision = "%d" def OnSpin(pos): self.value.ChangeValue(self.precision%(sinc * pos + self.remainder)) def OnEdit(event): text = event.GetString() point = self.value.GetInsertionPoint() if (IsNumber(self.value.GetValue()) == False): self.value.SetBackgroundColour( "Pink" ) self.value.SetForegroundColour( "Black" ) else: self.value.SetBackgroundColour(wx.NullColour) self.value.SetForegroundColour(wx.NullColour) self.value.ChangeValue(text) self.value.SetInsertionPoint(point) if ( text == '' or text == '.'): self.spin.SetValue(smin/sinc); try: self.spin.SetValue(int(float(text)/sinc)) except: pass event.Skip() fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize() self.font = wx.Font(fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) dc = wx.ScreenDC() dc.SetFont(self.font) textw,texth = dc.GetTextExtent(name) if textw > stextwidth: labelw = textw else: labelw = stextwidth wx.BoxSizer.__init__(self, wx.HORIZONTAL) self.label = StaticTextNew(parent, -1, name, style=wx.ALIGN_RIGHT, size=(labelw,-1) ) self.label.SetFont(self.font) self.Add( self.label, 0, wx.CENTER ) self.value = TextCtrlNew(parent, value=str(sinit),size=(swidth, -1), style=wx.TE_PROCESS_ENTER) self.value.SetWindowStyle(wx.TE_RIGHT) self.value.SetFont(self.font) self.value.Bind(wx.EVT_TEXT, OnEdit) self.Add( self.value, 0, wx.CENTER ) bw,bh = dc.GetTextExtent("0") spinw = int(1.5*bh) self.spin = SpinButtonNew(parent, size=(spinw,-1), spinfunc=OnSpin) self.spin.SetRange(int(smin/sinc), int(smax/sinc)) self.spin.SetValue(int(sinit/sinc)) self.remainder = smin%sinc self.Add( self.spin, 0, wx.CENTER ) self.IsEnabled = True self.Layout() self.Show()