How to set window size in Tkinter

In this tutorial, we will learn how to set window size in Tkinter with just a few lines of code.

Here is the required code :
from tkinter import *

root = Tk()

root.geometry("640x430")
root.title("Tkinter window")

root.mainloop()
  • The first line of code will import everything(*) from the Tkinter module.
  • We used the ‘geometry’ method to set the window’s dimensions.
  • Tk() will create the  “root” window.
  • The ‘title’ method will set the text on the window’s title bar.
  • ‘mainloop()’ keeps the window open and responsive.

Thank you for visiting this page. I hope you found it helpful.

Happy coding!

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top