Hello guys welcome again to our site where you get amazing source code absolutely free with explanation
So, today’s topic is to change the screen size from the screen by itself by taking the arguments for width and height
To change the screen size we have set two entry widgets in front of width and height then we have set a button “Apply” to change the screen size
To change the screen size we are calling a function called “update” to resize the screen according the new width and height
Here is the code to what we want to do
Code
from tkinter import * root = Tk() root.geometry("700x700") root.title("Changing screen size") root.minsize(400, 600) root.maxsize(700, 800) subject = Label(root, text="You can change screen size according to your wish", font="comicsansms 13 bold", borderwidth=3, relief=SUNKEN) can_width = StringVar() can_height = StringVar() def update(): root.geometry(f"{can_width.get()}x{can_height.get()}") width = Label(root, text="Enter width") height = Label(root, text=" Enter height") width_entry = Entry(root, textvariable=can_width) height_entry = Entry(root, textvariable=can_height) width.grid(row=0, column=0) height.grid(row=1, column=0) width_entry.grid(row=0, column=1) height_entry.grid(row=1, column=1) Button(root, text="Apply", command=update).grid(row=2, column=1, pady=12) subject.grid(row=3, column=1, pady=12) root.mainloop()
Output
Thanks for reading
Stay updated to our website for more amazing free source code with an explanation like this
Also read:
- See connected wifi passwords using Python
- Simple Text-To-Speech In Python
- GUI Calculator Using Python tkinter
- Password Generator Application
- Creating User-defined Entry Widgets
- GUI Stone Paper Scissor Game: Python
- Displaying Images in Tkinter
- GUI Age Calculator
- Simple Music Player Using Python
- Adding three matrices
- Auto-Login with Python