-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrad.py
41 lines (29 loc) · 1.2 KB
/
rad.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
from tkinter import *
import ttkbootstrap as tb
root = tb.Window(themename="superhero")
#root = Tk()
root.title("TTK Bootstrap! Radio Buttons")
root.iconbitmap('images/codemy.ico')
root.geometry('500x550')
# Clicker Function
def clicker():
my_label.config(text=f'You Selected: {my_topping.get()}')
# Create Radio Button List
toppings = ["Pepperoni", "Cheese", "Veggie"]
# Create A Tkinter Variable To Keep Track of everything
my_topping = StringVar()
# Loop thru the list and create radio buttons
for topping in toppings:
tb.Radiobutton(root, bootstyle="danger", variable=my_topping, text=topping, value=topping, command=clicker).pack(pady=20)
# Create button
my_button = tb.Button(root, text="Click Me!", command=clicker)
my_button.pack(pady=20)
# Create a Label
my_label = tb.Label(root, text="You Selected: ")
my_label.pack(pady=20)
# Create actual Radio Button Buttons
rb1 = tb.Radiobutton(root, bootstyle="info toolbutton", variable=my_topping, text="Radio Button 1", value="Radio Button 1", command=clicker)
rb1.pack(pady=20)
rb2 = tb.Radiobutton(root, bootstyle="info toolbutton outline", variable=my_topping, text="Radio Button 2", value="Radio Button 2", command=clicker)
rb2.pack(pady=20)
root.mainloop()