Пример #1
0
def hover_fx(screen, curdir, x, cursor):
    slash = os.sep
    dash = ' - '
    flag = 0
    for it in x:
        if it[0].collidepoint(cursor):
            flag = 1
            (shortcut, dirname) = it[1].split(gl.DIRNUMSEP)
            if dirname == slash:
                fullpath = curdir.split(slash)[0] + slash
            elif dirname == '..':
                fullpath = slash.join(curdir.rstrip(slash).split(slash)[:-1]) + slash
                if fullpath.split(dash)[0] == slash:
                    # make it so when in root dir of MS-Windows it prints drive letter
                    fullpath = curdir.split(slash)[0] + slash
            else:
                fullpath = curdir + dirname + slash
            gl.OLD_CAP = fullpath + ' [' + shortcut + '] - imgv'
            if gl.OLD_CAP != get_caption()[0]:
                # perform only once (otherwise it flashes in title bar)
                set_caption(gl.OLD_CAP)
            break
    if not flag:
        gl.OLD_CAP = curdir + " - imgv"
        # nothing was hovered on the last pass
        if gl.OLD_CAP != get_caption()[0]:
            set_caption(gl.OLD_CAP)
Пример #2
0
    def test_set_caption(self):
        TEST_CAPTION = "test"
        screen = display.set_mode((100, 100))

        self.assertIsNone(display.set_caption(TEST_CAPTION))
        self.assertEqual(display.get_caption()[0], TEST_CAPTION)
        self.assertEqual(display.get_caption()[1], TEST_CAPTION)
Пример #3
0
 def test_caption_unicode(self):
     TEST_CAPTION = u'台'
     display.set_caption(TEST_CAPTION)
     import sys
     if sys.version_info.major >= 3:
         self.assertEqual(display.get_caption()[0], TEST_CAPTION)
     else:
         self.assertEqual(unicode_(display.get_caption()[0], 'utf8'), TEST_CAPTION)
Пример #4
0
def hover_fx(screen, x, cursor):
    flag = 0
    for it in x:
        if it[0].collidepoint(cursor):
            flag = 1
            gl.OLD_CAP = it[1] + " - imgv"
            if gl.OLD_CAP != get_caption()[0]:
                set_caption(gl.OLD_CAP)
            break
    if not flag:
        gl.OLD_CAP = "Image Browser - imgv"
        if gl.OLD_CAP != get_caption()[0]:
            set_caption(gl.OLD_CAP)
Пример #5
0
def hover_fx(screen, x, cursor, marker):
    flag = 0
    for it in x:
        if it[0].collidepoint(cursor):
            flag = 1
            gl.OLD_CAP = it[1] + " [%d/%d] - imgv" % (gl.files.index(it[1]) + 1, len(gl.files))
            if gl.OLD_CAP != get_caption()[0]:
                set_caption(gl.OLD_CAP)
            break
    if not flag:
        if gl.PAUSED:
            gl.OLD_CAP = "%d Thumbnails [Paused] - imgv" % marker
        else:
            gl.OLD_CAP = "%d Thumbnails - imgv" % marker
        if gl.OLD_CAP != get_caption()[0]:
            set_caption(gl.OLD_CAP)
Пример #6
0
    def test_set_caption(self):

        # __doc__ (as of 2008-08-02) for pygame.display.set_caption:

        # pygame.display.set_caption(title, icontitle=None): return None
        # set the current window caption
        #
        # If the display has a window title, this function will change the
        # name on the window. Some systems support an alternate shorter title
        # to be used for minimized displays.
        #

        TEST_CAPTION = "test"
        screen = display.set_mode((100, 100))
        self.assertIsNone(display.set_caption(TEST_CAPTION))
        self.assertEqual(display.get_caption()[0], TEST_CAPTION)
        self.assertEqual(display.get_caption()[1], TEST_CAPTION)
Пример #7
0
def setWindowCaption(prefix):
    caption = display.get_caption()[0]

    class ctx:
        def __enter__(self):
            display.set_caption(prefix + caption)
        def __exit__(self, *args):
            display.set_caption(caption)
    return ctx()
Пример #8
0
def setWindowCaption(prefix):
    caption = display.get_caption()[0]

    class ctx:
        def __enter__(self):
            display.set_caption(prefix + caption)

        def __exit__(self, *args):
            display.set_caption(caption)

    return ctx()
Пример #9
0
def hover_fx(screen, img_one_name, img_two_name, img_three_name, img_four_name, img_one_rect, img_two_rect, img_three_rect, img_four_rect, cursor):
    dash = ' - '
    if img_one_rect.collidepoint(cursor):
        gl.OLD_CAP = img_one_name + " - imgv"
        if gl.OLD_CAP != get_caption()[0]:
            set_caption(gl.OLD_CAP)
    elif img_two_rect.collidepoint(cursor):
        gl.OLD_CAP = img_two_name + " - imgv"
        if gl.OLD_CAP != get_caption()[0]:
            set_caption(gl.OLD_CAP)
    elif img_three_rect.collidepoint(cursor):
        gl.OLD_CAP = img_three_name + " - imgv"
        if gl.OLD_CAP != get_caption()[0]:
            set_caption(gl.OLD_CAP)
    elif img_four_rect.collidepoint(cursor):
        gl.OLD_CAP = img_four_name + " - imgv"
        if gl.OLD_CAP != get_caption()[0]:
            set_caption(gl.OLD_CAP)
    else:
        gl.OLD_CAP = "Four at a time - imgv"
        if gl.OLD_CAP != get_caption()[0]:
            set_caption(gl.OLD_CAP)
def setWindowCaption(prefix):
    caption = display.get_caption()[0]
    prefix = _(prefix)
    if type(prefix) == unicode:
        prefix = prefix.encode("utf8")
    class ctx:
        def __enter__(self):
            display.set_caption(prefix + caption)

        def __exit__(self, *args):
            display.set_caption(caption)

    return ctx()
Пример #11
0
def setWindowCaption(prefix):
    caption = display.get_caption()[0]
    prefix = _(prefix)
    if type(prefix) == unicode:
        prefix = prefix.encode("utf8")
    class ctx:
        def __enter__(self):
            display.set_caption(prefix + caption)

        def __exit__(self, *args):
            display.set_caption(caption)

    return ctx()
Пример #12
0
    def test_get_caption(self):

        # __doc__ (as of 2008-08-02) for pygame.display.get_caption:

        # pygame.display.get_caption(): return (title, icontitle)
        # get the current window caption
        #
        # Returns the title and icontitle for the display Surface. These will
        # often be the same value.
        #

        screen = display.set_mode((100, 100))
        self.assertEqual(display.get_caption()[0], self.default_caption)
Пример #13
0
 def caption(self):
     return _pd.get_caption()[0]
Пример #14
0
    def test_get_caption(self):
        screen = display.set_mode((100, 100))

        self.assertEqual(display.get_caption()[0], self.default_caption)
Пример #15
0
 def test_caption_unicode(self):
     TEST_CAPTION = "台"
     display.set_caption(TEST_CAPTION)
     self.assertEqual(display.get_caption()[0], TEST_CAPTION)
Пример #16
0
    def caption(self): return _pd.get_caption()

    @caption.setter
