-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathmvc-before.py
More file actions
40 lines (33 loc) · 1.25 KB
/
mvc-before.py
File metadata and controls
40 lines (33 loc) · 1.25 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
39
40
import tkinter as tk
import uuid
class UUIDGen():
def __init__(self):
# setup tkinter
self.root = tk.Tk()
self.root.geometry("400x400")
self.root.title("UUIDGen")
# create the gui
self.frame = tk.Frame(self.root)
self.frame.pack(fill=tk.BOTH, expand=1)
self.label = tk.Label(self.frame, text="Result:")
self.label.pack()
self.list = tk.Listbox(self.frame)
self.list.pack(fill=tk.BOTH, expand=1)
self.generate_uuid_button = tk.Button(self.frame, text="Generate UUID", command=self.handle_click_generate_uuid)
self.generate_uuid_button.pack()
self.clear_button = tk.Button(self.frame, text="Clear list", command=self.handle_click_clear_list)
self.clear_button.pack()
# initialize the uuid list
self.uuid = []
# start the loop
self.root.mainloop()
def handle_click_generate_uuid(self):
# generate a uuid and add it to the list
self.uuid.append(uuid.uuid4())
self.list.insert(tk.END, self.uuid[-1])
def handle_click_clear_list(self):
# clear the uuid list and delete it from the list
self.uuid = []
self.list.delete(0, tk.END)
# start the application
u = UUIDGen()