Ejemplo n.º 1
0
def stopped_msg(screen):
    gl.SLIDE_SHOW_RUNNING = 0
    set_caption("[Slideshow Stopped] - imgv")
    enable_screensaver()
    show_message(screen, "Stopped", 30, 23, ("bold"))
    pygame.time.wait(1000) # display the stopped message for 1 second
Ejemplo n.º 2
0
def load_img(img_file, screen, allow_zoom=True):
    "load images and movies"
    if not gl.PERSISTENT_ZOOM_VAL:
        gl.ZOOM_EXP = 0
    if gl.PLAY_LIST_NAME != " ":
        gl.CUR_PATH = img_file
    else:
        gl.CUR_PATH = getcwd() + sep + img_file
    try:
        gl.CUR_PATH = gl.CUR_PATH[gl.CUR_PATH.rindex(getcwd()):] # only show path once
    except:
        print "Couldn't load image"
    try:
        if img_file[:5] == "http:": # load url
            try:
                gl.REMOTE = 1
                pic = urlopen(img_file).read()
                img = load(StringIO(pic))
                gl.REAL_WIDTH, gl.REAL_HEIGHT = img.get_width(), img.get_height()
                if gl.PERSISTENT_ZOOM_VAL and allow_zoom is True:
                    img = zoom_adjust(img)
                gl.REMOTE_FILE_SIZE = len(pic)
                gl.REMOTE_IMG_DATA = StringIO(pic)
                gl.REMOTE_IMG = img_file
                gl.ALREADY_DOWNLOADED = 0
            except:
                img = load(gl.ERROR_IMG).convert()
                gl.REAL_WIDTH, gl.REAL_HEIGHT = img.get_width(), img.get_height()
        elif insensitive_find(img_file, ".mpg") != -1 or insensitive_find(img_file, ".mpeg") != -1:
            disable_screensaver()
            if gl.THUMBING or gl.MULTI_VIEWING:
                img = load(gl.MOVIE_FILE).convert()
                gl.REAL_WIDTH, gl.REAL_HEIGHT = img.get_width(), img.get_height()
                if gl.PERSISTENT_ZOOM_VAL and allow_zoom is True:
                    img = zoom_adjust(img)
            else:
                img = load_movie(screen, img_file)
                gl.REAL_WIDTH, gl.REAL_HEIGHT = img.get_width(), img.get_height()
            if not gl.SLIDE_SHOW_RUNNING:
                enable_screensaver()
            return img
        else:
            # load normal image
            gl.REMOTE = 0
            img = load(img_file).convert()
            gl.REAL_WIDTH, gl.REAL_HEIGHT = img.get_width(), img.get_height()
            if (gl.FIT_IMAGE_VAL == 3 or (gl.SLIDE_SHOW_RUNNING and gl.FIT_IMAGE_SLIDESHOW_VAL == 3)) and allow_zoom is True:
                screen = fit_window(screen, img)
            if gl.PERSISTENT_ZOOM_VAL and allow_zoom is True:
                img = zoom_adjust(img)
    except error:
        img = load(gl.ERROR_IMG).convert()
        gl.REAL_WIDTH, gl.REAL_HEIGHT = img.get_width(), img.get_height()
    if gl.SLIDE_SHOW_RUNNING and gl.FIT_IMAGE_SLIDESHOW_VAL and not gl.SKIP_FIT:
        if gl.FIT_IMAGE_SLIDESHOW_VAL == 1:
            if (gl.REAL_WIDTH > screen.get_rect().right or gl.REAL_HEIGHT > screen.get_rect().bottom) or gl.SCALE_UP:
                img = fit_image(img, screen)
        if gl.FIT_IMAGE_SLIDESHOW_VAL == 2:
            img = fit_image(img, screen)
    if gl.FIT_IMAGE_VAL and not gl.SKIP_FIT and not gl.SLIDE_SHOW_RUNNING:
        if gl.FIT_IMAGE_VAL == 1:
            if (gl.REAL_WIDTH > screen.get_rect().right or gl.REAL_HEIGHT > screen.get_rect().bottom) or gl.SCALE_UP:
                img = fit_image(img, screen)
        if gl.FIT_IMAGE_VAL == 2 and allow_zoom is True:
            img = fit_image(img, screen)
    gl.SKIP_FIT = 0
    return img