Пример #17
0
def img_info(screen, filename, file, num_imgs, new_img, ns):
    if screen.get_width() < 800:
        font_size = 9
    else:
        font_size = 10
    font = pygame.font.Font(gl.FONT_NAME, font_size)

    # set the main caption:
    if filename == gl.IMGV_LOGO:
        set_caption("[No images in %s] - %s" % (getcwd(), gl.TITLE))
    else:
        set_caption("%s%s %s%s- %s" % (('', '+')[new_img.get_width() > screen.get_width() or new_img.get_height() > screen.get_height()], filename.capitalize(), ('', '[Fit Image] ')[gl.FIT_IMAGE_VAL and not gl.RESET_FIT], ('', '[Lock Zoom] ')[gl.PERSISTENT_ZOOM_VAL], gl.TITLE))

    bitsperpixelmsg = ""
    try:
        im = Image.open(filename)
        if im.mode == "RGB" or im.mode == "YCbCr":
            bitsperpixel = 24
            bitsperpixelmsg = "x24 BPP"
        elif im.mode == "P" or im.mode == "L":
            bitsperpixel = 8
            bitsperpixelmsg = "x8 BPP"
        elif im.mode ==  1:
            bitsperpixel = 1
            bitsperpixelmsg = "x1 BPP"
        elif im.mode == "RGBA" or im.mode == "CMYK" or im.mode == "I" or im.mode == "F":
            bitsperpixel = 32
            bitsperpixelmsg = "x32 BPP"
    except:
        pass

    file_mtime = ctime(stat(filename)[ST_MTIME]).split()
    file_mtime = "%s/%s/%s / %s" % (gl.MONTH_MAP[file_mtime[1]], file_mtime[2], file_mtime[-1], file_mtime[3])

    full_filename = filename
    if gl.TOGGLE_STATUS_BAR and gl.files != [gl.IMGV_LOGO]:
        # display info about the current image
        current_img = str(file + 1)
        (img_width, img_height) = new_img.get_size()
        if gl.REMOTE:
            fsize = gl.REMOTE_FILE_SIZE
            filename = gl.REMOTE_IMG
            filename = basename(filename)
        else:
            fsize = getsize(filename)
            filename = basename(filename)
        
        if fsize <= 1024:
            file_size = "%d b" % fsize
        elif fsize >= 1024 and fsize <= (1024 * 1024):
            file_size = "%.2f KB" % (fsize / 1024.0)
        elif fsize >= 1024 and fsize <= (1024 * 1024 * 1024):
            file_size = "%.2f MB" % (fsize / (1024.0 * 1024.0))
        else:
            file_size = "0 bytes"     

        memsizemsg = "?"
        try:
            # display memory size of image
            curmembytesize = ((img_width * img_height) * bitsperpixel) / 8
            if curmembytesize <= 1024:
                memsizemsg = "%d b" % curmembytesize
            elif curmembytesize >= 1024 and curmembytesize <= (1024 * 1024):
                memsizemsg = "%.2f KB" % (curmembytesize / 1024.0)
            elif curmembytesize >= 1024 and curmembytesize <= (1024 * 1024 * 1024):
                memsizemsg = "%.2f MB" % (curmembytesize / (1024.0 * 1024.0))
        except:
            pass
    
        if gl.PLAY_LIST_NAME != " ":
            set_caption("%s [%s] - imgv" % (get_caption()[0].replace(' - imgv', ''), gl.PLAY_LIST_NAME))
        if gl.SLIDE_SHOW_RUNNING == 1:
            set_caption("Slideshow - %s" % get_caption()[0])

        if gl.CALC_ZOOM:
            zoom_percent = (float(img_width) / float(gl.REAL_WIDTH)) * 100
            zoom_percent = int(round(zoom_percent, -1))
            gl.CURRENT_ZOOM_PERCENT = zoom_percent
        else:
            zoom_percent = gl.CURRENT_ZOOM_PERCENT
        gl.CALC_ZOOM = 1

        msmsg = calc_ms(str(ns))
        if msmsg == "":
            msmsg = "0"
        gl.N_MILLISECONDS = msmsg

        if zoom_percent == 100:
            img_status = " %s  [%s/%s]  %sx%s%s  %d%%  %.1fs  -  %s / %s, %s" % (filename, current_img, str(num_imgs), img_width, img_height, bitsperpixelmsg, zoom_percent, ns, str(file_size), memsizemsg, file_mtime)
        else:
            img_status = " %s  [%s/%s]  %sx%s%s  %d%%  [Zoom: %sx%s]  %.1fs  -  %s / %s, %s" % (filename, current_img, str(num_imgs), gl.REAL_WIDTH, gl.REAL_HEIGHT, bitsperpixelmsg, zoom_percent, img_width, img_height, ns, str(file_size), memsizemsg, file_mtime)

        filename = check_truncate(screen.get_width(), filename, font.size('  '.join(img_status.split()[1:]))[0])
        if zoom_percent == 100:
            img_status = " %s  [%s/%s]  %sx%s%s  %d%%  %.1fs  -  %s / %s, %s" % (filename, current_img, str(num_imgs), img_width, img_height, bitsperpixelmsg, zoom_percent, ns, str(file_size), memsizemsg, file_mtime)
        else:
            img_status = " %s  [%s/%s]  %sx%s%s  %d%%  [Zoom: %sx%s]  %.1fs  -  %s / %s, %s" % (filename, current_img, str(num_imgs), gl.REAL_WIDTH, gl.REAL_HEIGHT, bitsperpixelmsg, zoom_percent, img_width, img_height, ns, str(file_size), memsizemsg, file_mtime)

        if not gl.TOGGLE_TRANSPARENT:
            # draw transparent 'tinted' bar to be the background for the image status message to appear on
            transren = pygame.Surface((screen.get_width(), 13)).convert_alpha()
            transren.fill([gl.BLACK[0], gl.BLACK[1], gl.BLACK[2], 60]) # RGBA (A=Alpha)
            transrect = transren.get_rect()
            transrect.midbottom = screen.get_rect().midbottom
            screen.blit(transren, transrect)
            update(transrect)

        # write the image status message:
        show_message(screen, img_status, "bottom", font_size)

    try:
        if gl.ON_FLY_EXIF_STATUS_BAR:
            exif_data(screen, full_filename)
    except:
        print "Can't display exif"
