Changing Screen Size: Tkinter

Changing Screen Size: Tkinter

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:

Share:

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@copyassignment.com Thank you