def __main_menu(self):
# self.fill = pygame.draw.rect(self.screen,pygame.Color('red'),(0,0,800,600),0)
# self.text_rect = self.fonts.render_to(self.screen,(200,160),'TEST TEXT',fgcolor=(190,190,190),size=50)
# set background image
background = pygame.image.load(
r'..\..\resources\images\MainMenu.png').convert()
self.screen.blit(pygame.transform.scale(
background, (1280, 720)), (0, 0))
self.history_size = width, height = 1280, 720
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.VIDEORESIZE:
if event.size[1]/0.5625 == event.size[0]:
self.screen.blit(pygame.transform.scale(
background, (event.size[0], event.size[1])), (0, 0))
self.history_size = width, height = event.size[0], event.size[1]
elif event.size[0] == self.history_size[0]:
self.screen = pygame.display.set_mode(
(event.size[0], int(event.size[0]*0.5625)), pygame.RESIZABLE, 32)
self.screen.blit(pygame.transform.scale(
background, (event.size[0], int(event.size[0]*0.5625)), (0, 0))
self.history_size=width, height=event.size[0], int(
event.size[0]*0.5625) #就是提示这段代码有问题
#具体显示:
#
#G:\xxx>D:/Software/Python/python.exe "g:/xxx/Libs/DisplayContent/mainloop.py"
# File "g:\xxx\Libs\DisplayContent\mainloop.py", line 92
# self.history_size=width, height=event.size[0], int(
# ^
#SyntaxError: invalid syntax
#
elif event.size[1] == self.history_size[1]:
self.screen=pygame.display.set_mode(
(int(event.size[1]/0.5625), event.size[1]), pygame.RESIZABLE, 32)
self.screen.blit(pygame.transform.scale(
background, (int(event.size[1]/0.5625), event.size[1])), (0, 0))
self.history_size=width, height=int(
event.size[1]/0.5625), event.size[1]
else:
continue
pygame.display.update()