- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Disable Exit (or [ X ]) in Tkinter Window
The window manager implements the Tkinter window control icons. To hide and show the Tkinter window control icons, we can use the built-in function, which describes whether we want to disable control icons’ functionality.
To disable the Exit or [X] control icon, we have to define the protocol() method. We can limit the control icon definition by specifying an empty function for disabling the state of the control icon.
#Import the tkinter library from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame win= Tk() #Define the geometry of the function win.geometry("750x250") def close_win(): win.destroy() def disable_event(): pass #Create a button to close the window btn = ttk.Button(win, text ="Click here to Close",command=close_win) btn.pack() #Disable the Close Window Control Icon win.protocol("WM_DELETE_WINDOW", disable_event) win.mainloop()
The above code will display a window that has a disabled [X] window close control.
To close the window, click the button "Click here to Close."
- Disable the underlying window when a popup is created in Python TKinter
- How to hide or disable the mouse pointer in Tkinter?
- Window Resizer Control Panel in Tkinter
- How to disable a Combobox in Tkinter?
- How to exit from Python using a Tkinter Button?
- Default window color Tkinter and hex color codes in Tkinter
- Creating an automatically maximized tkinter window
- Creating a Transparent window in Python Tkinter
- Creating a Frameless window in Python Tkinter
- Function to close the window in Tkinter
- How to show webcam in TkInter Window?
- How to disable checkbutton Tkinter (grey out)?
- How to Disable / Enable a Button in TKinter?
- How to disable multiselection on Treeview in tkinter?
- How to disable an Entry widget in Tkinter?