Python pygame.error() Examples

The following are 30 code examples of pygame.error(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pygame , or try the search function .
Example #1
Source File: _Player.py    From PyDMXControl with GNU General Public License v3.0 6 votes vote down vote up
def __play(self, file, start_millis):
        # Stop anything previous
        self.stop()

        # Set states
        self.__paused = False
        self.__done = False

        # Get the file
        try:
            pygame.mixer.music.load(file)
        except pygame.error:
            self.__done = True
            raise AudioException("Error occurred loading '{}': {}".format(file, pygame.get_error()))

        # Play the file and tick until play completed
        pygame.mixer.music.play(start=start_millis / 1000)
        while pygame.mixer.music.get_busy():
            sleep(DMXMINWAIT)

        # Let everyone know play is done
        self.__done = True 
Example #2
Source File: resources.py    From QPong with Apache License 2.0 5 votes vote down vote up
def load_image(name, colorkey=None, scale=WIDTH_UNIT/13):
    fullname = os.path.join(data_dir, 'images', 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)
    image = pygame.transform.scale(image, tuple(round(scale*x) for x in image.get_rect().size))
    return image, image.get_rect() 
Example #3
Source File: resources.py    From QPong with Apache License 2.0 5 votes vote down vote up
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, 'sound', name)
    try:
        sound = pygame.mixer.Sound(fullname)
    except pygame.error:
        print('Cannot load sound: %s' % fullname)
        raise SystemExit(str(geterror()))
    return sound 
Example #4
Source File: pyrpg11.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #5
Source File: pyrpg01.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #6
Source File: pyrpg13.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #7
Source File: pyrpg22.py    From pygame with MIT License 5 votes vote down vote up
def load_image(dir, file, colorkey=None):
    file = os.path.join(dir, file)
    try:
        image = pygame.image.load(file)
    except pygame.error, message:
        print "Cannot load image:", file
        raise SystemExit, message 
Example #8
Source File: pyrpg10.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #9
Source File: pyrpg05.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #10
Source File: pyrpg06.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #11
Source File: pyrpg07.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #12
Source File: pyrpg04.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #13
Source File: pyrpg17.py    From pygame with MIT License 5 votes vote down vote up
def load_image(dir, file, colorkey=None):
    file = os.path.join(dir, file)
    try:
        image = pygame.image.load(file)
    except pygame.error, message:
        print "Cannot load image:", file
        raise SystemExit, message 
Example #14
Source File: pyrpg02.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #15
Source File: pyrpg08.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #16
Source File: pyrpg25.py    From pygame with MIT License 5 votes vote down vote up
def load_image(dir, file, colorkey=None):
    file = os.path.join(dir, file)
    try:
        image = pygame.image.load(file)
    except pygame.error, message:
        print "Cannot load image:", file
        raise SystemExit, message 
Example #17
Source File: pyrpg26.py    From pygame with MIT License 5 votes vote down vote up
def load_image(dir, file, colorkey=None):
    file = os.path.join(dir, file)
    try:
        image = pygame.image.load(file)
    except pygame.error, message:
        print "Cannot load image:", file
        raise SystemExit, message 
Example #18
Source File: pyrpg19.py    From pygame with MIT License 5 votes vote down vote up
def load_image(dir, file, colorkey=None):
    file = os.path.join(dir, file)
    try:
        image = pygame.image.load(file)
    except pygame.error, message:
        print "Cannot load image:", file
        raise SystemExit, message 
Example #19
Source File: pyrpg12.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #20
Source File: pyrpg24.py    From pygame with MIT License 5 votes vote down vote up
def load_image(dir, file, colorkey=None):
    file = os.path.join(dir, file)
    try:
        image = pygame.image.load(file)
    except pygame.error, message:
        print "Cannot load image:", file
        raise SystemExit, message 
Example #21
Source File: pyrpg18.py    From pygame with MIT License 5 votes vote down vote up
def load_image(dir, file, colorkey=None):
    file = os.path.join(dir, file)
    try:
        image = pygame.image.load(file)
    except pygame.error, message:
        print "Cannot load image:", file
        raise SystemExit, message 
Example #22
Source File: pyrpg21.py    From pygame with MIT License 5 votes vote down vote up
def load_image(dir, file, colorkey=None):
    file = os.path.join(dir, file)
    try:
        image = pygame.image.load(file)
    except pygame.error, message:
        print "Cannot load image:", file
        raise SystemExit, message 
Example #23
Source File: pyrpg14.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #24
Source File: pyrpg20.py    From pygame with MIT License 5 votes vote down vote up
def load_image(dir, file, colorkey=None):
    file = os.path.join(dir, file)
    try:
        image = pygame.image.load(file)
    except pygame.error, message:
        print "Cannot load image:", file
        raise SystemExit, message 
Example #25
Source File: pyrpg16.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #26
Source File: pyrpg15.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #27
Source File: pymap01.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("data", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #28
Source File: pymap07.py    From pygame with MIT License 5 votes vote down vote up
def load_image(dir, file, colorkey=None):
    file = os.path.join(dir, file)
    try:
        image = pygame.image.load(file)
    except pygame.error, message:
        print "Cannot load image:", file
        raise SystemExit, message 
Example #29
Source File: pymap03.py    From pygame with MIT License 5 votes vote down vote up
def load_image(filename, colorkey=None):
    filename = os.path.join("mapchip", filename)
    try:
        image = pygame.image.load(filename)
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message 
Example #30
Source File: pymap04.py    From pygame with MIT License 5 votes vote down vote up
def load_image(dir, file, colorkey=None):
    file = os.path.join(dir, file)
    try:
        image = pygame.image.load(file)
    except pygame.error, message:
        print "Cannot load image:", file
        raise SystemExit, message