-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·64 lines (46 loc) · 1.49 KB
/
main.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
from os.path import basename, splitext
import tkinter as tk
# from tkinter import ttk
class MyEntry(tk.Entry):
def __init__(self, master=None, cnf={}, **kw):
super().__init__(master, cnf, **kw)
if not "textvariable" in kw:
self.variable = tk.StringVar()
self.config(textvariable=self.variable)
else:
self.variable = kw["textvariable"]
@property
def value(self):
return self.variable.get()
@value.setter
def value(self, new: str):
self.variable.set(new)
class About(tk.Toplevel):
def __init__(self, parent):
super().__init__(parent, class_=parent.name)
self.config()
btn = tk.Button(self, text="Konec", command=self.close)
btn.pack()
def close(self):
self.destroy()
class Application(tk.Tk):
name = basename(splitext(basename(__file__.capitalize()))[0])
name = "Foo"
def __init__(self):
super().__init__(className=self.name)
self.title(self.name)
self.bind("<Escape>", self.quit)
self.lbl = tk.Label(self, text="Hello World")
self.lbl.pack()
self.btn = tk.Button(self, text="Quit", command=self.quit)
self.btn.pack()
self.btn2 = tk.Button(self, text="About", command=self.about)
self.btn2.pack()
def about(self):
window = About(self)
window.grab_set()
def quit(self, event=None):
super().quit()
app = Application()
app.mainloop()