About 7,180,000 results
Open links in new tab
  1. python - How to close a Tkinter window by pressing a Button?

    Apr 3, 2012 · You can use lambda to pass a reference to the window object as argument to close_window function: button = Button (frame, text="Good-bye.", command = lambda: …

  2. python - What's the Pythonic way to write an auto-closing class ...

    Aug 12, 2013 · Function contextlib.closing is typically used for those classes that do not explicitly define the methods __enter__ and __exit__ (but have a method close). If you define your own …

  3. Explaining Python's '__enter__' and '__exit__' - Stack Overflow

    Python calls __enter__ when execution enters the context of the with statement and it’s time to acquire the resource. When execution leaves the context again, Python calls __exit__ to free …

  4. How to Close a Tkinter Window With a Button? | GeeksforGeeks

    Dec 17, 2020 · Method 1: Using destroy () Non-Class method. Approach: Import tkinter module. Create a main window named root. Add a button. Assign root.destroy to the command …

  5. How to Exit from Python Using a Tkinter Button - Finxter

    Mar 2, 2024 · In the context of a Python Tkinter application, developers need a way to terminate the program on the event of a button click. This article demonstrates several approaches for …

  6. How to Close a Tkinter Window With a Button - Delft Stack

    Feb 2, 2024 · This tutorial introduces how to close a Tkinter window with a button that has a function or command attached to it. The solutions include root.destroy and root.quit methods. …

  7. Tkinter - Close window programmatically - Python Examples

    To close a window in Tkinter programmatically, call destroy method on the Tk class object which is our window. In this tutorial, you will learn how to programmatically close the window in …

  8. How to close the Window in Tkinter [5 easy Ways] - bobbyhadz

    Apr 10, 2024 · You can use the root.destroy() method to close the Window in Tkinter. The method destroys all widgets and exits the mainloop. command=root.destroy).grid(column=1, row=0) . …

  9. input - Closing a Tkinter Entry Box in Python - Stack Overflow

    I am trying to create a simple popup text entry for the user in which a user enters a text and hits submit (a button). Upon clicking submit, I want the popup entry box to close off and continue …

  10. How To Bind The Enter Key To A Tkinter Window ... - GeeksforGeeks

    Jun 21, 2024 · In Tkinter, you can bind keys using the bind method of a widget or the main window. The '<Key>' is the key event and function is the callback function that will be executed …

Refresh