您好我一直致力于为学生制作化学A级测验。 我创建了一组对应于每个TK帧间的类。有一类问题从主要问题继承而来。 我不知道为什么我收到此错误以及为什么我的代码无效:
ERROR:
Traceback (most recent call last):
File "/Users/ammarhusain/Desktop/Computing Project/Ammar Chemistry Program
FINAL.py", line 3376, in <module>
quiz = Main()
File "/Users/ammarhusain/Desktop/Computing Project/Ammar Chemistry Program FINAL.py", line 3360, in __init__
frame = F(container, self)
File "/Users/ammarhusain/Desktop/Computing Project/Ammar Chemistry Program FINAL.py", line 1167, in __init__
tk.Frame.__init__(self, parent,controller)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/tkinter/__init__.py", line 2583, in __init__
Widget.__init__(self, master, 'frame', cnf, {}, extra)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/tkinter/__init__.py", line 2138, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: unknown option "-use"
主要代码:
class Main(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
container = tk.Frame(self)
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
for F in (STUDENTLOGINPAGE,STAFFLOGINPAGE,STARTPAGE,STAGE1,STAGE2,STAGE3,STAGE4,STAGE5,LEADERBOARDPAGE):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row = 0, column = 0, sticky = "nsew")
self.show_frame(STUDENTLOGINPAGE)
if self.frames == []:
print ("Error in loading program")
#This class inherits from Tk class within module of Tk Inter
#This basically displays each page in turn from the List
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
quiz = Main()
quiz.mainloop()
答案 0 :(得分:0)
您需要从此行中删除,controller
:
tk.Frame.__init__(self, parent,controller)
controller
是一个对于子类唯一的参数,并不是基类支持的参数。