vendredi 5 juin 2020

Show tkinter widget when checkbox is checked

I'm trying to make the entry widget show once the checkbutton is checked and hide when it's not.

from tkinter import *
master = Tk()
master.geometry('500x400')
other = IntVar()
Checkbutton(master, text="Other", variable=other, command=toggle()).grid(row=10, sticky=W)
def toggle():
    if other.get()==1:
        Entry(master,width=50).grid(row=11, sticky=W)
    else:
        Entry(master,width=50).grid_remove()



Aucun commentaire:

Enregistrer un commentaire