#! /usr/bin/env python2.7 # -*- coding:utf-8 -*- #File:PG3.py #Date:2013-7-2 #Author:wangyu background_image_filename='8wxpython.jpg' import pygame from pygame.locals import * from sys import exit pygame.init() screen =pygame.display.set_mode((1640,980),0,32) background=pygame.image.load(background_image_filename).convert() Fullscreen=False while True: for event in pygame.event.get(): if event.type ==QUIT: exit() if event.type == KEYDOWN: if event.key == K_f: Fullcsreen= not Fullscreen if Fullscreen: screen=pygame.display.set_mode((1248,960),FULLSCREEN,32) else: screen=pygame.display.set_mode((640,480),0,32) screen.blit(background,(0,0)) pygame.display.update()
这时一个控制窗口大小的简单程序,其中通过按f键就能从大屏切换到小屏,下图为大图
下面为按过f键之后的界面.
这些代码的最初位置为:http://eyehere.net/2011/python-pygame-novice-professional-3/
里面有最详细的解释,只是里面的代码有点为题,我进行了改动
感谢原作者