• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python compat.geterror函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pygame.compat.geterror函数的典型用法代码示例。如果您正苦于以下问题:Python geterror函数的具体用法?Python geterror怎么用?Python geterror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了geterror函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: load_image

def load_image(name): #Used to load the cursor and Toad image files
    fullname = os.path.join(main_dir, name)
    try:
        image = pygame.image.load(fullname)
    except pygame.error:
        print ('Cannot load image:', fullname)
        raise SystemExit(str(geterror()))
    return image, image.get_rect()
开发者ID:UAB-ACM-Hackathon,项目名称:ACMHackathon,代码行数:8,代码来源:ShroomClicker.py


示例2: test_geterror

 def test_geterror(self):
     msg = 'Success'
     try:
         raise TypeError(msg)
     except TypeError:
         e = compat.geterror()
         self.failUnless(isinstance(e, TypeError))
         self.failUnlessEqual(str(e), msg)
开发者ID:AjithPanneerselvam,项目名称:Gamepy,代码行数:8,代码来源:compat_test.py


示例3: load_image

def load_image(name, colorkey=None):
    fullname = os.path.join(data_dir, name)
    try:
        image = pygame.image.load(fullname)
    except pygame.error:
        print ('Cannot load image:', fullname)
        raise SystemExit(str(geterror()))
    return image
开发者ID:tcekle,项目名称:Sandbox,代码行数:8,代码来源:main.py


示例4: load_font

 def load_font(cls,name):
     fullname = Asset.resource_path(os.path.join(Asset.data_dir, name))
     font = None
     try:
         font = pygame.font.Font(fontfile, 26)
     except pygame.error:
         print ('Cannot load font:', fullname)
         raise SystemExit(str(geterror()))
     return font
开发者ID:IrwinKwan,项目名称:ld27_tsts,代码行数:9,代码来源:asset.py


示例5: load_sound

def load_sound(name): #Used to load the Toad's noises
    if not pygame.mixer or not pygame.mixer.get_init():
        return NoneSound()
    fullname = os.path.join(main_dir, name)
    try:
        sound = pygame.mixer.Sound(fullname)
    except pygame.error:
        print ('Cannot load sound: %s' % fullname)
        raise SystemExit(str(geterror()))
    return sound
开发者ID:UAB-ACM-Hackathon,项目名称:ACMHackathon,代码行数:10,代码来源:ShroomClicker.py


示例6: load_image

def load_image(name, scale=(30,200)):
    fullname = os.path.join(data_dir, name)
    try:
        image = pygame.image.load(fullname)
    except pygame.error:
        print ('Cannot load image:', fullname)
        raise SystemExit(str(geterror()))
    image = image.convert()
    image = pygame.transform.scale(image, scale)
    return image, image.get_rect()
开发者ID:karolmajta,项目名称:squirrel,代码行数:10,代码来源:helpers.py


示例7: __call__

    def __call__(self, *args, **kwargs):

        #we try to call the function here.  If it fails we store the exception.
        try:
            self.result = self.f(*args, **kwargs)
            if self.callback:
                self.callback(self.result)
        except Exception:
            self.exception = geterror()
            if self.errback:
                self.errback(self.exception)
开发者ID:123jefferson,项目名称:MiniBloq-Sparki,代码行数:11,代码来源:__init__.py


示例8: load_sound

def load_sound(name):
    class NoneSound:
        def play(self): pass
    if not pygame.mixer or not pygame.mixer.get_init():
        return NoneSound()
    fullname = os.path.join(data_dir, name)
    try:
        sound = pygame.mixer.Sound(fullname)
    except pygame.error:
        print ('Cannot load sound: %s' % fullname)
        raise SystemExit(str(geterror()))
    return sound
开发者ID:alex-polosky,项目名称:MyOldCode,代码行数:12,代码来源:chimp_gl3.py


示例9: _sound

def _sound(name):
    class NoneSound(object):
        def play(self):
            pass
    if not pygame.mixer or not pygame.mixer.get_init():
        return NoneSound()
    fullname = os.path.join(data_dir, name)
    try:
        return pygame.mixer.Sound(fullname)
    except pygame.error:
        print >> sys.stderr, 'Cannot load sound: %s' % fullname
        sys.exit(geterror())
开发者ID:phpboxxx,项目名称:ludumdare23,代码行数:12,代码来源:asset.py


示例10: load_image

