gpt4 book ai didi

python 3.3 : Is it possible to put unicode characters on buttons with tkinter?

转载 作者:太空宇宙 更新时间:2023-11-04 10:41:48 24 4
gpt4 key购买 nike

我正在尝试找到一种将 unicode 字符放在按钮上的方法。

比如我的想法是这样的:

checkButton = Button(root, height=5, width=10, image=u"\u2713")

不幸的是,我收到了这个错误:

File "C:\Python33\lib\tkinter\__init__.py", line 2075, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: image "✓" doesn't exist

有谁知道我可以做这样的事情的方法吗?

最佳答案

您设置了错误的属性。 image 适用于您想要一个带有图像的按钮(它指定图像的路径)。您需要 text 属性。尝试:

checkButton = Button(root, height=5, width=10, text=u"\u2713")

并根据http://tkinter.unpythonic.net/wiki/UnicodeSupport :

For most systems, Tkinter should accept unicode strings and render them more or less properly

另见 http://effbot.org/tkinterbook/button.htm

关于 python 3.3 : Is it possible to put unicode characters on buttons with tkinter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20155488/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com