我对python很陌生,我遇到了一个类型错误,但我个人看不出来。我们将不胜感激。我用的是Windows7
错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "C:\Users\Kids\Desktop\Python Tests\Clock2.py", line 18, in mclock
mlable = Label(mGui, str(z), "minute(s) has past.").pack()
TypeError: __init__() takes from 1 to 3 positional arguments but 4 were given
代码:
import sys
from tkinter import *
from tkinter import messagebox
from tkinter import filedialog
import os
from time import sleep
def mclock():
x = 1
z = 0
while x != -1:
mlable = Label(mGui,text = "str(x) second(s)").pack()
x = x+1
sleep(1)
if x == 60:
x = 1
z = z+1
mlable = Label(mGui, str(z), "minute(s) has past.").pack()
return
mGui = Tk()
mGui.geometry("300x200+100+100")
mGui.title("Jono's Clock")
menubar = Menu(mGui)
filemenu = Menu(menubar, tearoff = 0)
filemenu.add_command(label = "Clock",command = mclock)
menubar.add_cascade(label = "File",menu = filemenu)
mGui.config(menu = menubar)
mGui.mainloop()
另外,如果有人知道haw添加一个clear函数来清除每次滴答滴答的秒数,也会很感激
与所有Python方法一样,标签初始值设定项具有
self
第一个参数。它最多只接受两个附加的位置参数(主参数和cfg
参数),但是您给出了3个:你可能想连接这两个字符串;您必须将其显式地作为
text
关键字参数传入:相关问题 更多 >
编程相关推荐