Python OSX上Pygame的全屏分辨率错误
我正在尝试用python+pygame为OSX创建一个全屏应用程序,但请注意,要创建具有正确分辨率的显示是不可能的Python OSX上Pygame的全屏分辨率错误,python,macos,pygame,Python,Macos,Pygame,我正在尝试用python+pygame为OSX创建一个全屏应用程序,但请注意,要创建具有正确分辨率的显示是不可能的 import pygame, logging, sys logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) pygame.init() screen_info = pygame.display.Info() flags = pygame.DOUBLEBUF | pygame.HWSURFACE | pygame.
import pygame, logging, sys
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
pygame.init()
screen_info = pygame.display.Info()
flags = pygame.DOUBLEBUF | pygame.HWSURFACE | pygame.FULLSCREEN
screen = pygame.display.set_mode((0, 0), flags)
done = False
rect_w = 60
rect_h = 60
x = (screen_info.current_w / 2) - (rect_w / 2)
y = (screen_info.current_h / 2) - (rect_h / 2)
logging.debug('Screen res is ' + str(screen_info.current_w) + 'x' + str(screen_info.current_h))
logging.debug('Center is ' + str(x) + 'x' + str(y))
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
done = True
color = (255, 100, 0)
pygame.draw.rect(screen, color, pygame.Rect(x, y, rect_w, rect_h))
pygame.display.flip()
<> P>当我运行这个代码时,我可以看到我的ReCt不在屏幕中间。经过一些调试后,应用程序似乎在顶部和底部留下了空格。此外,右侧被切断
我这里出了什么问题 我无法用提供的代码复制此文件。请您再确认一下好吗?我还要求您编辑代码并将其格式设置得更好:缩进被弄乱了,这使得很难分辨块内有什么,没有什么。@batbrat Check now,我更新了缩进。这很奇怪,我刚刚重新启动了电脑,现在屏幕的顶部和底部似乎都没有空格。但现在我的屏幕是白色的。当我按下ESC键时,我看到我的应用程序在退出前带有rect fast(在正确的位置)。@batbrat ok,它现在工作了。重启成功了。不知道我的外部屏幕的插入/插入是否会导致这种情况。