def edit_play_list(screen, play_list_name): paint_screen(gl.BLACK) keep_going = 1 play_list = gl.DATA_DIR + play_list_name f = open(play_list) file_names = f.readlines() f.close() if len(file_names) < 1: play_list_options_msg(screen, "Can't edit %s, it is empty" %\ play_list) keep_going = 0 for count in range(len(file_names)): file_names[count] = file_names[count].replace('\n', '') normal_cursor() if keep_going: (list_names, play_list_item, x, my_string) = command_file_master(screen,\ file_names, "Click item to delete it from play list", 47, 0, 1, "do again") file_names = delete_item(screen, play_list_item, play_list) if x == "do again": while 1: if len(file_names) < 1: break (list_names, play_list_item, x, my_string) = command_file_master(screen,\ file_names, "Click to delete another item from play list", 47, 0, 1,\ "do again") file_names = delete_item(screen, play_list_item, play_list) if x != "do again": break
def command_add_to_play_list(screen, filename): paint_screen(gl.BLACK) normal_cursor() gl.SORT_HIT = 1 small_font = pygame.font.Font(gl.FONT_NAME, 10) f = open(gl.IMGV_PLAYLISTS) file_names = f.readlines() if len(file_names) == 0: return (file_names, None, None, None, None) f.close() file_names.sort(lambda x, y: cmp(x.lower(), y.lower())) for count in range(len(file_names)): file_names[count] = file_names[count].replace('\n', '') (list_names, play_list_name, x, my_string) = command_file_master(screen,\ file_names, "LEFT-CLICK list name to add to list", 25, 0, 1, 0) if (list_names == None): return play_list = gl.DATA_DIR + play_list_name f = open(play_list, 'a') if os.path.isdir(filename): filez = dir_nav.get_imgs(os.getcwd(), 0) filez.sort(lambda x, y: cmp(x.lower(), y.lower())) for file in filez: f.write(file + "\n") else: if os.sep not in filename and filename.startswith("http:") != 1: filename = os.getcwd() + os.sep + filename + "\n" f.write(filename + "\n") f.close() normal_cursor()
def command_img_names(screen, new_img, img, file, rect): num_imgs = len(gl.files) (screen, before_winsize, not_accepted) = adjust_screen(screen) paint_screen(gl.BLACK) normal_cursor() gl.SORT_HIT = 0 (list_names, filename, x, my_string) = command_file_master(screen, gl.files,\ "(%d Images)" % len(gl.files), 15, 0, 1, 0) wait_cursor() screen = restore_screen(screen, before_winsize, not_accepted, new_img, file, rect) if not filename == None: if num_imgs > 1: file = gl.files.index(filename) new_img = load_img(gl.files[file]) rect = get_center(screen, new_img) my_update_screen(new_img, rect, file) normal_cursor() rect = get_center(screen, new_img) my_update_screen(new_img, rect, file) return (new_img, new_img, new_img, file, rect)
def play_list_options(screen, file): normal_cursor() f = open(gl.IMGV_PLAYLISTS) file_names = f.readlines() f.close() file_names.sort(lambda x, y: cmp(x.lower(), y.lower())) gl.SORT_HIT = 1 for count in range(len(file_names)): file_names[count] = file_names[count].replace('\n', '') (list_names, play_list_name, x, my_string) = command_file_master(screen, file_names, "There are %d Play Lists. (LEFT-CLICK list name to use. RIGHT-CLICK to edit. CTRL+LEFT-CLICK to delete)" % len(file_names), 5, 1, 0, 0) wait_cursor() if x == "deleteit": return ("deleteit", play_list_name) if x == "rclicked": return ("rclicked", play_list_name) if my_string != None and my_string != "\n": my_string = str(''.join(my_string)) new_list = gl.DATA_DIR + my_string f = open(gl.IMGV_PLAYLISTS, 'a') new_list_name = os.path.basename(new_list + "\n") if new_list_name != "\n": # no blank lists (user just hit RETURN) f.write(new_list_name) f.close() open(new_list, 'w') return (file, None) if (play_list_name == None): return (file, None) play_list = gl.DATA_DIR + play_list_name try: f = open(play_list) tmp_files = f.readlines() if len(tmp_files) > 0: gl.files = tmp_files for count in range(len(gl.files)): gl.files[count] = gl.files[count].replace('\n', '') f.close() gl.PLAY_LIST_NAME = os.path.basename(play_list) return (0, None) return (file, "\"%s\" is empty or not in %s" % (os.path.basename(play_list), gl.DATA_DIR)) except IOError: return (file, "\"%s\" is empty or not in %s" % (os.path.basename(play_list), gl.DATA_DIR))