vendredi 28 novembre 2014

Change the appearance of labels with Tkinter events


Vote count:

0




Context: I'm okay at Python, but not yet familiar with all its functionality.


I'm trying to build a GUI using Tkinter, and I'd like to know whether I can have this happen: If a radio button is selected, then one of the five labels will disappear. If another radio button is pressed, then the hidden label will appear and another label will disappear.



from Tkinter import *
root = Tk()

v = IntVar()
v.set(0)


physVar = (
("a", 1),
("vi", 2),
("vf", 3),
("t", 4),
("x", 5)
)


def ShowChoice():
print physVar[v.get()-1][0]


Label(root,
text="Solve for:",
padx = 5
).grid(row=0, column=0, columnspan = 6)

for txt, val in physVar:
Radiobutton(root,
text= txt,
variable = v,
command=ShowChoice,
value=val).grid(row=1, column = val)


for txt, val in physVar:
Label(root,
text=txt).grid(column = 0, row = val+1)

for txt, val in physVar:
Entry(root,
text=txt).grid(column = 1, columnspan = 5, row = val +1)
mainloop()


What I'd like is, for example, if I clicked on the radio button for "a", then the label "a" and the entry next to it will disappear.



asked 2 mins ago







Change the appearance of labels with Tkinter events

Aucun commentaire:

Enregistrer un commentaire