[Python] Disable, hide or remove close "X" button in Tkinter

Discussão em 'Python' iniciado por Stack, Fevereiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    I want to show a GUI to client, but I don't want to give the possibility to the client to close the window through the [X] button.

    How do I disable, hide or remove the close [X] button of Tkinter window?

    I found the following answers:

    1. Python Tkinter “X” button control
    2. Removing minimize/maximize buttons in Tkinter

    However, these posts are not answering my question. I want to disable, hide or completely remove the [X] button.

    When I use protocol:

    def __init__(self):
    Frame.__init__(self, bg = "black")
    self.protocol('WM_DELETE_WINDOW', self.doSomething)
    self.pack(expand = 1, fill = BOTH)

    def doSomething(self):
    if showinfo.askokcancel("Quit?", "Are you sure you want to quit?"):
    self.quit()


    I receive the following error:


    self.protocol('WM_DELETE_WINDOW', self.doSomething) AttributeError: 'GUI' object has no attribute 'protocol'
    ​

    Continue reading...

Compartilhe esta Página