Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the screen size in Tkinter?

Tags:

python

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...

like image 533
DonJuma Avatar asked Oct 16 '10 17:10

DonJuma


2 Answers

import tkinter as tk  root = tk.Tk()  screen_width = root.winfo_screenwidth() screen_height = root.winfo_screenheight() 
like image 87
mouad Avatar answered Sep 21 '22 11:09

mouad


A possible solution

import os  os.system("xrandr  | grep \* | cut -d' ' -f4") 

My output:

1440x900 0 
like image 33
Nandit Tiku Avatar answered Sep 22 '22 11:09

Nandit Tiku