Skip to content

Commit af39bdf

Browse files
author
Mofan Zhou
committedJun 14, 2016
create tk5
1 parent 5f9c8f9 commit af39bdf

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
 

‎tkinterTUT/tk5_radiobutton.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# View more python learning tutorial on my Youtube and Youku channel!!!
2+
3+
# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
4+
# Youku video tutorial: http://i.youku.com/pythontutorial
5+
6+
import tkinter as tk
7+
8+
window = tk.Tk()
9+
window.title('my window')
10+
window.geometry('200x200')
11+
12+
var = tk.StringVar()
13+
l = tk.Label(window, bg='yellow', width=20, text='empty')
14+
l.pack()
15+
16+
def print_selection():
17+
l.config(text='you have selected ' + var.get())
18+
19+
r1 = tk.Radiobutton(window, text='Option A',
20+
variable=var, value='A',
21+
command=print_selection)
22+
r1.pack()
23+
r2 = tk.Radiobutton(window, text='Option B',
24+
variable=var, value='B',
25+
command=print_selection)
26+
r2.pack()
27+
r3 = tk.Radiobutton(window, text='Option C',
28+
variable=var, value='C',
29+
command=print_selection)
30+
r3.pack()
31+
32+
33+
window.mainloop()

0 commit comments

Comments
 (0)
Please sign in to comment.