Exemplo n.º 1
0
def command_horiz(new_img, screen, file, rect):
    "flip horizontally (mirror)"
    wait_cursor()
    new_img = flip(new_img, 90, 0)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, rect)
Exemplo n.º 2
0
def square_four(screen, file):
    wait_cursor()
    draw_lines(screen)
    num_imgs = len(gl.files)
    if file >= num_imgs or file <= 0:
        file = 0
    img_four_name = gl.files[file]
    img_four_file = file
    img_four = load_img(img_four_name, screen, 0)
    file = file + 1
    img_four = adjust_img_size(img_four, screen.get_width(), screen.get_height())
    img_four_rect = img_four.get_rect()
    img_four_rect[0] = (screen.get_width() / 2)
    img_four_rect[1] = (screen.get_height() / 2)
    screen.blit(img_four, img_four_rect)
    update(img_four_rect)
    draw_lines(screen)
    if gl.FOUR_STATUS_BARS:
        font_size = 9
        font = pygame.font.Font(gl.FONT_NAME, font_size)
        name = os.path.basename(img_four_name)
        name = check_truncate(screen.get_width(), name)
        img_status = "%s [%d/%d]" % (name, img_four_file + 1, num_imgs)
        raise_up = 12
        show_message(screen, img_status, ((screen.get_width() / 2) + (screen.get_width() / 4 - font.size(img_status)[0]/2), screen.get_height() - raise_up), font_size, ("bold"))
    normal_cursor()
    return (file, img_four_rect, img_four_name, img_four_file)
Exemplo n.º 3
0
def save_remote_img(screen, file):
    save_path = gl.DATA_DIR + "downloads" + sep
    filename = gl.files[file]
    paint_screen(screen, gl.BLACK)
    try:
        im = Image.open(gl.REMOTE_IMG_DATA)

        show_message(screen, "Saving: %s" % basename(gl.files[file]), (20, 50), 12, ("bold"))
        show_message(screen, "From: %s" % filename[:filename.rindex('/')] + '/', (20, 70), 12, ("bold"))
        show_message(screen, "To: %s" % save_path, (20, 90), 12, ("bold"))

        im.save(save_path + basename(filename))

        show_message(screen, "Done", (20, 120), 12, ("bold", "underline"))
        show_message(screen, "[Press any key]", "bottom", 15)
        gl.ALREADY_DOWNLOADED = 1
        normal_cursor()
    except:
        return
    
    while 1:
        event = pygame.event.wait()
        check_quit(event)
        #if event.type == KEYDOWN or event.type == MOUSEBUTTONDOWN:
        if event.type == KEYDOWN and event.key not in (K_LALT, K_RALT):
            return
Exemplo n.º 4
0
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()
Exemplo n.º 5
0
def command_vert(new_img, screen, file, rect):
    "flip vertically"
    wait_cursor()
    new_img = flip(new_img, 90, 90)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, rect)
Exemplo n.º 6
0
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
Exemplo n.º 7
0
def get_confirmation(screen, confirm_msg):
    paint_screen(screen, gl.IMGV_COLOR)
    pygame.display.update()
    normal_cursor()
    show_message(screen, confirm_msg, "top", 12, ("bold"))
    yes_rect = imgv_button(screen, " YES ", 0, 30, "midtop")
    no_rect = imgv_button(screen, " NO ", 0, 60, "midtop")
    pygame.event.set_blocked(MOUSEMOTION)
    while 1:
        event = pygame.event.poll()
        pygame.time.wait(1)
        cursor = pygame.mouse.get_pos()
        hover_button(yes_rect, cursor, screen, " YES ", 0, 30, "midtop")
        hover_button(no_rect, cursor, screen, " NO ", 0, 60, "midtop")
        hover_cursor(cursor, (yes_rect, no_rect))
        check_quit(event)
        if hit_key(event, K_ESCAPE):
            return 
        if hit_key(event, K_y):
            return "yes"
        if hit_key(event, K_n):
            return "no"
        if event.type == MOUSEBUTTONDOWN and pygame.mouse.get_pressed()[0]:
            if yes_rect.collidepoint(cursor):
                return "yes"
            if no_rect.collidepoint(cursor):
                return "no"
