Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #-*- coding: utf-8 -*-
- # ANSI ESCAPE CODES
- # são códigos impressos afim de transmitir instruções ao terminal.
- print ''
- print '#' * 80
- print '\t\t\t\tANSI ESCAPE CODES'
- print '#' * 80
- # 8 CORES
- # Os terminais mais básicos possuem um conjunto de 8 cores.
- # que variam de 30m a 37m.
- print '\n1) FOREGROUND COLORS:\n'
- # Black: \u001b[30m
- print u'\u001b[30m\\u001b[30m ou \\033[30m BLACK\u001b[0m'
- # Red: \u001b[31m
- print u'\u001b[31m\\u001b[31m ou \\033[31m RED\u001b[0m'
- # Green: \u001b[32m
- print u'\u001b[32m\\u001b[32m ou \\033[32m GREEN\u001b[0m'
- # Yellow: \u001b[33m
- print u'\u001b[33m\\u001b[33m ou \\033[33m YELLOW\u001b[0m'
- # Blue: \u001b[34m
- print u'\u001b[34m\\u001b[34m ou \\033[34m BLUE\u001b[0m'
- # Magenta \u001b[35m
- print u'\u001b[35m\\u001b[35m ou \\033[35m MAGENTA\u001b[0m'
- # Cyan \u001b[36m
- print u'\u001b[36m\\u001b[36m ou \\033[36m CYAN\u001b[0m'
- # White \u001b[37m
- print u'\u001b[37m\\u001b[37m ou \\033[37m WHITE\u001b[0m'
- # Reset: \u001b[0m
- print u'\u001b[0m\\u001b[0m ou \\033[0m RESET'
- print ''
- # 16 CORES
- # Terminais com um conjunto de 16 cores suportam tons de cores (claros ou escuros).
- # Tom claro - bright
- # Tom escuro - bold
- # Nesse caso o ANSI code é seguido de ;1
- print '\n2) FOREGROUND COLORS WITH SHADES (BRIGHT OR BOLD):\n'
- # Bright Black
- print u'\u001b[30;1m\\u001b[30;1m ou \\033[30;1m BRIGHT BLACK\u001b[0m'
- # Bright Red
- print u'\u001b[31;1m\\u001b[31;1m ou \\033[31;1m BRIGHT RED\u001b[0m'
- # Bright Green
- print u'\u001b[32;1m\\u001b[32;1m ou \\033[32;1m BRIGHT GREEN\u001b[0m'
- # Bright Yellow
- print u'\u001b[33;1m\\u001b[33;1m ou \\033[33;1m BRIGHT YELLOW\u001b[0m'
- # Bright Blue
- print u'\u001b[34;1m\\u001b[34;1m ou \\033[34;1m BRIGHT BLUE\u001b[0m'
- # Bright Magenta
- print u'\u001b[35;1m\\u001b[35;1m ou \\033[35;1m BRIGHT MAGENTA\u001b[0m'
- # Bright Cyan
- print u'\u001b[36;1m\\u001b[36;1m ou \\033[36;1m BRIGHT CYAN\u001b[0m'
- # Bright White
- print u'\u001b[37;1m\\u001b[37;1m ou \\033[37;1m BRIGHT WHITE\u001b[0m'
- # 256 CORES
- # Alguns terminais suportam um conjunto de cores extendido de 256 cores.
- import sys
- for i in range(0, 16):
- for j in range(0, 16):
- code = str(i * 16 + j)
- sys.stdout.write(u'\u001b[38;5;' + code + 'm ' + code.ljust(4))
- print u'\u001b[0m'
- # BACKGROUND COLORS
- # Variam de 40m a 47m
- print ''
- print '3) BACKGROUND COLORS:'
- print ''
- # Background Black
- print u'\u001b[40m\\u001b[40m ou \\033[40m BACKGROUND BLACK\u001b[0m'
- # Background Bright Black
- print u'\u001b[40;1m\\u001b[40;1m ou \\033[40;1m BACKGROUND BRIGHT BLACK\u001b[m'
- # Background Red
- print u'\u001b[41m\\u001b[41m ou \\033[41m BACKGROUND RED\u001b[0m'
- # Background Bright Red
- print u'\u001b[41;1m\\u001b[41;1m ou \\033[41;1m BACKGROUND BRIGHT RED\u001b[0m'
- # Background Green
- print u'\u001b[42m\\u001b[42m ou \\033[42m BACKGROUND GREEN\u001b[0m'
- # Background Bright Green
- print u'\u001b[42;1m\\u001b[42;1m ou \\033[42;1m BACKGROUND BRIGHT GREEN\u001b[0m'
- # Background Yellow
- print u'\u001b[43m\\u001b[43m ou \\033[43m BACKGROUND YELLOW\u001b[0m'
- # Background Bright Yellow
- print u'\u001b[43;1m\\u001b[43;1m ou \\033[43;1m BACKGROUND BRIGHT YELLOW\u001b[0m'
- # Background Blue
- print u'\u001b[44m\\u001b[44m ou \\033[44m BACKGROUND BLUE\u001b[0m'
- # Background Bright Blue
- print u'\u001b[44;1m\\u001b[44;1m ou \\033[44;1m BACKGROUND BRIGHT BLUE\u001b[0m'
- # Background Magenta
- print u'\u001b[45m\\u001b[45m ou \\033[45m BACKGROUND MAGENTA\u001b[0m'
- # Background Bright Magenta
- print u'\u001b[45;1m\\u001b[45;1m ou \\033[45;1m BACKGROUND BRIGHT MAGENTA\u001b[0m'
- # Background Cyan
- print u'\u001b[46m\\u001b[46m ou \\033[46m BACKGROUND CYAN\u001b[0m'
- # Background Bright Cyan
- print u'\u001b[46;1m\\u001b[46;1m ou \\033[46;1m BACKGROUND BRIGHT CYAN\u001b[0m'
- # Background White
- print u'\u001b[47m\\u001b[47m ou \\033[47m BACKGROUND WHITE\u001b[0m'
- # Background Bright White
- print u'\u001b[47;1m\\u001b[47;1m ou \\033[47;1m BACKGROUND BRIGHT WHITE\u001b[0m'
- for i in range(0, 16):
- for j in range(0, 16):
- code = str(i * 16 + j)
- sys.stdout.write(u'\u001b[48;5;' + code + 'm ' + code.ljust(4))
- print u'\u001b[0m'
- print ''
- # DECORAÇÕES
- # Bold \u001b[1m
- # Underline \u001b[4m
- # Reversed \u001b[7m
- print u'\u001b[1m\\001b[1m ou \\033[1m BOLD\u001b[0m'
- print u'\u001b[4m\\001b[4m ou \\033[4m UNDERLINE\u001b[0m'
- print u'\u001b[7m\\001b[7m ou \\033[7m REVERSED\u001b[0m'
- print u'\u001b[1m\u001b[4m\u001b[7mHELLO ANSI ESCAPE CODES!!!\u001b[0m'
- # CURSOR NAVIGATION
- # Up \u001b[{n}A
- # Down \u001b[{n}B
- # Right \u001b[{n}C
- # Left \u001b[{n}D
- # Progress Indicator
- import time
- def loading():
- print 'Loading...'
- for i in range(0, 100):
- time.sleep(0.1)
- sys.stdout.write(u'\u001b[1000D' + str(i + 1) + '%')
- sys.stdout.flush()
- print
- loading()
- def slow_loading():
- print 'Loading...'
- for i in range(0, 100):
- time.sleep(1)
- sys.stdout.write(u'\u001b[1000D')
- sys.stdout.flush()
- time.sleep(1)
- sys.stdout.write(str(i + 1) + '%')
- sys.stdout.flush()
- print
- slow_loading()
- def progressbar():
- print 'Loading...'
- for i in range(0, 100):
- time.sleep(0.1)
- width = (i + 1) / 4
- bar = '[' + '#' * width + ' ' * (25 - width) + ']'
- sys.stdout.write(u'\u001b[1000D' + bar)
- sys.stdout.flush()
- print
- progressbar()
Add Comment
Please, Sign In to add comment