本文整理汇总了Python中tkinter.Entry.destroy方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.destroy方法的具体用法?Python Entry.destroy怎么用?Python Entry.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Entry
的用法示例。
在下文中一共展示了Entry.destroy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TimeClock
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import destroy [as 别名]
class TimeClock(Frame):
def __init__(self, parent, *args, **kwargs):
Frame.__init__(self,parent, *args, **kwargs)
self.e=Entry(self,text='Message')
self.e.delete(0,"end")
self.e.pack()
self.makebuttons()
self.pack( expand='true', fill='x')
def makebuttons(self):
self.b1 = Button(self, text="Tock" ,
bg='BLUE', activebackground="Blue",
activeforeground='White',fg='white',
height='2', width='8' , command = self.write )
self.b2 = Button(self, text="Tick",
activebackground='red', bg='red',
activeforeground='White',fg='white',
command = self.quit )
self.b1.pack(side='right', fill='both')
self.b2.pack(side='left', fill='both')
self.lastTime = ""
self.start_timer()
def start_timer(self):
def callback():
#self.message=self.e.delete(0,"end")
self.message=self.e.get()
print ("input text is equal to->",self.message)
root.title(self.message+":TIMER")
self.e.destroy()
self.B.destroy()
self.B= Button(self,text='start', command=callback)
self.B.pack()
t=time.localtime()
self.zeroTime = dt.timedelta(hours=t[3], minutes=t[4], seconds=t[5])
self.tick()
def tick(self):
self.now = dt.datetime(1, 1, 1).now()
elapsedTime = self.now - self.zeroTime
time2 = elapsedTime.strftime('%H:%M:%S')
if time2 != self.lastTime:
self.lastTime = time2
self.b1.config(text=time2)
self.b2.config(text=self.now.strftime('%I:%M:%S'))
self.after(20, self.tick)
def write(self):
g=time.localtime()
Datename = dt.datetime(1,1,1).now().strftime('%Y%m%d')
my_Time = dt.timedelta(hours=g[3], minutes=g[4], seconds=g[5])
#filename="C:\Users\jpeters\Timer.log\\"+Datename+"_demo.csv"
filename="/home/jeff/Desktop/"+Datename+"_demo.csv"
file =open(filename, 'a' )
file.write(str(Datename))
file.write(', ')
file.write(str(my_Time))
file.write(', ')
file.write((self.lastTime))
file.write(', ')
file.write(str(self.message))
file.write('\n')
file.close()
self.start_timer()
def quit(self):
self.write()
root.destroy()