【发布时间】:2013-05-12 23:01:09
【问题描述】:
我正在使用 wxpython 用 python 创建 GUI,现在,有没有办法为文本的特定部分着色?
示例(使用 Tkinter):
http://i.stack.imgur.com/fGAVA.png
这是我的打印功能:
def Print(self, String):
''' Print Received Data '''
self.text_serverLog.AppendText(datetime.now().strftime("[%H:%M:%S] " + String + "\n"))
我找到了函数SetForegroundColour,但遗憾的是它的颜色是整个TextCtrl。
我正在使用 Win7、python 2.7、wxpython。 谢谢。
【问题讨论】:
-
确保您指定了 text.SetForegroundColour 参见stackoverflow.com/questions/1785227/…
-
我不认为你可以用
TextCtrl做到这一点,但你应该可以用RichTextCtrl做到这一点。 -
如果您访问wxPython download page,并下载/安装
wxPython2.8-win32-docs-demos安装程序,会有一堆有用的演示(带有完整的源代码),其中包括一个您正在尝试做的示例. -
谢谢大家,我现在正在使用
RichTextCtrl对象。以下是如何为特定文本着色的示例:stackoverflow.com/questions/7734028/…
标签: python user-interface wxpython textctrl wxtextctrl