_Tkinter错误:预期整数但得到“Serif”

2024-04-29 02:05:20 发布

您现在位置:Python中文网/ 问答频道 /正文

正在尝试更改tkinter中的字体。 按钮一直工作到我到7号 我猜塞里夫女士是两个词, 通常我会在2个单词周围加上““ 但我不能用我写程序的方式。在

我的问题是如何修复我的函数以接受字体 有两个词的名字。在

输出如下:

Counter:  1  Fontz:  Terminal 12 bold
Counter:  2  Fontz:  Fixedsys 12 bold
Counter:  3  Fontz:  Modern 12 bold
Counter:  4  Fontz:  Roman 12 bold
Counter:  5  Fontz:  Script 12 bold
Counter:  6  Fontz:  Courier 12 bold
Counter:  7  Fontz:  MS Serif 12 bold
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Slim 960\AppData\Local\Programs\Py
    return self.func(*args)
  File "Tkinter001.py", line 83, in button_font
    logo = tk.Label(root, compound = tk.CENTER, tex
.grid(row=0, column=0)
  File "C:\Users\Slim 960\AppData\Local\Programs\Py
    Widget.__init__(self, master, 'label', cnf, kw)
  File "C:\Users\Slim 960\AppData\Local\Programs\Py
    (widgetName, self._w) + extra + self._options(c
_tkinter.TclError: expected integer but got "Serif"

代码:

^{pr2}$

Tags: inpyselftkinterlocalcounter字体users