How to make a Tkinter window not resizable?

Squash

I need a Python script that uses the Tkinter module to create a static (not resizable) window.

I have a pretty simple Tkinter script but I don't want it to be resizable. How do I prevent a Tkinter window from being resizable? 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()         # Uncomment 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()  
Bryan Oakley

The resizable method on the root window takes two boolean parameters to describe whether the window is resizable in the X and Y direction. To make it completely fixed in size, set both parameters to False:

root.resizable(False, False)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to make QtQuick2.0 application window not resizable?

From Dev

How to make QtQuick2.0 application window not resizable?

From Dev

How to make JScrollPane Resizable

From Dev

Make a pygame resizable window that can be snapped to the screen

From Dev

How to make a window fullscreen in a secondary display with tkinter?

From Dev

How to make canvas Resizable in javaFX?

From Dev

How to make a resizable rectangle in QML?

From Dev

How to make a div resizable for users?

From Dev

How to make image resizable in UIWebView?

From Dev

How to make main javafx window still resizable coming back from full screen mode in MacOS

From Dev

Java SWT: How to set the window to be resizable \ not resizable on the fly?

From Dev

How can I make a div resizable

From Dev

How to make a dijit/editor manualy resizable?

From Dev

How to make resizable line with jQuery-ui?

From Dev

How to make a background resizable for different screens?

From Dev

How to make a dijit/editor manualy resizable?

From Dev

How to make tkinter Window floating in i3 windowmanager

From Dev

How to make click events pass though a tkinter window?

From Dev

How to make state of window idle until button is pressed in python tkinter?

From Dev

How to make button command to open image inside window in tkinter?

From Dev

how to make only 1 new window when a button is clicked? tkinter

From Dev

How do you make an animation with the title of a Tkinter window?

From Dev

Logic within python and Tkinter: how to make a window run endlessly

From Dev

How do I make this button quit the parent window in tkinter?

From Dev

Make tkinter Window appear in the taskbar

From Dev

Tkinter - How can I make a button can create new window and close the main window

From Dev

How to clear window with tkinter

From Java

How to go about drawing the border of a rectangle in a resizable window using pygame?

From Dev

How to only allow WPF Window's height resizable?

Related Related

  1. 1

    How to make QtQuick2.0 application window not resizable?

  2. 2

    How to make QtQuick2.0 application window not resizable?

  3. 3

    How to make JScrollPane Resizable

  4. 4

    Make a pygame resizable window that can be snapped to the screen

  5. 5

    How to make a window fullscreen in a secondary display with tkinter?

  6. 6

    How to make canvas Resizable in javaFX?

  7. 7

    How to make a resizable rectangle in QML?

  8. 8

    How to make a div resizable for users?

  9. 9

    How to make image resizable in UIWebView?

  10. 10

    How to make main javafx window still resizable coming back from full screen mode in MacOS

  11. 11

    Java SWT: How to set the window to be resizable \ not resizable on the fly?

  12. 12

    How can I make a div resizable

  13. 13

    How to make a dijit/editor manualy resizable?

  14. 14

    How to make resizable line with jQuery-ui?

  15. 15

    How to make a background resizable for different screens?

  16. 16

    How to make a dijit/editor manualy resizable?

  17. 17

    How to make tkinter Window floating in i3 windowmanager

  18. 18

    How to make click events pass though a tkinter window?

  19. 19

    How to make state of window idle until button is pressed in python tkinter?

  20. 20

    How to make button command to open image inside window in tkinter?

  21. 21

    how to make only 1 new window when a button is clicked? tkinter

  22. 22

    How do you make an animation with the title of a Tkinter window?

  23. 23

    Logic within python and Tkinter: how to make a window run endlessly

  24. 24

    How do I make this button quit the parent window in tkinter?

  25. 25

    Make tkinter Window appear in the taskbar

  26. 26

    Tkinter - How can I make a button can create new window and close the main window

  27. 27

    How to clear window with tkinter

  28. 28

    How to go about drawing the border of a rectangle in a resizable window using pygame?

  29. 29

    How to only allow WPF Window's height resizable?

HotTag

Archive