0
我很新的python和一般编码。我正在尝试制作游戏的应用程序,但似乎无法销毁我创建的框架。Python Tkinter框架销毁
from tkinter import *
class application:
def __init__(self,parent):
self.startContainer = Frame(parent)
self.startContainer.pack()
self.lbl = Label(startContainer,text="Please choose from the following: \nFaith Points (F) \nBanqueting Goods (B) \nEnter Honour (E) ")
self.lbl.pack()
self.btn1 = Button(startContainer,text="Votes",command=self.votes(startContainer)).pack()
self.btn2 = Button(startContainer,text="Gold Tithe",command=self.gold(startContainer)).pack()
def votes(parent,self):
parent.destroy()
def gold(parent,self):
pass
window = Tk()
app = application(window)
window.title("Tools")
window.geometry("425x375")
window.wm_iconbitmap("logo.ico")
window.resizable(width=False, height=False)
window.mainloop()
定义方法时,第一个参数应该是'self'。这适用于投票方式和金牌方式。请参阅此链接(http://stackoverflow.com/questions/2709821/what-is-the-purpose-of-self)以获取更多信息。请注意,“self”的命名仅仅是一个约定,而不是一个保留字。 – arrethra