Search code examples
pythontkinter

How can I get the screen size in Tkinter?


I would like to know if it is possible to calculate the screen size using Tkinter.

I wanted this so that can make the program open up in the center of the screen...


Solution

  • import tkinter as tk
    
    root = tk.Tk()
    
    screen_width = root.winfo_screenwidth()
    screen_height = root.winfo_screenheight()