屏幕python的像素数

屏幕python的像素数

问题描述:

如何使用python计算屏幕中的像素数(宽度,高度)?

How can I calculate the number of pixels in screen (width, height) with python?

我希望它可以适应任何屏幕,这可能吗?

I want it to be adaptable to any screen, is this possible?

此问题的借用:

Borrowing from this question: How do I get monitor resolution in Python?, there are several options. Here's one with Tkinter:

import Tkinter as tk

root = tk.Tk()

screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()

print screen_width * screen_height # (e.g.) 3686400 = 2560*1440

其他帖子有很多不同的方式为此,包括获取有关多显示器设置,Windows操作系统实现,DPI等的信息.

That other post has a lot of different ways to do it, including getting information about multi-monitor setup, Windows OS implementations, DPI, etc.