【发布时间】:2019-01-22 10:13:39
【问题描述】:
我在 win 10 上使用 anurati(如果你不知道它是什么,请用谷歌搜索)字体我尝试从 tkinter 调用它以接收错误
我的代码是:
from tkinter import *
root = Tk()
root.title("P.E.T.A.R")
txt = Label(root, text = "welcome to project petar")
txt.grid(column = 0, row = 0, font=("Anurati Regular"))
错误是
================ RESTART: C:\Users\dell\Desktop\p.e.t.a.r.py ================
Traceback (most recent call last):
File "C:\Users\dell\Desktop\p.e.t.a.r.py", line 6, in <module>
txt.grid(column = 0, row = 0, font=("Anurati Regular", 50))
File "C:\Users\dell\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 2082, in grid_configure
+ self._options(cnf, kw))
_tkinter.TclError: bad option "-font": must be -column, -columnspan, -in, -ipadx, -ipady, -padx, -pady, -row, -rowspan, or -sticky
>>>
为什么会这样
【问题讨论】:
-
只使用文字的图片会更好吗?
-
为什么在
grid方法中使用字体? -
@elitegamer88 不,最好使用图像。添加新内容或更新时,它会很快变老。您只需要修复一些小错误即可使其正常工作。有关问题的解释,请参阅我的答案。
-
错误很明显:
font不是grid命令的有效选项。 -
没那么拘谨
标签: python tkinter fonts label