Exemplo n.º 8
0
Arquivo: thumb.py Projeto: rkulla/imgv
def command_thumbs(screen, new_img, file):
    normal_cursor()
    gl.THUMBING = 1

    screen_width = screen.get_width()
    if gl.THUMB_VAL.upper() == "AUTO" or gl.USING_THUMB_DEFAULT:
        gl.USING_THUMB_DEFAULT = 1
        if screen_width == 640:
            gl.THUMB_VAL = "85x90"
        elif screen_width == 800:
            gl.THUMB_VAL = "108x114"
        elif screen_width == 1024:
            gl.THUMB_VAL = "108x104"
        else:
            gl.THUMB_VAL = "100x100"

    if not gl.TOGGLE_FULLSCREEN_SET:
        screen = set_mode(screen.get_size())  # take away resize priviledges
    paint_screen(gl.IMGV_COLOR)
    set_caption("imgv")
    (new_img, new_img, new_img, file) = thumbs_engine(screen, new_img, file)
    if not gl.TOGGLE_FULLSCREEN_SET:
        screen = set_mode(screen.get_size(), RESIZABLE)  # restore resize priviledges
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    gl.THUMBING = 0
    return (new_img, new_img, new_img, file, rect)
Exemplo n.º 9
0
def show_slideshow_img(screen, new_img, file, num_imgs, speed):
    start = start_timer()
    wait_cursor()
    new_img = next_img(file, new_img, screen)
    rect = get_center(screen, new_img)
    ns = check_timer(start)
    my_update_screen(new_img, screen, rect, file, num_imgs, ns)
    normal_cursor()
    if speed > 0:
        for i in range(speed):
            # trick delay into letting you escape anytime
            event = pygame.event.poll()
            pygame.time.wait(1)
            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))
                return (new_img, file, rect, 1)
            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 hit_key(event, K_SPACE):
                # skip forward an image immediately
                file = file + 1
                return (new_img, file, rect, 0)
            if hit_key(event, K_BACKSPACE):
                # skip backward an image immediately
                file = file - 1
                return (new_img, file, rect, 0)
            pygame.time.delay(1000) # check every second
    file = file + 1
    return (new_img, file, rect, 0)
Exemplo n.º 10
0
def open_url(screen, img):
    gl.ISURL = 1
    num_imgs = len(gl.files)
    paint_screen(screen, gl.BLACK)
    set_caption("Extract from Web - imgv")
    normal_cursor()
    show_message(screen, "Enter a Web URL to extract images from", 20, 15, ("transparent"))
    gl.URL = ask(screen, "http://")
    if gl.URL != None:
        gl.files = []
        wait_cursor()
        show_message(screen, "Loading. Please wait..", 39, 42, ("transparent"))
        for ext in gl.IMG_TYPES:
            if gl.URL.endswith(ext):
                gl.files.append(str("".join(gl.URL)))
                return (load_img(gl.files[0], screen), 1)
    else:
        return (img, num_imgs)
    gl.files = []
    check_indexhtml()
    if gl.URL_ERROR:
        gl.files.append(gl.ERROR_IMG)
        return (load_img(gl.ERROR_IMG, screen), len(gl.files))
    if len(gl.files) < 1:
        gl.files.append(gl.ERROR_IMG)
    gl.files = [x.replace(" ", "%20") for x in gl.files]  # urls need %20 for spaces
    return (load_img(gl.files[0], screen), len(gl.files))
Exemplo n.º 11
0
def command_horiz(new_img, screen, file, num_imgs, rect):
    "flip horizontally (mirror)"
    wait_cursor()
    start = start_timer()
    new_img = flip(new_img, 90, 0)
    my_update_screen(new_img, screen, rect, file, num_imgs, check_timer(start))
    normal_cursor()
    return (new_img, new_img, rect)