def load_image(name, colorkey=None):
    fullname = os.path.join(img_dir, name)
    try:
        image = pygame.image.load(fullname)
    except pygame.error:
        print ('Cannot load image:', fullname)
        raise SystemExit(str(geterror()))
    #image = image.convert()
    if colorkey is not None:
        if colorkey is -1:
            colorkey = image.get_at((0,0))
        image.set_colorkey(colorkey, RLEACCEL)
    return image
开发者ID:rogerhil,项目名称:lettersgame,代码行数:13,代码来源:main.py


示例11: _image

def _image(name, colorkey=None):
    fullname = os.path.join(data_dir, name)
    try:
        image = pygame.image.load(fullname)
    except pygame.error:
        print >> sys.stderr, 'Cannot load image:', fullname
        sys.exit(geterror())
    image = image.convert()
    if colorkey is not None:
        if colorkey is -1:
            colorkey = image.get_at((0, 0))
        image.set_colorkey(colorkey, RLEACCEL)
    return image
开发者ID:phpboxxx,项目名称:ludumdare23,代码行数:13,代码来源:asset.py


示例12: load_one_alpha_image

 def load_one_alpha_image(cls, name, colorkey=None):
     fullname = Asset.resource_path(os.path.join(Asset.data_dir, name))
     try:
         image = pygame.image.load(fullname)
     except pygame.error:
         print ('Cannot load image:', fullname)
         raise SystemExit(str(geterror()))
     image = image.convert_alpha()
     if colorkey is not None:
         if colorkey is -1:
             colorkey = image.get_at((0,0))
         image.set_colorkey(colorkey, RLEACCEL)
     return image, image.get_rect()
开发者ID:IrwinKwan,项目名称:ld27_tsts,代码行数:13,代码来源:asset.py


示例13: load_image

def load_image(name, colorkey=None):
    fullname = os.path.join(data_dir, name)
    try:
        image = PyGL3Display.PyGL3Display_2dSprites.GL3PygameSurface.GL3Load(fullname)
    except pygame.error:
        print ('Cannot load image:', fullname)
        raise SystemExit(str(geterror()))
    
    image = image.convert()
    if colorkey is not None:
        if colorkey is -1:
            colorkey = image.get_at((0,0))
        image.set_colorkey(colorkey, RLEACCEL)
    return image, image.get_rect()
开发者ID:alex-polosky,项目名称:MyOldCode,代码行数:14,代码来源:chimp_gl3.py


示例14: load_image

def load_image(name, colorkey=None):
    filename = os.path.join(data_dir, name)
    try:
        image = pygame.image.load(filename)
    except pygame.error:
        raise SystemExit(str(geterror()))
    image = image.convert()

    if colorkey is not None:
        if colorkey is -1:
            # sets color key to color found at 0,0  in the image. that's actually pretty clever.
            colorkey = image.get_at((0, 0))
        image.set_colorkey(colorkey, pygame.RLEACCEL)
    return image, image.get_rect()
开发者ID:PeterCat12,项目名称:DeepStar,代码行数:14,代码来源:asset_loader.py


示例15: load_image

    def load_image(cls, name, rects, colorkey=None):
        if type(name) is not str:
            raise TypeError

        fullname = Asset.resource_path(os.path.join(Asset.data_dir, name))
        ss = spritesheet.spritesheet(fullname)
        images = None
        try:
            images = ss.images_at(rects, colorkey=colorkey)
        except pygame.error:
            print ('Cannot load image:', fullname)
            raise SystemExit(str(geterror()))

        return images
开发者ID:IrwinKwan,项目名称:ld27_tsts,代码行数:14,代码来源:asset.py


示例16: load_image

def load_image(name, colorkey=None):
    fullname = unicode(os.path.join(data_dir, name).decode(system_encoding))
    try:
        f = open(fullname, 'rb')
        content = f.read()
        f.seek(0)
        image = pygame.image.load(f, fullname.encode('utf-8'))
    except pygame.error:
        print ('Cannot load image:', fullname)
        raise SystemExit(str(geterror()))
    image = image.convert()
    if colorkey is not None:
        if colorkey is -1:
            colorkey = image.get_at((0,0))
        image.set_colorkey(colorkey, RLEACCEL)
    return image, image.get_rect()
开发者ID:PoolC,项目名称:pythonstudy,代码行数:16,代码来源:sprite.py


示例17: load_image

