Tkinter

时间:2023-11-10 08:41:50

单个选项

from Tkinter import *
root = Tk() v = IntVar() Radiobutton(root, text="One", variable=v, value=1).pack(anchor=W)
Radiobutton(root, text="Two", variable=v, value=2).pack(anchor=W)
Radiobutton(root, text="Three", variable=v, value=3).pack(anchor=W) l = Label(root,textvariable=v)
l.pack()
mainloop()
from Tkinter import *

master = Tk()

LANGS = [
("Python", 1),
("Perl", 2),
("Ruby", 3),
("Lua", 4)] v = IntVar()
v.set(1)
for lang, num in LANGS:
b = Radiobutton(master, text=lang, variable=v, value=num, indicatoron=False)
b.pack(fill=X) mainloop()

Tkinter