[英]Tkinter Text widget: Configure font
I have Text
widget that I can configure the font families by: 我有
Text
小部件,可以通过以下方式配置字体系列:
textwidget.config(font=(Consolas,13))
That would configure the whole text
Widget. 这将配置整个
text
Widget。 I only want to tell Tkinter
I want to make every input after the Text
widget has been configured to be like how I changed it. 我只想告诉
Tkinter
我想在将Text
小部件配置为类似于我对其进行更改后进行的所有输入。
How can I achieve this. 我该如何实现。 Thanks for any help !!
谢谢你的帮助 !!
Have a look at the tag
commands. 看一下
tag
命令。 You can change the selected text using this code: 您可以使用以下代码更改所选文本:
number=0
def fontchange():
textwidget.tag_add(str(number), SEL_FIRST, SEL_LAST)
textwidget.tag_config(str(number), font=(Consolas,13))
number += 1
Obviously this is a very basic changer but if you want to change it to the end you could change the SEL_LAST to END. 显然,这是一个非常基本的更改器,但是如果要将其更改为末尾,则可以将SEL_LAST更改为END。 Read this site for more info on tags.
阅读此站点以获取有关标签的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.