0
您好我一直在为这个项目做一个化学A水平测验的学生。 我做了一组对应于每个TK帧间的类。有几类从主要问题继承的问题。 我不知道为什么我收到此错误,为什么我的代码不工作:Tk面向对象的编程
错误:
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()
@eyllanesc:请不要引用格式回溯。这不是更具可读性,而且您正在积极破坏问题来源中的重要间距信息。 – user2357112
错误来自您未发布的页面类之一 - 我无法分辨哪一个,但它看起来是在第1167行(这是跟踪您的源代码的最后一行,而是比Python库)。你有一个'__init__',它将3个参数传递给继承的'Frame .__ init__',尽管在那里只有两个位置参数是有意义的。 – jasonharper