【发布时间】:2017-07-15 06:03:46
【问题描述】:
我正在尝试在 tkinter 中制作一个文本编辑器。
我正在更改标签属性上的字体大小和字体系列,但问题是当我更改字体系列时,所选文本的大小恢复为默认值,而当我更改字体大小时,字体系列恢复为默认值。 我尝试了很多东西
def changeFontSize2():
textPad.tag_add("bt2", "sel.first", "sel.last")
textPad.tag_config("bt2",font = (False,2))
def changeFontSize6():
textPad.tag_add("bt6", "sel.first", "sel.last")
textPad.tag_config("bt6",font = (False,6))
def changeFontFamily1():
textPad.tag_add("btArial", "sel.first", "sel.last")
textPad.tag_config("btArial",font = ("Arial",False))
def changeFontFamily2():
textPad.tag_add("btCourierNew", "sel.first", "sel.last")
textPad.tag_config("btCourierNew",font = ("Courier New",False))
【问题讨论】:
-
我现在要去某个地方。我会在晚上检查。希望我能得到一个有用的答案
-
我认为这确实是 tkinter 的极限 :(。但我仍然希望我能在明天得到完美的答案。请通过一些代码进行评估。我现在要睡觉了。晚安
-
这不是 tkinter 的限制。在您发布的代码中,您将
False作为家庭(或大小)传递,这是不正确的用法。您不能将False作为这些参数之一传递。这里唯一的限制是您的代码中的限制。
标签: python python-2.7 tkinter tkinter-canvas