-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathhello.py
More file actions
44 lines (24 loc) · 643 Bytes
/
hello.py
File metadata and controls
44 lines (24 loc) · 643 Bytes
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
from tkinter import *
root = Tk()
root.title("Hello World!!")
root.iconbitmap('images/tkinter.ico')
root.geometry('500x350')
# Create global switch variable
global switch
switch = True
def change():
global switch
if switch == True:
my_label.config(text="Goodbye World!")
switch = False
else:
my_label.config(text="Hello World!")
switch = True
# Create a Label
my_label = Label(root, text="Hello World!", font=("Helvetica", 24))
# Pack, Grid, Place
my_label.pack(pady=20)
# Create a Button
my_button = Button(root, text="Click Me!", font=("Helvetica", 16), command=change)
my_button.pack(pady=20)
root.mainloop()