Disable exit button


3 posts
by sefikTim » Wed May 17, 2017 2:52 pm
I'm currently programming a GUI on Tkinter. I want the GUI to run 24/7 so therefor I need to remove/disable the X-button on the top right corner. Any suggestions on how I can do that. I'm using python 3 and the newest tkinter.
Posts: 22
Joined: Tue Mar 21, 2017 9:47 am
by Davies » Wed May 17, 2017 3:22 pm
Code: Select all
root = tk.Tk()
root.overrideredirect(True)
root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight()))
root.resizable(width=FALSE, height=FALSE)


this will disable close and window size buttons, disable screen resize and set your gui to whatever size the screen is, running full screen. (on python 2.7.. i havent used on 3.4+ yet)
root.overrideredirect(True) also prevents the application been closed by alt + F4 etc.
Posts: 117
Joined: Sat Apr 04, 2015 4:24 pm
by RogerW » Wed May 17, 2017 3:43 pm
I am not sure how to remove the X button but you can stop it doing anything.
Code: Select all
import tkinter as tk

def donothing():
    pass

main = tk.Tk()
main.protocol('WM_DELETE_WINDOW',donothing)
main.mainloop()
User avatar
Posts: 250
Joined: Sat Dec 20, 2014 12:15 pm
Location: London UK