Python/PyQt4: How do you find the SIZE of a monitor (in inches)?

我与影子孤独终老i 提交于 2019-12-20 01:46:24

问题


I'm trying to find the horizontal width of a monitor in inches or cm (not pixels!) to make a small "ruler" program. DPI would work too.

I'm using PyQt4.


回答1:


try using the QDesktopWidget's width() and height() to get the width and height respectively. Class reference at QDesktopWidget Class Reference, this will give you the screens size in pixels and then use QX11Info.appDpiX, this will give you the DPI in pixels per inch. Use both the above info to calculate the screen size in inches.

PS: The width() returns the union width, so in case you have multiple screens, it will return union width of all the screens.



来源:https://stackoverflow.com/questions/19070370/python-pyqt4-how-do-you-find-the-size-of-a-monitor-in-inches

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!