所以我正在创建一个游戏,现在我决定添加一个 GUI。GUI代码如下所示:
master = Tk()
master.wm_title("Main Menu")
a = Button.grid(master, text = "DOMINATE!", command = difficulty)
a.grid(row = 0, column = 0)
a.pack()
mainloop()
b = Button.grid(master, text = "Patch Notes", command = changelog)
b.grid(row = 0, column = 1)
b.pack()
mainloop()
c = Button.grid(master, text = "Credits", command = credit)
c.grid(row = 1, column = 0)
c.pack()
mainloop()
d = Button.grid(master, text = "Rules", command = rules)
d.grid(row = 1, column = 1)
d.pack()
mainloop()
e = Button.grid(master, text = "Quit", command = exit)
e.grid(row = 2, column = 0)
e.pack()
mainloop()
我已经从 Tkinter 导入了函数 *,这只是我 1200 行代码的一个片段。当我尝试运行它时,我收到此错误:
类型错误:必须使用 Button 实例作为第一个参数调用未绑定的方法 grid_configure()(改为获取 Tk 实例)
(Python 对我来说是一种新语言,很抱歉遗漏了任何明显或愚蠢的东西。我对编程也很陌生)。