Exemplo n.º 12
0
def command_vert(new_img, screen, file, num_imgs, rect):
    "flip vertically"
    wait_cursor()
    start = start_timer()
    new_img = flip(new_img, 90, 90)
    my_update_screen(new_img, screen, rect, file, num_imgs, check_timer(start))
    normal_cursor()
    return (new_img, new_img, rect)
Exemplo n.º 13
0
def command_rotate_left(new_img, screen, file, rect):
    "rotate counter clockwise"
    wait_cursor()
    new_img = rotate(new_img, 90)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, rect)
Exemplo n.º 14
0
def command_rotate_left(new_img, screen, file, num_imgs, rect):
    "rotate counter clockwise"
    wait_cursor()
    start = start_timer()
    new_img = rotate(new_img, 90)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, screen, rect, file, num_imgs, check_timer(start))
    normal_cursor()
    return (new_img, new_img, rect)
Exemplo n.º 15
0
def command_shuffle(new_img, img, screen, rect, file):
    "randomize the images"
    wait_cursor()
    shuffle(gl.files)
    new_img = load_img(gl.files[file])
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, new_img, rect)
Exemplo n.º 16
0
def play_list_options_msg(screen, msg):
    paint_screen(gl.BLACK)
    show_message(msg, 100, 10)
    normal_cursor()
    while 1:
        event = pygame.event.wait()
        check_quit(event)
        if event.type == KEYDOWN or event.type == MOUSEBUTTONDOWN:
            wait_cursor()
            break
Exemplo n.º 17
0
Arquivo: imgv.py Projeto: rkulla/imgv
    def start(self):
        # start with menu open
        self.gfx = command_main_menu(self.gfx)

        # main loop
        while 1:
            self.event = pygame.event.poll()
            pygame.time.wait(1)  # so pygame doesn't use 100% CPU
            cursor = pygame.mouse.get_pos()
            self.last_rect = Rect(self.gfx['rect'])

            # drag image code:
            if gl.HAND_TOOL:
                if left_click(self.event):  # calculate drag coordinates:
                    if gl.IMG_BORDER:
                        self.border_fix()  # erase the current border
                    grab_hand_cursor()
                    self.minus1 = cursor[0] - self.gfx['rect'][0]
                    self.minus2 = cursor[1] - self.gfx['rect'][1]
                    gl.DO_DRAG = 1
                if self.event.type == MOUSEMOTION and gl.DO_DRAG:  # move the image when dragged:
                    grab_hand_cursor()
                    self.gfx['rect'][0] = cursor[0] - self.minus1
                    self.gfx['rect'][1] = cursor[1] - self.minus2
                    self.gfx['screen'].fill(gl.IMGV_COLOR, self.last_rect)
                    self.gfx['screen'].blit(self.gfx['new_img'], self.gfx['rect'])
                    update(self.gfx['rect'].union(self.last_rect))
                if self.event.type == MOUSEBUTTONUP:  # released mouse button, redisplay status bars:
                    drag_hand_cursor()
                    my_update_screen(self.gfx['new_img'], self.gfx['rect'], self.gfx['file'])
                    gl.DO_DRAG = 0

            if self.event.type == VIDEORESIZE:
                self.gfx['screen'] = pygame.display.set_mode(self.event.dict['size'], RESIZABLE)
                self.gfx['rect'] = get_center(self.gfx['screen'], self.gfx['new_img'])
                my_update_screen(self.gfx['new_img'], self.gfx['rect'], self.gfx['file'])
            if self.event.type == KEYDOWN:
                gl.HAND_TOOL = 0
                if self.event.key not in (K_DOWN, K_UP, K_RIGHT, K_LEFT):
                    normal_cursor()  # stop displaying hand tool
                (self.gfx, self.last_rect) = handle_keyboard(self.event, self.gfx, self.last_rect)
            if self.event.type == KEYUP:
                self.stop_auto_repeat()
            check_quit(self.event)

            if self.event.type == MOUSEBUTTONDOWN and right_click(self.event):
                self.open_main_menu()

            # Re-open the purposely closed window that frees up RAM
            if (gl.KEEP_MENU_OPEN == "1" and gl.COUNT_CLICKS == 1) or gl.JUST_RESIZED:
                gl.COUNT_CLICKS = 0
                gl.JUST_RESIZED = 0
                self.gfx = command_main_menu(self.gfx)

            self.start_auto_repeat()
