Tkinter provides some methods with the help of which we can get the current screen height and width.
Following methods can be used to decide height and width :
winfo_screenheight() // Returns screen height in pixels
winfo_screenmmheight() // Returns screen height in mm
winfo_screenwidth() // Returns screen width in pixels
winfo_screenmmwidth() // Returns screen width in mm
Code #1: Getting height and width in pixels.
Python3
from tkinter import * from tkinter.ttk import *
root = Tk()
height = root.winfo_screenheight()
width = root.winfo_screenwidth()
print ( "\n width x height = %d x %d (in pixels)\n" % (width, height))
mainloop()
|
Output:

Code #2: Getting height and width in mm.
Python3
from tkinter import * from tkinter.ttk import *
root = Tk()
height = root.winfo_screenmmheight()
width = root.winfo_screenmmwidth()
print ( "\n width x height = %d x %d (in mm)\n" % (width, height))
mainloop()
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
14 Sep, 2021
Like Article
Save Article