-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathctk_radio.py
73 lines (51 loc) · 1.59 KB
/
ctk_radio.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
from tkinter import *
import customtkinter
customtkinter.set_appearance_mode("dark") # Modes: system (default), light, dark
customtkinter.set_default_color_theme("dark-blue") # Themes: blue (default), dark-blue, green
#root = Tk()
root = customtkinter.CTk()
root.title('Tkinter.com - Custom Tkinter Radio Buttons!')
root.iconbitmap('images/codemy.ico')
root.geometry('700x300')
def get_rad():
if radio_var.get() == "other":
my_label2.configure(text="Please Make A Selection")
elif radio_var.get() == "Yes":
my_label2.configure(text="Of Course You Like Pizza!")
else:
my_label2.configure(text="What's Wrong With You?!")
my_label = customtkinter.CTkLabel(root, text="Do You Like Pizza?!", font=("Helvetica", 18))
my_label.pack(pady=40)
radio_var = customtkinter.StringVar(value="other")
# Radio Button 1
my_rad1 = customtkinter.CTkRadioButton(root, text="Yes I Do", value="Yes",
variable=radio_var,
#width=50,
#height=50,
radiobutton_width=50,
radiobutton_height=50,
corner_radius=1,
border_width_unchecked = 2,
border_width_checked=5,
border_color="red",
hover_color="pink",
fg_color="green",
hover=True,
text_color="red",
font=("Helvetica", 18),
state="normal",
text_color_disabled="green"
)
my_rad1.pack(pady=10)
# Radio Button 2
my_rad2 = customtkinter.CTkRadioButton(root, text="No I Don't", value="No",
variable=radio_var,
)
my_rad2.pack(pady=10)
# Button
my_button = customtkinter.CTkButton(root, text="Select", command=get_rad)
my_button.pack(pady=10)
# Label
my_label2 = customtkinter.CTkLabel(root, text="", font=("Helvetica",18))
my_label2.pack(pady=10)
root.mainloop()