+ 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()
2 Réponses
+ 3
from Tkinter import *
....
rad0 = Radiobutton(root, text="btn1", variable=var, value=1)
rad0.pack.(anchor=W)
......
label = Label(root)
label.pack()
root.mainloop()
+ 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)