Python Forum
[Tkinter] Closing a window but not the whole program
Thread Rating:
  • 4 Vote(s) - 2.75 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Closing a window but not the whole program
#1
I want to close a window that I created by pressing a button. However if I put exit then it shuts the whole program down. Can anyone help me fix this?[size=medium][/size]
Reply
#2
Don't call sys.exit() then. I'm sure tk has a window close method. Maybe something like root.destroy() or frame.destroy().

If that doesn't help, please share some code so we can see what's going on.
Reply
#3
you might be able to use lift and lower, which will hide it behind another widget, but of course you need to have another widget large enough to hide behind.
The other method is withdraw, which I believe doesn't actually delete the window and it can be restored. I have used withdraw, but have never tried to redraw a withdrawn window, it could be as simple as issuing another geometry command (place, pack or grid).
Google it for details.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question closing a "nested" window with a button in PySimpleGUI and repeating this process Robby_PY 9 2,847 Jan-18-2021, 10:21 PM
Last Post: Serafim
  [PyQt] Received RunTimeError after script concludes, closing Dialog Window (clicking x-out) skipper0802 0 843 Oct-09-2020, 09:23 PM
Last Post: skipper0802
  Closing window on button click not working kenwatts275 4 1,008 May-03-2020, 01:59 PM
Last Post: deanhystad
  Running cli program within a wx window? t4keheart 2 1,583 Jan-23-2020, 04:50 PM
Last Post: buran
  tkinter window and turtle window error 1885 3 3,027 Nov-02-2019, 12:18 PM
Last Post: 1885
  [split] Closing a window but not the whole program scriptdrache 1 928 Jun-25-2019, 03:43 PM
Last Post: joe_momma
  How to stop a tkinter function, without closing the window? keakins 5 9,107 Jun-29-2017, 11:53 AM
Last Post: keakins
  Closing Modal Window in QT nieselfriem 0 3,304 Apr-19-2017, 03:32 PM
Last Post: nieselfriem
  update a variable in parent window after closing its toplevel window gray 5 5,503 Mar-20-2017, 10:35 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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