Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unclosable window using tkinter

Hey I am making a program that take a picture using my webcam when I type the wrong password. The program will be open and I want it unclosable. I need to know how to make a window unclosable using tkinter.

like image 985
Adailton Júnior Avatar asked Sep 07 '25 01:09

Adailton Júnior


1 Answers

You can try all of the many things @abarnert suggested, but I think the easiest way would be to just ignore the close event.

From this question:

Here you have a concrete example:

import Tkinter as tk
import tkMessageBox as messagebox
root = tk.Tk()

def on_closing():
    if messagebox.askokcancel("Quit", "Do you want to quit?"):
        root.destroy()

root.protocol("WM_DELETE_WINDOW", on_closing)
root.mainloop()

(edited code for Windows)

So change on_closing() to
def on_closing(): pass
and that makes it unclosable. I tried Alt+F4, the close button, closing it from the Windows Taskbar, all to no avail. The only way I was able to kill it was to use Task Manager.

like image 66
IronManMark20 Avatar answered Sep 10 '25 02:09

IronManMark20