def load_image(name, name2=None):
    fullname = os.path.join(data_dir, name)
    try:
        image = pygame.image.load(fullname)
        if name2:
            image1 = image.convert_alpha()
            image2 = pygame.image.load(os.path.join(data_dir, name2))
            image2 = image2.convert_alpha()
            w = max(image2.get_width(), image1.get_width())
            h = max(image2.get_height(), image1.get_height())
            image = pygame.Surface((w,h), pygame.SRCALPHA, 32)
            image = image.convert_alpha()
            image.blit(image2, (1,1))
            image.blit(image1, (round(w/2 - image1.get_width()/2), 1))
    except pygame.error:
        print ('Cannot load image:', fullname)
        raise SystemExit(str(geterror()))
    image = image.convert_alpha()
    return image, image.get_rect()
开发者ID:feste,项目名称:party,代码行数:19,代码来源:party.py


示例18: test_post

    def test_post(self):
    
        # __doc__ (as of 2008-08-02) for pygame.fastevent.post:
    
          # pygame.fastevent.post(Event) -> None
          # place an event on the queue
          # 
          # This will post your own event objects onto the event queue.
          # You can past any event type you want, but some care must be
          # taken. For example, if you post a MOUSEBUTTONDOWN event to the
          # queue, it is likely any code receiving the event will expect
          # the standard MOUSEBUTTONDOWN attributes to be available, like
          # 'pos' and 'button'.
          # 
          # Because pygame.fastevent.post() may have to wait for the queue
          # to empty, you can get into a dead lock if you try to append an
          # event on to a full queue from the thread that processes events.
          # For that reason I do not recommend using this function in the
          # main thread of an SDL program.
    
        for _ in range(1, 11):
            fastevent.post(event.Event(pygame.USEREVENT))
        
        self.assertEquals (
            [e.type for e in event.get()], [pygame.USEREVENT] * 10,
            race_condition_notification
        )

        try:
            # Special case for post: METH_O.
            fastevent.post(1)
        except TypeError:
            e = geterror()
            msg = ("argument 1 must be %s, not %s" %
                   (fastevent.Event.__name__, type(1).__name__))
            self.failUnlessEqual(str(e), msg)
        else:
            self.fail()
开发者ID:AjithPanneerselvam,项目名称:Gamepy,代码行数:38,代码来源:fastevent_test.py


示例19: except

#first, the "required" modules
from pygame.base import *
from pygame.constants import *
from pygame.version import *
from pygame.rect import Rect
from pygame.compat import geterror
from pygame.rwobject import encode_string, encode_file_path
import pygame.surflock
import pygame.color
Color = color.Color
__version__ = ver

#next, the "standard" modules
#we still allow them to be missing for stripped down pygame distributions
try: import pygame.math
except (ImportError,IOError):math=MissingModule("math", geterror(), 1)

try: import pygame.cdrom
except (ImportError,IOError):cdrom=MissingModule("cdrom", geterror(), 1)

try: import pygame.cursors
except (ImportError,IOError):cursors=MissingModule("cursors", geterror(), 1)

try: import pygame.display
except (ImportError,IOError):display=MissingModule("display", geterror(), 1)

try: import pygame.draw
except (ImportError,IOError):draw=MissingModule("draw", geterror(), 1)

try: import pygame.event
except (ImportError,IOError):event=MissingModule("event", geterror(), 1)
开发者ID:SantoKo,项目名称:RPI3-Desktop,代码行数:31,代码来源:__init__.py


示例20: except

from pygame.version import *
from pygame.rect import Rect
from pygame.compat import geterror
import pygame.rwobject
import pygame.surflock
import pygame.color

Color = color.Color
__version__ = ver

# next, the "standard" modules
# we still allow them to be missing for stripped down pygame distributions
try:
    import pygame.cdrom
except (ImportError, IOError):
    cdrom = MissingModule("cdrom", geterror(), 1)

try:
    import pygame.cursors
except (ImportError, IOError):
    cursors = MissingModule("cursors", geterror(), 1)

try:
    import pygame.display
except (ImportError, IOError):
    display = MissingModule("display", geterror(), 1)

try:
    import pygame.draw
except (ImportError, IOError):
    draw = MissingModule("draw", geterror(), 1)
开发者ID:sorcerer-com,项目名称:MyHome,代码行数:31,代码来源:__init__.py



注:本文中的pygame.compat.geterror函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python compat.xrange_函数代码示例发布时间:2022-05-25
下一篇:
Python compat.as_unicode函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap