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 inpixelswinfo_screenmmheight() // Returns screen height inmmwinfo_screenwidth() // Returns screen width inpixelswinfo_screenmmwidth() // Returns screen width inmm
Code #1: Getting height and width in pixels.
Python3# importing tkinter modulefromtkinterimport*fromtkinter.ttkimport*# creating tkinter windowroot=Tk()# getting screen's height in pixelsheight=root.winfo_screenheight()# getting screen's width in pixelswidth=root.winfo_screenwidth()print("\n width x height =%d x%d (in pixels)\n"%(width,height))# infinite loopmainloop()
Output:

Code #2: Getting height and width in mm.
Python3# importing tkinter modulefromtkinterimport*fromtkinter.ttkimport*# creating tkinter windowroot=Tk()# getting screen's height in mmheight=root.winfo_screenmmheight()# getting screen's width in mmwidth=root.winfo_screenmmwidth()print("\n width x height =%d x%d (in mm)\n"%(width,height))# infinite loopmainloop()
Output:
