Ejemplo n.º 1
0
def verbose_info(screen, new_img, file, num_imgs):
    # main engine
    wait_cursor()
    paint_screen(screen, gl.BLACK)
    try:
        (uniquecolors_rect, total_colors, row, font, im, verb) = print_verbose_info(screen, new_img, file, num_imgs)
    except:
        print 'print verbose'
        #(uniquecolors_rect, total_colors, row, font, im, verb) = junk_rect()#
       # uniquecolors_rect = junk_rect()#
       # total_colors = ""#
        verb = verbose(screen, file)#
        (uniquecolors_rect, total_colors, row, font, im) = verb.colors()
        #return
    if gl.SHOW_EXIFBUTTON:
        exif_rect = imgv_button(screen, " Exif Data ", 5, gl.ROW_SEP + 435, None)
    (esc_rect, close_font) = close_button(screen)
    normal_cursor()
    transparency = 0
    while 1:
        event = pygame.event.poll()
        pygame.time.wait(1)
        check_quit(event)
        cursor = pygame.mouse.get_pos()
        hover_cursor(cursor, (esc_rect, exif_rect, uniquecolors_rect))
        if gl.SHOW_EXIFBUTTON:
            hover_button(exif_rect, cursor, screen, " Exif Data ", 5, gl.ROW_SEP + 435, None)
        if gl.UNIQUE_COLORS == None and gl.SHOW_EXIFBUTTON and total_colors != "":
            hover_button(uniquecolors_rect, cursor, screen, " Unique colors ", (font.size(total_colors)[0] + 230), row, None)

        show_message(screen, convert_times(ctime(), 0), "bottom", 15, ("transparent"))

        if event.type == MOUSEBUTTONDOWN and pygame.mouse.get_pressed()[0]:
            if uniquecolors_rect != junk_rect():
                if uniquecolors_rect.collidepoint(cursor):
                    wait_cursor()
                    gl.UNIQUE_COLORS = comma_it(len(dict.fromkeys(im.getdata()))) # determine unique colors
                    before_color = gl.MSG_COLOR
                    if gl.MSG_COLOR == gl.SILVER:
                        gl.MSG_COLOR = (142, 142, 142)
                    else:
                        gl.MSG_COLOR = gl.SILVER
                    show_message(screen,  "Unique colors: %s%s" % (gl.UNIQUE_COLORS, ' ' * 12), ((font.size(total_colors)[0] + 235), row), 12, (""), (14, before_color))
                    gl.MSG_COLOR = before_color
                    normal_cursor()
            if exif_rect.collidepoint(cursor):
                wait_cursor()
                try:
                    verb.exif_data(file)
                except:
                    break
                normal_cursor()
            if esc_rect.collidepoint(cursor):
                before_exit()
                break
        if event.type == KEYDOWN and event.key not in (K_LALT, K_RALT, K_LCTRL, K_RCTRL, K_TAB):
            before_exit()
            break
Ejemplo n.º 2
0
def file_master(screen, file_names, place, marker, menu_items, msg, down, button_op):
    paint_screen(gl.BLACK)
    show_message(msg, down, 10, ("bold", "transparent"))
    font = pygame.font.Font(gl.FONT_NAME, 9)
    font.set_bold(1)
    (esc_rect, esc_font) = close_button(screen)
    font_height = font.size(file_names[0])[1]
    screen_height = screen.get_height()
    name_max = 16
    max_file_width = 116
    line = 65 # leave room at top of screen for other stuff
    col = 5
    count = 0
    back_rect = forward_rect = sort_rect = junk_rect()
    for name in file_names[place:]:
        count = count + 1
        place = place + 1
        marker = marker + 1
        if count >= gl.MAX_SCREEN_FILES or place >= len(file_names):
            ren_name = os.path.basename(name)
            if len(ren_name) > name_max:
                ren_name = ren_name[:name_max] + '...' # truncate
                if ren_name[-4:] == '....':
                    ren_name = ren_name[:-1] # 3 .'s are enough
            ren = font.render(ren_name, 1, gl.MSG_COLOR, gl.BLACK)
            if (place + 1) < len(file_names):
                forward_rect = imgv_button(screen, " Next ", 10, 18, "topright")
            if (((place + 1) - gl.MAX_SCREEN_FILES) > 1):
                back_rect = imgv_button(screen, " Previous ", 10, 18, "topleft")
            if not gl.SORT_HIT:
                sort_rect = imgv_button(screen, " Sort ", 13, 42, "midtop")
            ren_rect = ren.get_rect()
            ren_rect[0] = col
            ren_rect[1] = line
            menu_items.append((ren_rect, name))
            screen.blit(ren, ren_rect)
            update(ren_rect)
            return (file_names, menu_items, 1, place, marker, forward_rect, back_rect, sort_rect)
        ren_name = os.path.basename(name)
        if len(ren_name) > name_max:
            ren_name = ren_name[:name_max] + '...'
            if ren_name[-4:] == '....':
                ren_name = ren_name[:-1]
        ren = font.render(ren_name, 1, gl.MSG_COLOR, gl.BLACK)
        ren_rect = ren.get_rect()
        ren_rect[0] = col
        ren_rect[1] = line
        menu_items.append((ren_rect, name))
        screen.blit(ren, ren_rect)
        line = line + 12
        if (line + font_height) >= (screen_height - 15):
            line = 65
            col = col + max_file_width
        update(ren_rect)
    return (file_names, menu_items, 0, place, marker, forward_rect, back_rect, sort_rect)
Ejemplo n.º 3
0
 def colors(self):
     uniquecolors_rect = junk_rect()
     total_colors = ""
     imret = None
     if self.pil_info and self.bitsperpixel not in (None, 32):
         imret = self.im
         if self.bitsperpixel == 24:
             total_colors = "Total colors: 16.7 Million."
         else:
             total_colors = "Total colors: %s." % (2 ** self.bitsperpixel)
         self.print_info(total_colors, 13)
         if gl.UNIQUE_COLORS == None and gl.SHOW_EXIFBUTTON and total_colors != "":
             uniquecolors_rect = imgv_button(self.screen, " Unique colors ", (self.font.size(total_colors)[0] + 230), self.row, None)
     return (uniquecolors_rect, total_colors, self.row, self.font, imret)
Ejemplo n.º 4
0
def command_file_master(screen, file_names, msg, down, button_op, disable_right_click, again):
    set_caption("Image Browser - imgv")
    screen_pause = place = marker = 0
    menu_items = []
    edit_rect = back_rect = forward_rect = sort_rect = junk_rect()
    (esc_rect, font) = close_button(screen)
    create_rect = imgv_button(screen, " Create New List ", 0, 18, "midtop")
    if len(file_names) < 1:
        my_string = ask(screen, "Create playlist first (Enter a name)")
        if my_string == None or my_string == []:
            return ([], [], [], []) # don't create a list
        if my_string != []: # create list
            if (len(my_string) > 0) and my_string != "\n":
                return (file_names, None, None, my_string)
    pygame.event.set_blocked(MOUSEMOTION)
    while 1:
        event = pygame.event.poll()
        pygame.time.wait(1)
        if screen_pause == 1:
            while 1:
                event = pygame.event.poll()
                pygame.time.wait(1)
                cursor = pygame.mouse.get_pos()
                hover_fx(screen, menu_items, cursor)
                hover_cursor(cursor, [esc_rect, edit_rect, sort_rect, back_rect, forward_rect, create_rect] + [x[0] for x in menu_items])
                if button_op:
                    hover_button(create_rect, cursor, screen, " Create New List ", 0, 18, "midtop")
                if (place + 1) < len(file_names):
                    hover_button(forward_rect, cursor, screen, " Next ", 10, 18, "topright")
                if (((place + 1) - gl.MAX_SCREEN_FILES) > 1):
                    hover_button(back_rect, cursor, screen, " Previous ", 10, 18, "topleft")
                if not gl.SORT_HIT:
                    hover_button(sort_rect, cursor, screen, " Sort ", 13, 42, "midtop")
                check_quit(event)
                if hit_key(event, K_ESCAPE):
                    return (None, None, None, None)
                if left_click(event):
                    if esc_rect.collidepoint(cursor):
                        return (None, None, None, None)
                if left_click(event):
                    for item in menu_items:
                        if item[0].collidepoint(cursor):
                            if pygame.mouse.get_pressed()[0] and (pygame.key.get_pressed()[K_LCTRL] or\
                               pygame.key.get_pressed()[K_RCTRL]):
                                return (file_names, item[1], "deleteit", None)
                            if again == "do again":
                                return (file_names, item[1], "do again", None)
                            return (file_names, item[1], menu_items, None)
                if right_click(event):
                    if not disable_right_click:
                        for item in menu_items:
                            if item[0].collidepoint(cursor):
                                if not os.path.isfile(gl.DATA_DIR + item[1]):
                                    if edit_rect != junk_rect():
                                        paint_screen(gl.BLACK)
                                    edit_rect = show_message(
                                    "%s doesn't exist in %s" % (item[1], gl.DATA_DIR), "top", 9, ("bold", "transparent"))
                                else:
                                    return (None, item[1], "rclicked", None)
                if hit_key(event, K_SPACE) or right_click(event):
                    if not place >= len(file_names):
                        screen_pause = 0
                        marker = 0
                        menu_items = []
                        break
                if left_click(event):
                    if forward_rect.collidepoint(cursor):
                        if not place >= len(file_names):
                            screen_pause = 0
                            marker = 0
                            menu_items = []
                            break
                if hit_key(event, K_BACKSPACE) or middle_click(event):
                    if ((place - marker) > 0):
                        paint_screen(gl.BLACK)
                        screen_pause = 0
                        place = place - (gl.MAX_SCREEN_FILES + marker)
                        marker = 0
                        menu_items = []
                        break
                if left_click(event):
                    if back_rect.collidepoint(cursor):
                        if ((place - marker) > 0):
                            paint_screen(gl.BLACK)
                            screen_pause = 0
                            place = place - (gl.MAX_SCREEN_FILES + marker)
                            marker = 0
                            menu_items = []
                            break
                if left_click(event):
                    if sort_rect.collidepoint(cursor):
                        gl.SORT_HIT = 1
                        file_names = basename_sort(file_names)
                        (file_names, menu_items, screen_pause, place, marker, forward_rect, back_rect, sort_rect) = file_master(screen, file_names, place, marker, menu_items, msg, down, button_op)
                        screen_pause = place = marker = 0
                        menu_items = []
                        break
                if left_click(event):
                    if create_rect.collidepoint(cursor):
                        my_string = ask(screen, "Enter name of list")
                        if my_string != None:
                            if (len(my_string) > 0) and my_string != "\n":
                                return (file_names, None, menu_items, my_string)
        (file_names, menu_items, screen_pause, place, marker, forward_rect, back_rect, sort_rect) =\
            file_master(screen, file_names, place, marker, menu_items, msg, down, button_op)
        pygame.time.delay(5)