-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple.py
More file actions
38 lines (28 loc) · 1.07 KB
/
simple.py
File metadata and controls
38 lines (28 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import time
import tkinter as tk
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.mode, self.other_mode = "%c", "%Y%m%d(%w)%H%M%S"
self.grid()
self.createWidgets()
self.showtime()
def showtime(self):
self.time.set(time.strftime(self.mode))
def swap(self):
self.mode, self.other_mode = self.other_mode, self.mode
self.showtime();
def createWidgets(self):
self.time = tk.StringVar()
self.timeButton = tk.Button(self, text='Time', command=self.showtime)
self.modeButton = tk.Button(self, text='Mode', command=self.swap)
self.quitButton = tk.Button(self, text='Quit', command=self.quit)
self.timeLabel = tk.Label(self, textvariable=self.time)
self.timeButton.grid()
self.modeButton.grid(row=0, column=1)
self.quitButton.grid(row=0, column=2)
self.timeLabel.grid(columnspan=3)
if (__name__ == "__main__"):
app = Application()
app.master.title('Sample application')
app.mainloop()