How do I get monitor resolution in Python?

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

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

30条回答
  •  清歌不尽
    2020-11-22 14:43

    A cross platform and easy way to do this is by using TKinter that comes with nearly all the python versions so you don't have to install anything:

    import tkinter
    root = tkinter.Tk()
    root.withdraw()
    WIDTH, HEIGHT = root.winfo_screenwidth(), root.winfo_screenheight()
    

提交回复
热议问题