0

I am building a simple login system using Tkinter in python, for that I need a non-resizable and it can be done by 'resizable(0,0) but it only disables the maximize button. But I what the minimize button to be disabled also, so please someone help me find the solution for these.

Here's the sample of my code,

from tkinter import *

root = Tk()
root.geometry("400x300")


def signIn():

    # Opening a new window for SignIn options
    signin = Toplevel()
    signin.grab_set()
    signin.focus_set()

    # I also tried this but it removes the whole title bar along with the close 'X' button
    # root.overrideredirect(True)

# SignIn button
button = Button(root, text="Sign In", command=signIn)
button.grid(row=1, column=0)

root.mainloop() 
Kumara
  • 480
  • 1
  • 4
  • 13
  • Does this answer your question? [Removing minimize/maximize buttons in Tkinter](https://stackoverflow.com/questions/2969870/removing-minimize-maximize-buttons-in-tkinter) – BokiX Apr 08 '22 at 13:05
  • Yes @BokiX https://stackoverflow.com/a/63359625/17518541 is the solution, but also has a new error. While using " root.attributes('-toolwindow', True) " removes the function of "signin.grab_set() and signin.focus_set()" . Is there any way to solve this with out these new errors. – Kumara Apr 08 '22 at 14:38

2 Answers2

1
from tkinter import *

root = Tk()
root.geometry("400x300")
root.attributes('-toolwindow', True)

def signIn():

    # Opening a new window for SignIn options
    signin = Toplevel()
    signin.grab_set()
    signin.focus_set()

    # I also tried this but it removes the whole title bar along with the close 'X' button
    # root.overrideredirect(True)

# SignIn button
button = Button(root, text="Sign In", command=signIn)
button.grid(row=1, column=0)

root.mainloop()

Khalil
  • 11
  • 3
  • 1
    This solve the problem with creating another problem, that I mentioned below the comment section of my question. So help me solve this, by the way welcome to stackoverflow – Kumara Apr 08 '22 at 14:43
1

If you want to disable the minimize and maximize use this. It will leave you with only the x button. I gave example for only removing maximize and then one for both.

import tkinter as tk
import time



root = tk.Tk()
root.geometry("500x500")
root.resizable(False, False)#removes only the maximize option

root.attributes("-toolwindow", True)#removes both the maximize and the minimize option


root.mainloop()
Rory
  • 661
  • 1
  • 6
  • 15