Server IP : 85.214.239.14 / Your IP : 18.217.26.8 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/cwd/proc/2/root/proc/2/cwd/proc/3/root/usr/share/doc/python3-colorama/examples/ |
Upload File : |
#!/usr/bin/python3 # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. # print grid of all colors and brightnesses # uses stdout.write to write chars with no newline nor spaces between them # This should run more-or-less identically on Windows and Unix. from __future__ import print_function import sys # Add parent dir to sys path, so the following 'import colorama' always finds # the local source in preference to any installed version of colorama. import fixpath from colorama import just_fix_windows_console, Fore, Back, Style just_fix_windows_console() # Fore, Back and Style are convenience classes for the constant ANSI strings that set # the foreground, background and style. The don't have any magic of their own. FORES = [ Fore.BLACK, Fore.RED, Fore.GREEN, Fore.YELLOW, Fore.BLUE, Fore.MAGENTA, Fore.CYAN, Fore.WHITE ] BACKS = [ Back.BLACK, Back.RED, Back.GREEN, Back.YELLOW, Back.BLUE, Back.MAGENTA, Back.CYAN, Back.WHITE ] STYLES = [ Style.DIM, Style.NORMAL, Style.BRIGHT ] NAMES = { Fore.BLACK: 'black', Fore.RED: 'red', Fore.GREEN: 'green', Fore.YELLOW: 'yellow', Fore.BLUE: 'blue', Fore.MAGENTA: 'magenta', Fore.CYAN: 'cyan', Fore.WHITE: 'white' , Fore.RESET: 'reset', Back.BLACK: 'black', Back.RED: 'red', Back.GREEN: 'green', Back.YELLOW: 'yellow', Back.BLUE: 'blue', Back.MAGENTA: 'magenta', Back.CYAN: 'cyan', Back.WHITE: 'white', Back.RESET: 'reset' } # show the color names sys.stdout.write(' ') for foreground in FORES: sys.stdout.write('%s%-7s' % (foreground, NAMES[foreground])) print() # make a row for each background color for background in BACKS: sys.stdout.write('%s%-7s%s %s' % (background, NAMES[background], Back.RESET, background)) # make a column for each foreground color for foreground in FORES: sys.stdout.write(foreground) # show dim, normal bright for brightness in STYLES: sys.stdout.write('%sX ' % brightness) sys.stdout.write(Style.RESET_ALL + ' ' + background) print(Style.RESET_ALL) print()