How to make tkinter window not mutable?

I need a tkinter (python) script for me static (non resizable)

I have a pretty simple tkinter script, but I don't want me to be reanimated as some kind of error message. i honestly don't know what to do

this is my script:

from tkinter import * import ctypes, os def callback(): active.set(False) quitButton.destroy() JustGo = Button(root, text=" Keep Going!", command= lambda: KeepGoing()) JustGo.pack() JustGo.place(x=150, y=110) #root.destroy() # Uncoment this to close the window def sleep(): if not active.get(): return root.after(1000, sleep) timeLeft.set(timeLeft.get()-1) timeOutLabel['text'] = "Time Left: " + str(timeLeft.get()) #Update the label if timeLeft.get() == 0: #sleep if timeLeft = 0 os.system("Powercfg -H OFF") os.system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0") def KeepGoing(): active.set(True) sleep() quitButton1 = Button(root, text="do not sleep!", command=callback) quitButton1.pack() quitButton1.place(x=150, y=110) root = Tk() root.geometry("400x268") root.title("Alert") root.configure(background='light blue') timeLeft = IntVar() timeLeft.set(10) # Time in seconds until shutdown active = BooleanVar() active.set(True) # Something to show us that countdown is still going. label = Label(root, text="ALERT this device will go to sleep soon!", fg="red") label.config(font=("Courier", 12)) label.configure(background='light blue') label.pack() timeOutLabel = Label(root, text = 'Time left: ' + str(timeLeft.get()), background='light blue') # Label to show how much time we have left. timeOutLabel.pack() quitButton = Button(root, text="do not sleep!", command=callback) quitButton.pack() quitButton.place(x=150, y=110) root.after(0, sleep) root.mainloop() 
+6
source share
1 answer

The resizable method in the root window accepts two logical parameters to determine whether the window will be resized in the X and Y directions. To make it completely fixed in size, set both parameters to False :

 root.resizable(False, False) 
+15
source

All Articles