简体   繁体   English

如何检查 Python 或终端中的 Retina 显示屏?

[英]How to check is it a Retina Display in Python or Terminal?

I use the Python module pyautogui .我使用 Python 模块pyautogui
It has problems with Retina display's and i must check if the script runs on a computer with a retina display.视网膜显示器有问题,我必须检查脚本是否在带有视网膜显示器的计算机上运行。

I found this code, but it's not working (anymore).我找到了这段代码,但它不起作用(不再)。

if subprocess.call("system_profiler SPDisplaysDataType | grep 'retina'", shell=True) == 0:
        IS_RETINA = True

Is there any other command to check if the computer has a retina display?是否有任何其他命令可以检查计算机是否具有视网膜显示器?
I use OSX Mojave 10.14.6我使用 OSX Mojave 10.14.6

I just tried, got False.我刚试了一下,结果是假的。 Then when I checked the whole output, I can see string Retina with a capital R.然后,当我检查整个 output 时,我可以看到带有大写 R 的字符串 Retina。 So I changed所以我改变了

if subprocess.call("system_profiler SPDisplaysDataType | grep 'retina'", shell=True) == 0:
        IS_RETINA = True

to

if subprocess.call("system_profiler SPDisplaysDataType | grep -i 'retina'", shell=True) == 0:
        IS_RETINA = True

and it worked.它奏效了。

Try that试试看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM