如题,在参考文档入门 Python GUI 库 tkinter 时,第一步就遇到了下图的报错:
#!/usr/bin/python3
from tkinter import *
root = Tk()
root.update() # 一定要刷新界面,否则打印出的值是1
print("当前窗口的宽度为", root.winfo_width())
print("当前窗口的高度为", root.winfo_height())
root.mainloop()
记录下解决方法:
brew install python-tk@3.9
再次运行: