如何在python中获取系统颜色



获取此信息。如何在python中获取颜色/外观。例如,如果用户使用的是系统范围的深色主题还是浅色主题?提前谢谢。

您也可以使用darkdetect模块。它适用于Windows和macOS
pip install darkdetect
现在,展示它的工作原理:

import darkdetect
if darkdetect.isDark():
print("Dark mode is enabled.")
else:
print("Dark mode is not enabled.")

有关darkdetect的更多信息,请点击此处。

from os import system
command = 'theme=$(defaults read -g AppleInterfaceStyle) && if [[ $theme == "Dark" ]]; then python3 -c "from color import ifdark; ifdark()"; else python3 -c "from color import iflight; iflight()"; fi'
theme = system(command)

CCD_ 4将返回"0";深色";如果主题是深色的,如果不是,则显示特定于用户的消息。

最新更新