Destroy Tkinter Button After Click
I have a Tkinter list box populated with city names. I want to grab the selected value and pass it to subsequent code after the mainloop. I have the following tkinker code: master
Solution 1:
Your button doesn't destroy
because its function 'returns' before doing so. Which is also bad because a command
's callback method can't really return
anywhere meaningful. Do the following changes:
some_outer_scope_var = None
def ok():
global some_outer_scope_var
some_outer_scope_var = variable.get()
print ("value is:" + variable.get())
master.destroy()
That way you save the value of variable.get()
on some_outer_scope_var
first and then destroy
all GUI.
Solution 2:
Try using button.destroy() if you want to destroy the button only.
Post a Comment for "Destroy Tkinter Button After Click"