|
|
Question : hide a button
|
|
i am working on aprogram where i have declared the Button(text="start", Command = self.showcurrent).pack(side=LEFT, padx=4)
This buttons calls the function and works perfrctly, but once the user i has clicked on the start button i would like to hide the button, How do i do that
thank you
|
Answer : hide a button
|
|
Use pack_forget, like this:
import Tkinter from Tkconstants import *
def showcurrent(): button.pack_forget()
tk = Tkinter.Tk() frame = Tkinter.Frame(tk, relief=RIDGE, borderwidth=2) frame.pack(fill=BOTH,expand=1) label = Tkinter.Label(frame, text="Click the button to hide it") label.pack(fill=X, expand=1) button = Tkinter.Button(text="Hide me", command = showcurrent) button.pack(side=BOTTOM, padx=4) tk.mainloop()
|
|
|
|
|