Posts: 22
Joined: Tue Mar 21, 2017 9:47 am

Disable exit button

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: 150
Joined: Sat Apr 04, 2015 4:24 pm

Re: Disable exit button

Wed May 17, 2017 3:22 pm

Code: Select all

root = tk.Tk()
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.

User avatar
Posts: 266
Joined: Sat Dec 20, 2014 12:15 pm
Location: London UK

Re: Disable exit button

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():

main = tk.Tk()

Return to “Python”

Who is online

Users browsing this forum: mattg31 and 16 guests