Home > Software engineering >  How to create a window without minimize, maximized, and close button in python?
How to create a window without minimize, maximized, and close button in python?

Time:11-10

I would like to know if tkinter can remove minimize, maximized and closed button on the upper right portion of the screen. Or is there any other python library can do this? If so, what is the code?

CodePudding user response:

I explained this in a comment above, but I wanted to put it here for better readability. AFAIK, you can hide the minimize and maximize buttons on windows that are instances of Toplevel, but you can't do this on root windows that are instances of Tk - at least not using the method shown.

# basic example
import tkinter as tk

root = tk.Tk()
root.transient()  # does nothing - min/max buttons are still shown
win = tk.Toplevel(root)
win.transient(root)  # works as intended - only close button is shown
root.mainloop()
# classy OOP example
import tkinter as tk


class App(tk.Tk):
    def __init__(self):
        super().__init__()
        self.transient()  # does nothing - min/max buttons are still shown
        self.win = tk.Toplevel(self)
        self.win.transient(self)  # works as intended - only close button is shown
   

if __name__ == '__main__':
    app = App()
    app.mainloop()

CodePudding user response:

Is this what you want window without minimize, maximized, and close button? Here is code:

import tkinter as tk

root = tk.Tk()

root.geometry("400x400")

root.overrideredirect(True)

root.mainloop()
  • Related