Answers for "tkinter stop user changing size of window"

1

python tkinter resize window on button click

from tkinter import *

root = Tk()
root.title("Title")
root.geometry("800x800")

# Resize on button click
def resize():
  root.geometry("500x500")

button_1 = Button(root, text="Resize", command=resize)
button_1.pack(pady=20)

# Resize by parameters
def resize2():
  w = 650
  h = 650
  root.geometry(f"{w}x{h}")

button_2 = Button(root, text="Resize", command=resize2)
button_2.pack(pady=20)

# Resize by user entered parameters
def resize3():
  w = width_entry.get()
  h = height_entry.get()
  root.geometry(f"{w}x{h}")

width_label = Label(root, text="Width:")
width_label.pack(pady=20)
width_entry = Entry(root)
width_entry.pack()

height_label = Label(root, text="Height:")
height_label.pack(pady=20)
height_entry = Entry(root)
height_entry.pack()

button_3 = Button(root, text="Resize", command=resize3)
button_3.pack(pady=20)

root.mainloop()
Posted by: Guest on May-25-2021
2

how to resize tkinter window

import tkinter

window = tkinter.Tk()       # creating the window object
window.title('my first GUI program')
window.minsize(width=600, height=500)    # makes the window 500*600

window.mainloop()           # keeping the window until we close it
Posted by: Guest on February-01-2021

Code answers related to "tkinter stop user changing size of window"

Python Answers by Framework

Browse Popular Code Answers by Language