我想下载一个开源字体并在我的 Python Tkinter 程序中使用它。
如何告诉 Tkinter 从目录导入字体或将字体放在与程序相同的文件夹中?
注意: 我已经搜索了一段时间的答案,甚至阅读了 Tkinter 的关于我能找到的所有字体相关内容的 API 参考。如果这个问题有一个明显的答案而我不知道,因为也许我没有足够努力地搜索或问错了问题,我很抱歉。
我在 Python2 和 Python3 中尝试了相同的代码,看看 wm 属性是否可以在 Python3 中工作(我通常使用 Python2)
root.call("wm", "attributes", ".", "-zoomed", "True")
root.attributes('-zoomed', True)
root.wm_attributes('-zoomed', True)
Run Code Online (Sandbox Code Playgroud)
但它给了我这个错误:
_tkinter.TclError: wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"
Run Code Online (Sandbox Code Playgroud)
我也试过这些:
root.wm_state('-zoomed', True)
root.state('-zoomed', True)
Run Code Online (Sandbox Code Playgroud)
但给了我这个错误:
TypeError: wm_state() takes at most 2 arguments (3 given)
Run Code Online (Sandbox Code Playgroud)
我正在使用 Windows 7,尽管它似乎适用于也在使用 Windows 7 的 @ParvizKarimli。
我做错了吗?是否有另一种方法可以最大化窗口?