本文整理匯總了Python中wx.TextAttr方法的典型用法代碼示例。如果您正苦於以下問題:Python wx.TextAttr方法的具體用法?Python wx.TextAttr怎麽用?Python wx.TextAttr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wx
的用法示例。
在下文中一共展示了wx.TextAttr方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _Log
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import TextAttr [as 別名]
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)
示例2: UpdateOSD
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import TextAttr [as 別名]
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()
示例3: ClearHighlights
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import TextAttr [as 別名]
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()
示例4: ShowHighlights
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import TextAttr [as 別名]
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)
示例5: printMem
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import TextAttr [as 別名]
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")
示例6: reset_text
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import TextAttr [as 別名]
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
示例7: GenerateSearchResultsTreeBranch
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import TextAttr [as 別名]
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)