Server IP : 85.214.239.14 / Your IP : 13.59.69.109 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/task/2/cwd/proc/2/cwd/usr/share/doc/python3-colorama/examples/ |
Upload File : |
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. from __future__ import print_function import fixpath import colorama from colorama import Fore, Back, Style, Cursor from random import randint, choice from string import printable # Demonstrate printing colored, random characters at random positions on the screen # Fore, Back and Style are convenience classes for the constant ANSI strings that set # the foreground, background and style. They 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 ] # This assumes your terminal is 80x24. Ansi minimum coordinate is (1,1). MINY, MAXY = 1, 24 MINX, MAXX = 1, 80 # set of printable ASCII characters, including a space. CHARS = ' ' + printable.strip() PASSES = 1000 def main(): colorama.just_fix_windows_console() pos = lambda y, x: Cursor.POS(x, y) # draw a white border. print(Back.WHITE, end='') print('%s%s' % (pos(MINY, MINX), ' '*MAXX), end='') for y in range(MINY, 1+MAXY): print('%s %s ' % (pos(y, MINX), pos(y, MAXX)), end='') print('%s%s' % (pos(MAXY, MINX), ' '*MAXX), end='') # draw some blinky lights for a while. for i in range(PASSES): print('%s%s%s%s%s' % (pos(randint(1+MINY,MAXY-1), randint(1+MINX,MAXX-1)), choice(FORES), choice(BACKS), choice(STYLES), choice(CHARS)), end='') # put cursor to top, left, and set color to white-on-black with normal brightness. print('%s%s%s%s' % (pos(MINY, MINX), Fore.WHITE, Back.BLACK, Style.NORMAL), end='') if __name__ == '__main__': main()