Пример #1
0
 def test_end_flag(self):
     """
     With end-flag, it makes the print normal. Otherwise, it will keep the style that you last used.
     """
     cprint('cp fore.red + bg.blue',
            fore=RGB.RED,
            bg=RGB.BLUE,
            end_flag=False)
     print('fore.red + bg.blue')
     print(Style.NORMAL + 'normal')
Пример #2
0
 def test_combine(self):
     print('cp fore.red abc' + cprint('RED', RGB.RED, pf=False) + '456')
     print('cp fore.white + bg.black abc' +
           cprint('RED', RGB.WHITE, RGB.BLACK, pf=False) + '456')
     print('zp fore.yellow + bg.red ' +
           zprint('RED', Fore.YELLOW, BG.RED, '', False) + '456')
     print('zp style only: italic' +
           zprint('No fore, no bg, and style is ITALIC',
                  style=Style.ITALIC,
                  pf=False) + '  456')
     print('zp style only: italic' +
           zprint('No fore, no bg, and style is ITALIC',
                  style=Style.BOLD + Style.ITALIC,
                  pf=False) + '  456')
Пример #3
0
    def test_print_hot_color(self):
        r, g, b = 0, 0, 0
        row_string = ''
        count = 0
        while 1:
            count += 1
            t_rgb = tuple((r, g, b))
            fore_color = RGB.complementary_color(t_rgb)
            row_string += cprint(f'{RGB.tuple2hex_str(t_rgb)}  ',
                                 fore_color,
                                 t_rgb,
                                 pf=False)

            if count % 5 == 0:
                print(row_string),
                row_string = ''

            r_end_flag = r + 17 > 255
            g_end_flag = g + 17 > 255
            b_end_flag = b + 17 > 255
            r = r if r_end_flag else r + 17
            g = g + 17 if r_end_flag and not g_end_flag else g
            b = b + 17 if g_end_flag and not b_end_flag else b
            if r_end_flag and g_end_flag and b_end_flag:
                # print(row_string)
                break
Пример #4
0
 def test_basic(self):
     cprint('cp fore.red + bg.blue\n123', fore=RGB.RED, bg=RGB.BLUE)
     cprint('cp fore.red\n123', RGB.RED)
     cprint('cp bg.PURPLE\n123', bg=RGB.PURPLE)
     zprint('zp fore.yellow\n123', Fore.YELLOW)
     zprint('zp fore.violet + bg.red\n123', Fore.VIOLET, BG.RED)
     zprint('zp bg.violet\n123', bg=BG.RED)
Пример #5
0
    def test_show_all_color(self):
        from itertools import permutations
        row_string = ''
        for count, rgb in enumerate(
                permutations((_ for _ in range(0, 256, 40)), 3)):
            count += 1
            fore_color = RGB.complementary_color(rgb)
            row_string += cprint(f'{RGB.tuple2hex_str(rgb)}  ',
                                 fore_color,
                                 rgb,
                                 pf=False)

            if count % 7 == 0:
                print(row_string),
                row_string = ''

        print(row_string) if len(row_string) > 0 else None
Пример #6
0
    def test_basic_usage(self):
        print('#only Fore test#')
        cprint('red: RGB.RED', RGB.RED)
        cprint(
            'red: #FF0000', bg='#FF0000'
        )  # It doesn't matter for string upper or lower, and if you don't want to add the sign of #, it's ok too.
        cprint('red: (255, 0, 0)', (255, 0, 0))

        print('#only Background test#')
        cprint('red: RGB.RED', bg=RGB.RED)
        cprint('red: #FF0000', bg='#ff0000')
        cprint('red: (255, 0, 0)', bg=(255, 0, 0))

        print('#fore + bg#')
        cprint('red: RGB.RED, RGB.YELLOW', RGB.RED, RGB.YELLOW)
        cprint('red: FF0000, #FFFF00', 'FF0000', '#FFFF00')
        cprint('red: (255, 0, 0), (255, 255, 0)', (255, 0, 0), (255, 255, 0))

        print('#style test#')
        cprint('Italic', style=Style.ITALIC)
        cprint('Italic and Bold', style=Style.BOLD + Style.ITALIC)
        cprint('Strike', style=Style.STRIKE)
        cprint('URL', style=Style.URL)

        print('#combine normal text#')  # set pf=False
        print(
            f"123 {cprint('Fore=Red, bg=Yellow, Style=Italic and Bold', RGB.RED, RGB.YELLOW, Style.BOLD + Style.ITALIC, False)} 456"
        )
        print(f"123 {cprint('BOLD', style=Style.BOLD, pf=False)} 456")

        print('#keeping the setting#')
        ry_print = create_print(fore='FF0000', bg='#FFFF00')
        inner_ry_text = create_print('FF0000',
                                     '#FFFF00',
                                     Style.BOLD + Style.ITALIC,
                                     pf=False)
        msg = "fore='FF0000', bg='#FFFF00'"
        print(msg)
        ry_print(msg)
        print('...')
        ry_print(msg)

        print(
            f'123 {inner_ry_text("fore=red, bg=yellow, style=bold+italic")} !!!'
        )
Пример #7
0
 def test_style(self):
     zprint('zp fore: yellow\n bg: red, style:bold',
            Fore.YELLOW,
            BG.RED,
            style=Style.BOLD)
     zprint('zp fore: yellow, style:Italic',
            Fore.YELLOW,
            style=Style.ITALIC)
     zprint('zp style url', style=Style.URL)
     zprint('zp style strike', style=Style.STRIKE)
     cprint('cp fore: yellow, style: Italic',
            RGB.YELLOW,
            style=Style.ITALIC)
     cprint('cp style: URL', style=Style.URL)
     cprint('cp, fore: (102, 255, 204), style: Italic ',
            fore=(102, 255, 204),
            style=Style.ITALIC)
     cprint('cp fore: #6666ff, s: Italic',
            fore='#6666ff',
            style=Style.ITALIC)
     cprint('cp fore: #6666ff bg: #66ff33',
            fore='#6666ff',
            bg='#66ff33',
            style=Style.ITALIC)
     cprint('cp style: strike', style=Style.STRIKE)