Python pygame 模块,ver() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用pygame.ver()

项目:Projects    作者:it2school    | 项目源码 | 文件源码
def test_issue_269 (self):
        """PyColor OverflowError on HSVA with hue value of 360

           >>> c = pygame.Color(0)
           >>> c.hsva = (360,0,0,0)
           Traceback (most recent call last):
             File "<stdin>", line 1, in <module>
           OverflowError: this is not allowed to happen ever
           >>> pygame.ver
           '1.9.1release'
           >>>

        """

        c = pygame.Color(0)
        c.hsva = 360, 0, 0, 0
        self.assertEqual(c.hsva, (0, 0, 0, 0))
        c.hsva = 360, 100, 100, 100
        self.assertEqual(c.hsva, (0, 100, 100, 100))
        self.assertEqual(c, (255, 0, 0, 255))

####################### COLORSPACE PROPERTY SANITY TESTS #######################
项目:DollopOS    作者:AppleJuiceSnake    | 项目源码 | 文件源码
def startup():
    global aboutopened
    screen.blit(bg, (1, 1))
    screen.blit(tskbar, (0,440))
    screen.blit(tskbar, (0,0))
    if aboutopened:
        screen.blit(close, (280,0))
    if not aboutopened:
        screen.blit(sdicon, (280,0))
    screen.blit(logo, (288,448))
    screen.blit(menu, (0,440))
    screen.blit(respring, (240,0))
    screen.blit(dbtb, (0,0))
    display_text(time,black,35,50,440)
    pygame.display.flip()
    # Create stuff to log
    if not runningBootPy:
        print ("Current Platform: ", sys.platform)
        print ("Current Revision: ", currev)
        print ("Pygame Version", pygame.ver)
    mainLoop()
项目:solarwolf    作者:pygame    | 项目源码 | 文件源码
def checkdependencies():
    "only returns if everything looks ok"
    msgs = []

    #make sure this looks like the right directory
    if not os.path.isdir(CODEDIR):
        msgs.append('Cannot locate SolarWolf modules')
    if not os.path.isdir('data'):
        msgs.append('Cannot locate SolarWolf data files')

    #first, we need python >= 2.1
    if int(sys.version[0]) < 2:
        errorbox('Requires Python-2.1 or Greater')

    #is correct pygame found?
    try:
        import pygame
        if pygame.ver < '1.5.6':
            msgs.append('Requires Pygame-1.5.6 or Greater, You Have ' + pygame.ver)
    except ImportError:
        msgs.append("Cannot import Pygame, install version 1.5.6 or higher")
        pygame = None

    #check that we have FONT and IMAGE
    if pygame:
        if not pygame.font:
            msgs.append('Pygame requires the SDL_ttf library, not available')
        if not pygame.image or not pygame.image.get_extended():
            msgs.append('Pygame requires the SDL_image library, not available')

    if msgs:
        msg = '\n'.join(msgs)
        errorbox(msg)



#Pretty Error Handling Code...
项目:DollopOS    作者:AppleJuiceSnake    | 项目源码 | 文件源码
def start():
    logg = open(os.path.join(os.getcwd(), "logs", strftime("%Y_%-m_%-d_%-I_%-M_%-S_dollop-os.log")), "w+")
    logg.write("DollopOS is now starting up...")
    print("Current Platform: ", sys.platform)
    print("Current Revision: ", currev)
    print("Pygame Version", pygame.ver)
    logg.write("Platfrom:")
    logg.write(sys.platform)
    logg.write("\n")
    logg.write("Revision:")
    logg.write(currev)
    logg.write("\n")
    logg.write("Pygame Version:")
    logg.write(pygame.ver)
    logg.write("\n")

    process = subprocess.Popen("python main.py booting", shell=True, stdout=subprocess.PIPE)
    while process.returncode == None:
        print(process.communicate()[0])
        if process.communicate()[0] == "Restarting...":
            global restarted
            logg.close()
            restarted = True
            process.kill()
            start()
        logg.write(process.communicate()[0])

    if (process.returncode == 0):
        exit()
    else:
        print(process.returncode)
        from errno import errorcode
        print(errorcode.get(process.returncode))
        exit()
项目:enderX    作者:Pugduddly    | 项目源码 | 文件源码
def uhOhAnError(status):
    global threads
    if sounds:
        sounds['Indigo.wav'].play()
    for thread in threads:
        thread.stop()
    print "Uh-oh. An error occurred."
    Config = ConfigParser.ConfigParser()
    Config.read("enderX.ini")
    Assets = enderAPI.ConfigSectionMap(Config, "Assets")
    Textures = enderAPI.ConfigSectionMap(Config, "Textures")
    System = enderAPI.ConfigSectionMap(Config, "System")
    Fonts = enderAPI.ConfigSectionMap(Config, "Fonts")
    texturesFolder = os.path.join(Assets['assetsfolder'], Textures['texturesfolder'])
    try:
        SCREEN_WIDTH = int(System['screenwidth'])
        SCREEN_HEIGHT = int(System['screenheight'])
    except Exception:
        print "Error while getting screen width & height from config file. Reverting to 640x480"
        SCREEN_WIDTH, SCREEN_HEIGHT = 640, 480
    size = [SCREEN_WIDTH, SCREEN_HEIGHT]
    screen = pygame.display.set_mode(size)
    pygame.display.set_caption(" ")
    clockError = pygame.time.Clock()
    foobar = True
    fooBar = pygame.image.load(os.path.join(texturesFolder,'fatalerror.png'))
    screenCorners = [pygame.image.load(os.path.join(texturesFolder, 'menubar', 'cornerL_b.png')), pygame.image.load(os.path.join(texturesFolder, 'menubar', 'cornerR_b.png')), pygame.image.load(os.path.join(texturesFolder, 'menubar', 'cornerL_c.png')), pygame.image.load(os.path.join(texturesFolder, 'menubar', 'cornerR_c.png'))]
    #uptime = int(calendar.timegm(time.gmtime()))-int(psutil.boot_time())
    uptime = getUptime()
    errormsg = ["Fatal Error",""] + traceback.format_exc().splitlines() + ["", "System info:",
        "Python %d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]), "Pygame %s" % pygame.ver, "SDL %d.%d.%d" % pygame.get_sdl_version(), platform.platform(),
        "system: %s" % str(platform.system()), "node: %s" % str(platform.node()), "release: %s" % str(platform.release()), "version: %s" % str(platform.version()), "machine: %s" % str(platform.machine()),
        "processor: %s" % str(platform.processor()), "", "System uptime in seconds: %d" % uptime, "System status: %s" % status]
    font = pygame.font.Font(os.path.join(Assets['assetsfolder'], Fonts['fontsfolder'], '16', 'ScratchySans.ttf'), 16)
    while(foobar): # Keep window open
        events = pygame.event.get() # Get events
        for event in events:
            if event.type == pygame.QUIT: # Goodbye
                foobar = False
        screen.fill(BG_COLOR)
        screen.blit(fooBar, (SCREEN_WIDTH/2-64,SCREEN_HEIGHT/2-64))
        yPos = 0
        for msg in errormsg:
            screen.blit(font.render(msg, False, (255,255,255), (0,0,0)), (0,yPos))
            yPos+=font.size(msg)[1]
        screen.blit(screenCorners[0], (0,SCREEN_HEIGHT-5))
        screen.blit(screenCorners[1], (SCREEN_WIDTH-5,SCREEN_HEIGHT-5))
        screen.blit(screenCorners[2], (0,0))
        screen.blit(screenCorners[3], (SCREEN_WIDTH-5,0))
        clockError.tick(10)
        pygame.display.flip()
    pygame.quit()
    sys.exit()