Exemplo n.º 18
0
def command_unshuffle(new_img, img, screen, rect, file):
    "un-randomize the images"
    was_on = gl.files[file]
    wait_cursor()
    gl.files.sort(lambda x, y: cmp(x.lower(), y.lower()))
    file = gl.files.index(was_on)
    new_img = load_img(gl.files[file])
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, new_img, rect, file)
Exemplo n.º 19
0
def command_first_img(new_img, screen, file, num_imgs, rect):
    "jump to the first image"
    wait_cursor()
    start = start_timer()
    file = 0
    new_img = load_img(gl.files[file], screen)
    rect = get_center(screen, new_img)
    ns = check_timer(start)
    my_update_screen(new_img, screen, rect, file, num_imgs, ns)
    normal_cursor()
    return (new_img, new_img, new_img, file, rect)
Exemplo n.º 20
0
def command_shuffle(new_img, img, screen, rect, file, num_imgs):
    "randomize the images"
    wait_cursor()
    start = start_timer()
    shuffle(gl.files)
    new_img = load_img(gl.files[file], screen)
    rect = get_center(screen, new_img)
    ns = check_timer(start)
    my_update_screen(new_img, screen, rect, file, num_imgs, ns)
    normal_cursor()
    return (new_img, new_img, new_img, rect)
Exemplo n.º 21
0
def command_prev_img(new_img, screen, file, num_imgs, rect):
    "jump to previous image"
    wait_cursor()
    start = start_timer()
    if file > 0:
        file = file - 1
        new_img = previous_img(file, new_img, screen)
        rect = get_center(screen, new_img)
        ns = check_timer(start)
        my_update_screen(new_img, screen, rect, file, num_imgs, ns)
    normal_cursor()
    return (new_img, new_img, new_img, file, rect)
Exemplo n.º 22
0
def command_zoom_out(new_img, new_img_width, new_img_height, img, screen, file, num_imgs, rect, zoom_type):
    wait_cursor()
    start = start_timer()
    if new_img.get_width() >= gl.MIN_WIDTH and new_img.get_height() >= gl.MIN_HEIGHT:
        gl.ZOOM_EXP -= 1
        if zoom_type == "normal":
            gl.ZOOM_DOUBLE = 0
            new_img = scale(img, (new_img.get_width() / 1.1, new_img.get_height() / 1.1))
        else:
            gl.ZOOM_DOUBLE = 1
            new_img = scale(img, (new_img.get_width() / 2, new_img.get_height() / 2))
        rect = get_center(screen, new_img)
        my_update_screen(new_img, screen, rect, file, num_imgs, check_timer(start))
    normal_cursor()
    return (new_img, img, rect)
Exemplo n.º 23
0
def command_zoom_in(new_img, new_img_width, new_img_height, img, screen, files, file, num_imgs, rect, zoom_type):
    wait_cursor()
    start = start_timer()
    gl.ZOOM_EXP += 1
    if zoom_type == "normal":
        gl.ZOOM_DOULBE = 0
        new_img = scale(img, (new_img.get_width() * 1.1, new_img.get_height() * 1.1))
    if zoom_type == "double":
        gl.ZOOM_DOUBLE = 1
        new_img = scale(img, (new_img.get_width() * 2, new_img.get_height() * 2))
    if zoom_type == "scale2x":
        gl.ZOOM_DOUBLE = 1
        new_img = scale2x(img) # don't alias simple solid color images (ie., black & white GIFs)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, screen, rect, file, num_imgs, check_timer(start))
    normal_cursor()
    return (new_img, img, rect)
