def my_slideshow(new_img, img, screen, file, num_imgs, rect): if not gl.TOGGLE_FULLSCREEN_SET: screen = set_mode(screen.get_size()) set_caption("Slideshow Options - imgv") speed = get_speed(screen, new_img, rect, gl.files[file], file, num_imgs) if not speed == -1: # didn't hit Esc from get_speed: gl.SLIDE_SHOW_RUNNING = 1 disable_screensaver() dont_call = 0 pygame.event.set_blocked(MOUSEMOTION) while 1: event = pygame.event.poll() pygame.time.wait(1) check_quit(event) if event.type == KEYDOWN and event.key not in (K_LALT, K_RALT, K_LCTRL, K_RCTRL, K_p, K_PAUSE, K_TAB, K_SPACE, K_BACKSPACE): stopped_msg(screen) my_update_screen(new_img, screen, rect, file, len(gl.files)) file = file - 1 break if hit_key(event, K_p) or hit_key(event, K_PAUSE): pause(screen) my_update_screen(new_img, screen, rect, file, len(gl.files)) if dont_call == 1: break if not gl.WRAP_SLIDESHOW: if file < num_imgs: (new_img, file, rect, dont_call) = show_slideshow_img(screen, new_img, file, num_imgs, speed) if gl.WRAP_SLIDESHOW: if file >= num_imgs: file = 0 (new_img, file, rect, dont_call) = show_slideshow_img(screen, new_img, file, num_imgs, speed) pygame.time.delay(5) # don't hog CPU if not gl.TOGGLE_FULLSCREEN_SET: screen = set_mode(screen.get_size(), RESIZABLE) return (new_img, new_img, new_img, file, rect)
def my_fourslideshow(screen, new_img, rect, filename, file, num_imgs, img_one_file, img_two_file, img_three_file, img_four_file, ns): if not gl.TOGGLE_FULLSCREEN_SET: screen = set_mode(screen.get_size()) set_caption("Slideshow Options - imgv") speed = get_speed(screen, new_img, rect, filename, file, num_imgs) if not speed == -1: # didn't hit Esc from get_speed: gl.SLIDE_SHOW_RUNNING = 1 disable_screensaver() dont_call = 0 while 1: event = pygame.event.poll() pygame.time.wait(1) check_quit(event) if event.type == KEYDOWN and event.key not in (K_LALT, K_RALT, K_LCTRL, K_RCTRL,\ K_p, K_PAUSE, K_TAB, K_SPACE, K_BACKSPACE): stopped_msg(screen) file = file - 1 (file, new_img, start) = four(screen, file, new_img, ns) # needed to repaint break if hit_key(event, K_p) or hit_key(event, K_PAUSE): pause(screen) if dont_call == 1: break if not gl.WRAP_SLIDESHOW: if file < num_imgs: (file, dont_call, img_one_file, img_two_file, img_three_file, img_four_file) =\ show_fourslideshow_imgs(screen, file, speed) if gl.WRAP_SLIDESHOW: if file >= num_imgs: file = 0 (file, dont_call, img_one_file, img_two_file, img_three_file, img_four_file) =\ show_fourslideshow_imgs(screen, file, speed) pygame.time.delay(5) else: # escaped file = file + 4 return (file, img_one_file, img_two_file, img_three_file, img_four_file) if not gl.TOGGLE_FULLSCREEN_SET: screen = set_mode(screen.get_size(), RESIZABLE) return (file, img_one_file, img_two_file, img_three_file, img_four_file)
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