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)
#11
If I needed someone to enter a password I would use a dialog, a separate window. When the password entry is done I close the window. If my program needs multiple views, I make multiple views (frames) that are mapped or unmapped. depending on which controls are currently in use. I almost never change the controls in a view and I don't remember the last time I ever deleted a control. I may unmap a control (usually I unmap a frame), but I never delete. I'll probably need it later.
Reply
#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
#13
Yes you are right.I understand.I made this mistake in the past(with place() ).
Also I agree with you,maybe a dialog is a good idea for my password function.
I have been using tkinter for about 2 weeks.
Thank you so much Cool
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using Tkinter inside function not working Ensaimadeta 5 4,861 Dec-03-2023, 01:50 PM
Last Post: deanhystad
  TKinter Widget Attribute and Method Quick Reference zunebuggy 3 787 Oct-15-2023, 05:49 PM
Last Post: zunebuggy
  Tkinter won't run my simple function AthertonH 6 3,742 May-03-2022, 02:33 PM
Last Post: deanhystad
  [Tkinter] tkinter best way to pass parameters to a function Pedroski55 3 4,736 Nov-17-2021, 03:21 AM
Last Post: deanhystad
  Creating a function interrupt button tkinter AnotherSam 2 5,418 Oct-07-2021, 02:56 PM
Last Post: AnotherSam
  [Tkinter] Have tkinter button toggle on and off a continuously running function AnotherSam 5 4,920 Oct-01-2021, 05:00 PM
Last Post: Yoriz
  return a variable from a function snakes 3 2,742 Apr-09-2021, 06:47 PM
Last Post: snakes
  tkinter get function finndude 2 2,890 Mar-02-2021, 03:53 PM
Last Post: finndude
  function in new window (tkinter) Dale22 7 4,964 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,519 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