How do I get monitor resolution in Python?

后端 未结 30 1567
深忆病人
深忆病人 2020-11-22 13:49

What is the simplest way to get monitor resolution (preferably in a tuple)?

30条回答
  •  佛祖请我去吃肉
    2020-11-22 14:51

    For Linux, you can use this:

    import gi
    gi.require_version("Gdk", "3.0")
    from gi.repository import Gdk
    
    s = Gdk.Screen.get_default()
    screen_width = s.get_width()
    screen_height = s.get_height()
    print(screen_width)
    print(screen_height)
    

提交回复
热议问题