Пример #18
0
def img_info(filename, file, new_img):
    screen = get_surface()
    num_imgs = len(gl.files)
    if screen.get_width() < 800:
        font_size = 9
    else:
        font_size = 10
    font = pygame.font.Font(gl.FONT_NAME, font_size)

    # set the main caption:
    if filename == gl.IMGV_LOGO:
        set_caption("[No images in %s] - %s" % (getcwd(), gl.TITLE))
    else:
        set_caption(
            "%s%s %s%s- %s"
            % (
                ("", "+")[new_img.get_width() > screen.get_width() or new_img.get_height() > screen.get_height()],
                filename.capitalize(),
                ("", "[Fit Image] ")[gl.FIT_IMAGE_VAL and not gl.RESET_FIT],
                ("", "[Lock Zoom] ")[gl.PERSISTENT_ZOOM_VAL],
                gl.TITLE,
            )
        )

    bitsperpixelmsg = ""
    try:
        im = Image.open(filename)
        if im.mode == "RGB" or im.mode == "YCbCr":
            bitsperpixelmsg = "x24 BPP"
        elif im.mode == "P" or im.mode == "L":
            bitsperpixelmsg = "x8 BPP"
        elif im.mode == 1:
            bitsperpixelmsg = "x1 BPP"
        elif im.mode == "RGBA" or im.mode == "CMYK" or im.mode == "I" or im.mode == "F":
            bitsperpixelmsg = "x32 BPP"
    except:
        pass

    file_mtime = ctime(stat(filename)[ST_MTIME]).split()
    file_mtime = "%s/%s/%s / %s" % (gl.MONTH_MAP[file_mtime[1]], file_mtime[2], file_mtime[-1], file_mtime[3])

    full_filename = filename
    if gl.TOGGLE_STATUS_BAR and gl.files != [gl.IMGV_LOGO]:
        # display info about the current image
        current_img = str(file + 1)
        (img_width, img_height) = new_img.get_size()
        if gl.REMOTE:
            fsize = gl.REMOTE_FILE_SIZE
            filename = gl.REMOTE_IMG
            filename = basename(filename)
        else:
            fsize = getsize(filename)
            filename = basename(filename)

        if fsize <= 1024:
            file_size = "%d b" % fsize
        elif fsize >= 1024 and fsize <= (1024 * 1024):
            file_size = "%.2f KB" % (fsize / 1024.0)
        elif fsize >= 1024 and fsize <= (1024 * 1024 * 1024):
            file_size = "%.2f MB" % (fsize / (1024.0 * 1024.0))
        else:
            file_size = "0 bytes"

        if gl.PLAY_LIST_NAME != " ":
            set_caption("%s [%s] - imgv" % (get_caption()[0].replace(" - imgv", ""), gl.PLAY_LIST_NAME))
        if gl.SLIDE_SHOW_RUNNING == 1:
            set_caption("Slideshow - %s" % get_caption()[0])

        if gl.CALC_ZOOM:
            zoom_percent = (float(img_width) / float(gl.REAL_WIDTH)) * 100
            zoom_percent = int(round(zoom_percent, -1))
            gl.CURRENT_ZOOM_PERCENT = zoom_percent
        else:
            zoom_percent = gl.CURRENT_ZOOM_PERCENT
        gl.CALC_ZOOM = 1

        stats = {
            "file": filename,
            "curr": current_img,
            "num_imgs": str(num_imgs),
            "w": img_width,
            "h": img_height,
            "bpp": bitsperpixelmsg,
            "zoom": zoom_percent,
            "size": str(file_size),
            "date": file_mtime,
        }

        stats_zoom = {
            "file": filename,
            "curr": current_img,
            "num_imgs": str(num_imgs),
            "w": gl.REAL_WIDTH,
            "h": gl.REAL_HEIGHT,
            "bpp": bitsperpixelmsg,
            "zoom": zoom_percent,
            "zoom_w": img_width,
            "zoom_h": img_height,
            "size": str(file_size),
            "date": file_mtime,
        }

        if zoom_percent == 100:
            img_stats_msg = build_stats_msg(stats)
        else:
            img_stats_msg = build_stats_msg_zoom(stats_zoom)

        filename = check_truncate(screen.get_width(), filename, font.size("  ".join(img_stats_msg.split()[1:]))[0])

        if zoom_percent == 100:
            img_stats_msg = build_stats_msg(stats)
        else:
            img_stats_msg = build_stats_msg_zoom(stats_zoom)

        if not gl.TOGGLE_TRANSPARENT:
            # draw transparent 'tinted' bar to be the background for the image status message to appear on
            transren = pygame.Surface((screen.get_width(), 13)).convert_alpha()
            transren.fill([gl.BLACK[0], gl.BLACK[1], gl.BLACK[2], 60])  # RGBA (A=Alpha)
            transrect = transren.get_rect()
            transrect.midbottom = screen.get_rect().midbottom
            screen.blit(transren, transrect)
            update(transrect)

        # write the image status message:
        show_message(img_stats_msg, "bottom", font_size)

    try:
        if gl.ON_FLY_EXIF_STATUS_BAR:
            exif_data(screen, full_filename)
    except:
        print "Can't display exif"