如何以不同的颜色为 StaticText (wxpython) 中的文本着色? [英] How to colour text in StaticText (wxpython) in different colours?

查看:28
本文介绍了如何以不同的颜色为 StaticText (wxpython) 中的文本着色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将 wxpython 中的 StaticText 字段的文本以不同颜色着色?我知道您可以像这样更改 StaticText 字段的整个文本(值)的颜色:

Is it somehow possible to have text of a StaticText field in wxpython coloured in different colours? I know you can change the colour of the whole text (value) of a StaticText field like this:

text = wx.StaticText(panel, -1, 'random text')
text.SetForegroundColour('blue')

但是我怎样才能将文本着色为不同的颜色,例如随机"为红色,文本"为蓝色.有办法吗?或者我可以使用其他某种小部件吗?

But how can I have the a text coloured in different colours, for example 'random' coloured in red and 'text' coloured in blue. Is there a way? Or is there some kind of other widget I could use?

推荐答案

wx.StaticText 小部件不支持这类事情.您可能希望改用其中一种 StyledText 控件.RichText 控件也可能会起作用.

The wx.StaticText widget doesn't support that sort of thing. You'd want to use one of the StyledText controls instead. the RichText control would probably work too.

这篇关于如何以不同的颜色为 StaticText (wxpython) 中的文本着色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