当使用tkinter时,我总是得到这个错误返回。它只出现在这个代码示例中,并且似乎起源于the.pack()行。
代码语言:javascript复制Callback :
Traceback (most recent call last):
File "c:\Users\celia\Desktop\ZackAi\zackaitkinter.py", line 16, in
myPad.pack(root)
File "C:\Users\celia\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 2398, in pack_configure
+ self._options(cnf, kw))
File "C:\Users\celia\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1473, in _options
cnf = _cnfmerge(cnf)
File "C:\Users\celia\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 109, in _cnfmerge
for c in _flatten(cnfs):
TypeError: object of type 'Tk' has no len()代码:
代码语言:javascript复制import random
from tkinter import *
while True :
root = Tk()
Greeting ="Dydh da !"
choicelist = "language practise(A), positive message (B) or a idea for thought (C)"
thing = ["You are doing well", "You look cute", "Keep smiling"]
myPad= Label(root, text = Greeting)
myPad2 = Label(root, text ="please type Yes to start")
myPad.pack(root)
myPad2.pack(root)
e = Entry(root, borderwidth= 70)
e.pack()
varrr= e.get()
if varrr == "Yes" or "yes":
labelthree = Label(root, "choose a task")
labelfour = Label(root, "language, happy message and ideas for thoughts")
labelthree.pack(root)
labelfour.pack(root)
e2 = Entry(root,borderwidth =50)
e.pack()
else:
labelstop =Label(root, text= "No problem")
root.mainloop()