Python wx.TextAttr() Examples
The following are 7
code examples of wx.TextAttr().
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: pyResManDialog.py From pyResMan with GNU General Public License v2.0 | 6 votes |
def _Log(self, msg, level=wx.LOG_Message): """Display log with levels""" if msg.endswith('\r'): msg = msg[ : len(msg) - 1] if msg.endswith('\n'): msg = msg[ : len(msg) - 1] textColor = "#000000" if level == wx.LOG_Info: textColor = "#228B22" elif level == wx.LOG_Error: textColor = "#FF0000" elif level == wx.LOG_Warning: textColor = "#D2691E" elif level == wx.LOG_Message: pass else: pass self._textctrlLog.SetDefaultStyle(wx.TextAttr(colText=textColor)) self._textctrlLog.AppendText(msg + '\n') curSelTo = self._textctrlLog.GetSelection()[1] self._textctrlLog.ShowPosition(curSelTo)
Example #2
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def UpdateOSD(self, data=None): if data: self.GoToCtrl.SetValue(data) if self.pos > -1: pos = self.pos self.GoToCtrl.SetStyle(0, pos, wx.TextAttr(self.fore, self.back, self.fnt)) self.GoToCtrl.SetStyle(pos, pos+1, wx.TextAttr(self.foreSel, self.backSel, self.fnt)) self.GoToCtrl.SetStyle(pos+1, 8, wx.TextAttr(self.fore, self.back, self.fnt)) f = self.fore b = self.back else: self.GoToCtrl.SetStyle(0, 8, wx.TextAttr(self.fore, self.back, self.fnt)) f = self.foreSel b = self.backSel self.gotoLbl.SetBackgroundColour(b) self.gotoLbl.SetForegroundColour(f) self.Refresh()
Example #3
Source File: DataTypeEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
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.GetValueStr() if isinstance(control, CustomIntCtrl) else \ 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()
Example #4
Source File: DataTypeEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def ShowHighlights(self): type_infos = self.Controler.GetDataTypeInfos(self.TagName) for infos, start, end, highlight_type in self.Highlights: if infos[0] == "struct": self.StructureElementsTable.AddHighlight(infos[1:], highlight_type) else: control = self.HighlightControls.get((type_infos["type"], infos[0]), None) if control is not None: if isinstance(control, (wx.ComboBox, wx.SpinCtrl)): control.SetBackgroundColour(highlight_type[0]) control.SetForegroundColour(highlight_type[1]) elif isinstance(control, wx.TextCtrl): control.SetStyle(start[1], end[1] + 1, wx.TextAttr(highlight_type[1], highlight_type[0])) elif isinstance(control, wx.gizmos.EditableListBox): listctrl = control.GetListCtrl() listctrl.SetItemBackgroundColour(infos[1], highlight_type[0]) listctrl.SetItemTextColour(infos[1], highlight_type[1]) listctrl.Select(listctrl.FocusedItem, False)
Example #5
Source File: uicore.py From NXP-MCUBootUtility with Apache License 2.0 | 5 votes |
def printMem( self , memStr, strColor=uidef.kMemBlockColor_Padding ): self.m_textCtrl_bootDeviceMem.SetDefaultStyle(wx.TextAttr(strColor, uidef.kMemBlockColor_Background)) self.m_textCtrl_bootDeviceMem.AppendText(memStr + "\n")
Example #6
Source File: DownloadManager.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def reset_text(self, force=False): self.dont_reset = True if force or self.GetValue() == '': self.SetValue(self.default_text) self.SetStyle(0, len(self.default_text), wx.TextAttr(wx.SystemSettings_GetColour(wx.SYS_COLOUR_GRAYTEXT))) self.dont_reset = False
Example #7
Source File: SearchResultPanel.py From OpenPLC_Editor with GNU General Public License v3.0 | 4 votes |
def GenerateSearchResultsTreeBranch(self, root, infos): 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 | wx.TE_NO_VSCROLL 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) item, root_cookie = self.SearchResultsTree.GetFirstChild(root) 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)