Get the screen size(width and height) in Tkinter

here we will able to get the screen size  in terms of width and height in the tkinter.

We will able to get an idea of  how to set the width and height of the screen size in the Tkinter.

Algorithm

  • At first we will import the Tkinter as tk.
  • Next we will create a window.
  • Then we will adjust the screen width.
  • Next we will adjust the screen height.
  • We will print the screen width.
  • Then we will print the screen height.
  • At last we will use main loop.

Source Code 

Here is the code.

import tkinter as tk

win = tk.Tk() # creating a window

screen_width = win.winfo_screenwidth() # getting screen width
screen_height = win.winfo_screenheight() # getting screen height

print("Screen width:", screen_width)
print("Screen height:", screen_height)

win.mainloop()

Output:

Screen width: 1536
Screen height: 864

Leave a Comment

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

Scroll to Top