+ 2

How to create a radio button? What is the mistake here?

from tkinter import * root = Tk() var = IntVar() var.set(1) rad0 = Radiobutton(root,text="Первая",variable=var,value=0) rad1 = Radiobutton(root,text="Вторая",variable=var,value=1) rad2 = Radiobutton(root,text="Третья",variable=var,value=2) var.pack() root.mainloop()

16th Dec 2016, 11:03 PM
Dmytro Shcherbakov
Dmytro Shcherbakov - avatar
2 Respostas
+ 3
from Tkinter import * .... rad0 = Radiobutton(root, text="btn1", variable=var, value=1) rad0.pack.(anchor=W) ...... label = Label(root) label.pack() root.mainloop()
17th Dec 2016, 4:45 PM
Piyush Goyani
Piyush Goyani - avatar
+ 3
u need to call .pack() with each radiobutton variable ,and at end need to create label and call pack() otherwise it will show attribute error if try to pack using var(IntVar)
17th Dec 2016, 4:48 PM
Piyush Goyani
Piyush Goyani - avatar