Python Forum
tkinter -- after() method and return from function -- (python 3)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter -- after() method and return from function -- (python 3)
#12
I think you are having a problem deleting your button because you don't have a handle to the button. You provide this example:
button_ok.destroy()
And in an earlier example this:
Output:
button_ok = Button(root, text="OK", width=7, pady=8, command=check_passcode, state=DISABLED).place(x=655, y=140)
Guess what, button_ok is None!

When you call Button() followed by .place() as in Button(root, text="OK"...).place(x=655, y=140) the thing returned is None. This is because the place() function returns none. I cannot tell you how many times I see this error in this forum. If you want to keep the a reference to the button, you need to split the creation and the place.
button_ok = Button(root, text="OK", width=7, pady=8, command=check_passcode, state=DISABLED)
button_ok.place(x=655, y=140)
And to remove a button you should use forget_pack() to remove it from view, then you can use destroy() if you will never use it again, or keep it around and use pack or place or whatever to make it visiable.
Reply


Messages In This Thread
RE: tkinter -- after() method and return from function -- (python 3) - by deanhystad - Feb-20-2021, 10:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using Tkinter inside function not working Ensaimadeta 5 5,099 Dec-03-2023, 01:50 PM
Last Post: deanhystad
  TKinter Widget Attribute and Method Quick Reference zunebuggy 3 872 Oct-15-2023, 05:49 PM
Last Post: zunebuggy
  Tkinter won't run my simple function AthertonH 6 3,916 May-03-2022, 02:33 PM
Last Post: deanhystad
  [Tkinter] tkinter best way to pass parameters to a function Pedroski55 3 4,904 Nov-17-2021, 03:21 AM
Last Post: deanhystad
  Creating a function interrupt button tkinter AnotherSam 2 5,577 Oct-07-2021, 02:56 PM
Last Post: AnotherSam
  [Tkinter] Have tkinter button toggle on and off a continuously running function AnotherSam 5 5,056 Oct-01-2021, 05:00 PM
Last Post: Yoriz
  return a variable from a function snakes 3 2,825 Apr-09-2021, 06:47 PM
Last Post: snakes
  tkinter get function finndude 2 2,983 Mar-02-2021, 03:53 PM
Last Post: finndude
  function in new window (tkinter) Dale22 7 5,199 Nov-24-2020, 11:28 PM
Last Post: Dale22
Star [Tkinter] How to perform math function in different page of Tkinter GUI ravaru 2 4,617 Oct-23-2020, 05:46 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020