-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tkinter.py
131 lines (106 loc) · 3.38 KB
/
Tkinter.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
from tkinter import *
from tkinter import ttk
def click():
print("Button clicked.")
def submit():
text = entry.get()
print(text)
entry.config(state = DISABLED)
def delete():
entry.delete(0, END)
def backspace():
entry.delete(len(entry.get()) - 1, END)
def display():
if x.get() == 1:
print("You agree.")
else:
print("You don't agree.")
def openFile():
print("File Opened.")
def saveFile():
print("File saved.")
def Cut():
print("Cut.")
def Copy():
print("Copy.")
def Paste():
print("Paste.")
window = Tk()
window.geometry("800x600")
window.title("Tkinter Test Program")
icon = PhotoImage(file = "./Image/TikTok_Logo.png")
window.iconphoto(True, icon)
window.config(background = "#000000")
photo = PhotoImage(file = "./Image/material-symbols--download-rounded.png")
x = IntVar()
menubar = Menu(window)
window.config(menu = menubar)
notebook = ttk.Notebook(window)
tab1 = Frame(notebook)
tab2 = Frame(notebook)
notebook.add(tab1, text = "Tab 1")
notebook.add(tab2, text = "Tab 2")
notebook.pack(expand = True, fill = "both")
Label(tab1, text = "Hello Tab 1", width = 50, height = 25).pack()
Label(tab2, text = "Hello Tab 2", width = 50, height = 25).pack()
button = Button(window,
text = "Click",
command = click,
font = ("Comic Sans", 30),
fg = "#00ff00",
bg = "black",
activeforeground = "#00ff00",
activebackground = "black",
state = ACTIVE,
image = photo,
compound = LEFT
)
button.pack()
entry = Entry(window,
font = ("Arial", 20),
fg = "#00ff00",
bg = "black",
show = '*'
)
entry.insert(0, "Type here")
entry.pack(side = LEFT)
submit_button = Button(window, text = "submit", command = submit)
submit_button.pack(side = RIGHT)
delete_button = Button(window, text = "delete", command = delete)
delete_button.pack(side = RIGHT)
backspace_button = Button(window, text = "backspace", command = backspace)
backspace_button.pack(side = RIGHT)
check_button = Checkbutton(window,
text = "I agree.",
variable = x,
onvalue = 1,
offvalue = 0,
command = display
)
check_button.pack()
fileMenu = Menu(menubar, tearoff = 0, font = ("MV Boli", 15))
menubar.add_cascade(label = "File", menu = fileMenu)
fileMenu.add_command(label = "Open", command = openFile)
fileMenu.add_command(label = "Save", command = saveFile)
fileMenu.add_separator()
fileMenu.add_command(label = "Exit", command = quit)
editMenu = Menu(menubar, tearoff = 0)
menubar.add_cascade(label = "Edit", menu = editMenu)
editMenu.add_command(label = "Cut", command = Cut)
editMenu.add_command(label = "Copy", command = Copy)
editMenu.add_command(label = "Paste", command = Paste)
# label = Label(window,
# text = "Hello tk",
# font = ("Arial", 40, 'bold'),
# fg = "green",
# bg = "black",
# relief = RAISED,
# bd = 10,
# padx = 20,
# pady = 20,
# # image = photo,
# # compound = BOTTOM
# )
# label.pack()
# # label.place(x = 0, y = 0)
window.mainloop()