Exemplo n.º 24
0
def command_play_list_options(screen, file):
    paint_screen(gl.BLACK)
    old_file = file
    (file, msg) = play_list_options(screen, file)
    if (msg != None and file != "rclicked" and file != "deleteit"):
        play_list_options_msg(screen, msg)
    if (file == "rclicked"):
        edit_play_list(screen, msg)
        file = old_file
    if (file == "deleteit"):
        delete_play_list(msg)
        file = old_file
    new_img = load_img(gl.files[file])
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, new_img, file, rect)
Exemplo n.º 25
0
Arquivo: zoom.py Projeto: rkulla/imgv
def command_zoom_out(new_img, img, file, rect, zoom_type):
    wait_cursor()
    screen = get_surface()
    new_img_width = new_img.get_width()
    new_img_height = new_img.get_height()
    if new_img_width >= gl.MIN_WIDTH and new_img_height >= gl.MIN_HEIGHT:
        gl.ZOOM_EXP -= 1
        if zoom_type == "normal":
            gl.ZOOM_DOUBLE = 0
            new_img = scale(img, (int(new_img_width / 1.1), int(new_img_height / 1.1)))
        else:
            gl.ZOOM_DOUBLE = 1
            new_img = scale(img, (new_img_width / 2, new_img_height / 2))
        rect = get_center(screen, new_img)
        my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, img, rect)
Exemplo n.º 26
0
def command_remove_img(new_img, screen, file, rect):
    "Don't display the image anymore during the session"
    wait_cursor()
    num_imgs = len(gl.files)
    # only remove file if its not the only one:
    if not num_imgs < 2:
        gl.files.remove(gl.files[file])
        # go to the next image if there is one
        if file < (num_imgs - 1):
            new_img = next_img(file, new_img, screen)
        # if not go to the previous image
        else:
            if file > 0:
                file = file - 1
                new_img = previous_img(file, new_img, screen)
        rect = get_center(screen, new_img)
        my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, new_img, file, rect)
Exemplo n.º 27
0
Arquivo: zoom.py Projeto: rkulla/imgv
def command_zoom_in(new_img, img, file, rect, zoom_type):
    wait_cursor()
    screen = get_surface()
    new_img_width = new_img.get_width()
    new_img_height = new_img.get_height()
    gl.ZOOM_EXP += 1
    if zoom_type == "normal":
        gl.ZOOM_DOULBE = 0
        new_img = scale(img, (int(new_img_width * 1.1), int(new_img_height * 1.1)))
    if zoom_type == "double":
        gl.ZOOM_DOUBLE = 1
        new_img = scale(img, (new_img_width * 2, new_img_height * 2))
    if zoom_type == "scale2x":
        gl.ZOOM_DOUBLE = 1
        new_img = scale2x(img)  # don't alias simple solid color images (ie., black & white GIFs)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, img, rect)
Exemplo n.º 28
0
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)
Exemplo n.º 29
0
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))
Exemplo n.º 30
0
def do_change_dir(screen, file, dirname):
    wait_cursor()
    try:
        change_to = ' '.join(dirname.split(' ')[1:])
        if change_to != os.getcwd(): # don't add numbers more than once
            gl.ADDED_DIR_NUMS = 0
        os.chdir(change_to)
        gl.BEEN_THERE_DONE_THAT = 1

        # adjust the variables for the new dir
        file = adjust_files(0)

        show_dirs(screen, file)

        normal_cursor()
        return file
    except:
        gl.ADDED_DIR_NUMS = 0
        normal_cursor()
        error_screen(screen, "Directory error2. [%s] Permission denied?" % change_to)
        return file