本文整理汇总了Python中tkinter.Button.destroy方法的典型用法代码示例。如果您正苦于以下问题:Python Button.destroy方法的具体用法?Python Button.destroy怎么用?Python Button.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Button
的用法示例。
在下文中一共展示了Button.destroy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import destroy [as 别名]
class Menu:
def __init__(self, master):
self.master = master
master.title("TicTacToe")
self.label_index = 0
self.label_text = StringVar()
self.label_text.set('TicTacToe')
self.lable = Label(master, textvariable=self.label_text)
self.lable.pack()
self.start_button = Button(master, text='Start', command=self.start)
self.start_button.pack()
def start(self):
self.lable.destroy()
self.start_button.destroy()
self.play()
def play(self):
Play(self.master)
示例2: game
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import destroy [as 别名]
class game(object):
def __init__(self):
self.root = Tk()
self.root["width"]=logix.WIDTH*(CARDW+PAD)+3*PAD
self.root["height"]=logix.HEIGHT*(CARDH+PAD)+3*PAD + 50
self.root.title("Unocolour")
self.mainscreen()
self.root.mainloop()
def mainscreen(self):
self.gamename = tkinter.Label(self.root, text = "UNOCOLOUR", font = ("Ariel", 24))
self.gamename.place(x=(logix.WIDTH*(CARDW+PAD)+3*PAD-400)//2, y=10, width = 400, height = 25)
self.startbutton = Button(text = "Start", command=self.startgame)
self.startbutton.place(x=(logix.WIDTH*(CARDW+PAD)+3*PAD-100)//2, y=60, width = 100, height = 25)
def startgame(self):
self.cardcounter = tkinter.Label(text = "Cards: 108")
self.cardcounter.place(x=10, y=25)
self.lvltitle = tkinter.Label(text = "Level I")
self.lvltitle.place(x=10, y=10)
self.b=board(self.root, self)
self.b.place(x=10,y=50)
self.startbutton.destroy()
del self.startbutton
def endgame(self):
self.b.destroy()
self.cardcounter.destroy()
self.lvltitle.destroy()
del self.b, self.cardcounter, self.lvltitle
self.mainscreen()
def update_counter(self, n):
self.cardcounter["text"] = "Cards: {}".format(n)
def update_level(self, n):
self.lvltitle["text"] = "Level {}".format(romanik(n))
示例3: Example
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import destroy [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("EGUANA")
self.style = ttk.Style()
self.style.theme_use("alt")
self.photoName = "eguana.gif"
self.frame = Frame(self, relief=FLAT, borderwidth=10,bg='#FADC46')
self.frame.pack(fill=BOTH, expand=True)
self.pack(fill=BOTH, expand=True)
self.setupMenuBar()
self.setupTopBar()
def setupMenuBar(self):
self.menubar = EguanaMenu(self.parent,self)
self.parent.config(menu=self.menubar)
def setupTopBar(self):
self.openButton3D = Button(self.frame,text="Select Directory for 3D EMA",relief=RAISED,command=self.askDirectory)
self.openButton3D.grid(row=0,column=0, sticky=N+S+E+W,padx=2,pady =2)
self.openButton2D = Button(self.frame,text="Select Directory for 2D EMA",relief=RAISED,command=self.askDirectory);
self.openButton2D.grid(row=2,column=2, sticky=N+S+E+W,padx=2,pady =2)
self.p1Button = Button(self.frame,text="Placeholder",relief=RAISED)
self.p1Button.grid(row=0,column=1, sticky=N+S+E+W,padx=2,pady =2)
self.p2Button = Button(self.frame,text="Placeholder",relief=RAISED)
self.p2Button.grid(row=0,column=2, sticky=N+S+E+W,padx=2,pady =2)
self.p3Button = Button(self.frame,text="Placeholder",relief=RAISED)
self.p3Button.grid(row=1,column=0, sticky=N+S+E+W,padx=2,pady =2)
self.p4Button = Button(self.frame,text="Placeholder",relief=RAISED)
self.p4Button.grid(row=1,column=2, sticky=N+S+E+W,padx=2,pady =2)
self.p5Button = Button(self.frame,text="Placeholder",relief=RAISED)
self.p5Button.grid(row=2,column=0, sticky=N+S+E+W,padx=2,pady =2)
self.p6Button = Button(self.frame,text="Placeholder",relief=RAISED)
self.p6Button.grid(row=2,column=1, sticky=N+S+E+W,padx=2,pady =2)
self.openButton3D.bind('<Motion>',self.cursorPosition)
self.openButton2D.bind('<Motion>',self.cursorPosition)
self.photo = PhotoImage(file="eguana.gif")
self.photo = self.photo.subsample(2);
self.photo_label = Label(self.frame,image=self.photo,borderwidth=0,highlightthickness=0)
self.photo_label.configure(bg='#FADC46')
self.photo_label.grid(row=1,column=1, sticky=N+S+E+W,padx=2,pady =2)
self.photo_label.image = self.photo
self.frame.columnconfigure(0, weight=1)
self.frame.columnconfigure(1, weight=1)
self.frame.columnconfigure(2, weight=1)
self.frame.rowconfigure(0, weight=1)
self.frame.rowconfigure(1, weight=1)
self.frame.rowconfigure(2, weight=1)
def askDirectory(self):
dirStr = filedialog.askdirectory()
if len(dirStr):
self.openButton3D.destroy()
self.openButton2D.destroy()
self.p1Button.destroy()
self.p2Button.destroy()
self.p3Button.destroy()
self.p4Button.destroy()
self.p5Button.destroy()
self.p6Button.destroy()
self.menubar.entryconfigure('Filter', state = 'active')
self.photo_label.destroy()
dirStr = 'Input Path : '+dirStr
self.frame.grid_forget()
self.infoFrame = Frame(self.frame, relief=FLAT, bg='#FADC46')
self.infoFrame.grid(row=0,column=0,columnspan=3, sticky=N+S+E+W,padx=2,pady =2)
self.directoryLabel = Label(self.infoFrame, text="No project currently selected",relief=FLAT)
self.directoryLabel.grid(row=0,column=0,columnspan=2, sticky=N+S+E+W,padx=2,pady =2)
#.........这里部分代码省略.........
示例4: TrendProg
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import destroy [as 别名]
class TrendProg(Frame):
def __init__(self, parent):
Frame.__init__(self, parent, background='white')
# saved reference to parent widget. "Tk root window"
self.parent = parent
self._workbook = None
self._file_path = None
self._folder_path = None
# set properties of buttons
self.frame_1 = Frame(self, relief=RAISED)
self.run_button = Button(self, text='Run', width=10,
command=self.run_program)
self.file_button = Button(self.frame_1, text='Select File',
width=15, command=self.get_file)
self.folder_button = Button(self.frame_1, text='Select Folder',
width=15, command=self.get_folder)
self.close_button = Button(self, text='Close', width=10,
command=self.quit)
self.init_gui()
def init_gui(self):
self.parent.title('Trending Analysis')
# fill frame to take up whole of root window
self.pack(fill=BOTH, expand=True)
self.frame_1.pack(fill=BOTH, expand=True)
# put buttons on GUI
self.folder_button.pack(side=RIGHT, padx=5)
self.file_button.pack(side=LEFT, padx=5, pady=5)
self.close_button.pack(side=RIGHT, padx=5, pady=5)
self.run_button.pack(side=RIGHT, pady=5)
def get_file(self):
self._file_path = filedialog.askopenfilename()
if self._file_path != '':
self.file_button.config(text='File Selected!')
self.file_button.pack(fill=BOTH, expand=True, padx=5, pady=5)
self.folder_button.destroy()
def get_folder(self):
self._folder_path = filedialog.askdirectory()
if self._folder_path != '':
self.folder_button.config(text='Folder Selected!')
self.folder_button.pack(fill=BOTH, expand=True, padx=5, pady=5)
self.file_button.destroy()
def run_program(self):
workbook = 'Draft_Detail_Findings.xlsx'
worksheet = 'Template'
# user selected one CAPA
print('=' * 75)
if self._folder_path == '' or self._folder_path is None:
self._file_path = self.convert_to_docx(self._file_path)
docx_to_xlsx.main(self._file_path, workbook, worksheet)
print('=' * 75)
# user selected a folder of CAPA's
elif self._file_path == '' or self._file_path is None:
for f in os.listdir(self._folder_path):
# get full path name
file_name = str(self._folder_path + '/' + f)
file_name = self.convert_to_docx(file_name)
docx_to_xlsx.main(file_name, workbook, worksheet)
print('=' * 75)
# get ready to end the program
# pd = project_data.TrendData(workbook, worksheet)
print('Done.')
self.frame_1.destroy()
self.run_button.destroy()
self.close_button.config(text='Done.')
self.close_button.pack(fill=BOTH, expand=True, padx=10, pady=10)
@classmethod
def convert_to_docx(cls, file_selected):
""" Check that file(s) selected is .docx NOT .doc and convert if needed. """
if str(file_selected).endswith('.docx'):
return file_selected
else:
new_file_name = re.sub('.doc', '.docx', file_selected)
# full path to wordconv.exe
word_conv = r'C:\Program Files (x86)\Microsoft Office\Office12\wordconv.exe'
commands = ['wordconv.exe', '-oice', '-nme', file_selected, new_file_name]
try:
print('CONVERTING {}'.format(file_selected))
subprocess.Popen(commands, executable=word_conv)
# wait for converted file to be created
while not os.path.exists(new_file_name):
time.sleep(1.5)
print('REMOVING old .doc file ...')
os.remove(file_selected)
return new_file_name
except OSError:
print('FAILED to convert file. Check to see if it exists.')
示例5: Frontend
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import destroy [as 别名]
class Frontend():
def __init__(self,x,y,b):
self.x=str(x) #1600
self.y=str(y) #900
self.pressed=0
self.b=10
self.c=30
self.grapher=0
self.graph=[0,0,0,0]
self.root=b
def startwindow(self):
# self.root=Tk()
a=str(self.x+'x'+self.y)
self.root.title('Wahrscheinlichkeinten & Simulation')
self.root.geometry(a)
self.g=Label(self.root,bg='white')
self.g.place(x=0,y=0,width=self.x,height=self.y)
# self.g.bind('<1>',self.optioncanged)
self.lst1 = ['Marriage','Atom','BubbleGum','House_of_Cards','Lotto','SecretSanta','Coins']
self.var1 = StringVar(self.root)
self.var1.set('Marriage')
self.drop = OptionMenu(self.root,self.var1,*self.lst1)
self.drop.config(font=('Arial',(30)),bg='white')
self.drop['menu'].config(font=('calibri',(20)),bg='white')
self.drop.pack(side=TOP)
self.photo = PhotoImage(file='z1.gif')
self.label = Label(image=self.photo,borderwidth=0)
self.label.image = self.photo
self.label.bind('<1>',self.MouseOneDown)
self.label.place(y=0,x=int(self.x)-200)
self.startbutton=Button(self.root,text='Start',font=('Arial',40),bg='#B4045F',borderwidth=5,command=self.startpressed)
self.startbutton.place(x=0,y=int(self.y)-100,width=int(self.y)-200,height=100)
self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='green',borderwidth=5,command=self.csvpressed)
self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100)
def startpressed(self):
if self.grapher==1:
for x in range(len(self.graph)):
if self.graph[x]!=0:
self.graph[x].destroy()
self.grapher=0
self.root.update()
a=self.var1.get()
if self.pressed==1:
try:
self.b=int(self.changer0.get('1.0','end-1c'))
except (AttributeError,TclError,ValueError):
self.b=10
try:
self.c=self.changer2.get('1.0','end-1c')
except (AttributeError,TclError,ValueError):
self.c=1
if a=='Marriage':
self.run0=Marriage(self.b)
self.run0.DEBUG=False
self.run0.sim()
elif a=='Atom':
self.c=float(self.c)
self.run1=Atom(self.c,self.b)
self.run1.DEBUG=False
self.run1.sim()
elif a=='BubbleGum':
self.run2=BubbleGum(self.b)
self.run2.DEBUG=False
self.run2.sim()
self.grapher=1
self.graph=[0,0]
g=str(round(self.run2.getrel()[0],4))
h=str(round(self.run2.getrel()[1],4))
self.graph[0]=Label(self.root,bg='white',text='Durchschnitt Karten zu viel: '+g,font=('calibri',19))
self.graph[0].place(x=10,y=450)
self.graph[1]=Label(self.root,bg='white',text='Durchschnitt dass es passiert: '+h,font=('calibri',19))
self.graph[1].place(x=10,y=500)
elif a=='House_of_Cards':
if self.c=='':
self.c=0
else:
self.c=int(self.c)
self.run3=House_of_Cards(self.b,self.c)
self.run3.DEBUG=False
self.run3.sim()
self.grapher=1
self.graph=[0]
self.graph[0]=Label(self.root,bg='white',text=('Durchschnitt: '+str(round(self.run3.getrel(),4))),font=('calibri',19))
self.graph[0].place(x=10,y=450)
elif a=='Lotto':
self.run4=Lotto(self.b)
self.run4.DEBUG=False
self.run4.sim()
x=4
y=1
count=0
self.graph=[0,0,0,0]
self.grapher=1
self.graph[0]=Label(self.root,bg='black')
self.graph[0].place(x=10,width=10+(int(self.x)*0.8),height=1,y=int(self.y)-int(self.y)/4*0.5-350)
self.graph[1]=Label(self.root,text='50%',bg='white',font=('calibri',10))
self.graph[1].place(x=60+(int(self.x)*0.8),width=50,height=50,y=int(self.y)-int(self.y)/4*0.5-375)
self.graph[2]=Label(self.root,bg='black')
self.graph[2].place(x=10,width=20,height=1,y=int(self.y)-350)
self.graph[3]=Label(self.root,bg='black')
#.........这里部分代码省略.........