用python写出监视器,在python中获取监视器大小

I am using python and want to create a fullscreen window. I know about the pygame.FULLSCREEN flag but when I use that there's areas of black around the screen. Is there any way to get the monitor size using python so I can make the window the correct size?

解决方案

Per the docs, pygame.display.Info gives you a VideoInfo object that has, among other attributes:

current_w, current_h: Width and

height of the current video mode, or

of the

desktop mode if called before the display.set_mode is called.

pygame.display.list_modes gives you a list of the available fullscreen resolutions, e.g., per a comment in the docs:

>>> pygame.display.list_modes()

[(1920, 1080), (1768, 992), (1680, 1050), (1600, 1200), (1600, 1024), (1600, 900

), (1440, 900), (1400, 1050), (1360, 768), (1280, 1024), (1280, 960), (1280, 800

), (1280, 768), (1280, 720), (1152, 864), (1024, 768), (800, 600), (720, 576), (

720, 480), (640, 480)]

largest to smallest. You should try some of these possibilities with pygame.display.set_mode to see which one looks good for you.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值