Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
Python | How to dynamically change text of Checkbutton
Next article icon

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: 
 


 


Improve
Practice Tags :

Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp