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
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 346 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  [PyQt] PyQt5 window closing when trying to display a graph bianca 4 1,621 Aug-12-2023, 03:25 PM
Last Post: bianca
Exclamation [Tkinter] Error when closing the main window with destroy TomasSanchexx 1 728 Aug-06-2023, 01:54 AM
Last Post: deanhystad
Question closing a "nested" window with a button in PySimpleGUI and repeating this process Robby_PY 9 13,417 Jan-18-2021, 10:21 PM
Last Post: Serafim
  [PyQt] Received RunTimeError after script concludes, closing Dialog Window (clicking x-out) skipper0802 0 2,527 Oct-09-2020, 09:23 PM
Last Post: skipper0802
  Closing window on button click not working kenwatts275 4 3,671 May-03-2020, 01:59 PM
Last Post: deanhystad
  Running cli program within a wx window? t4keheart 2 2,728 Jan-23-2020, 04:50 PM
Last Post: buran
  tkinter window and turtle window error 1885 3 6,625 Nov-02-2019, 12:18 PM
Last Post: 1885
  [split] Closing a window but not the whole program scriptdrache 1 2,305 Jun-25-2019, 03:43 PM
Last Post: joe_momma
  How to stop a tkinter function, without closing the window? keakins 5 12,949 Jun-29-2017, 11:53 AM
Last Post: keakins

Forum Jump:

User Panel Messages

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