FRIKIdelTO

colores

Oct 11th, 2021 (edited)
1,732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. """ Muestra todos los códigos ANSI de color posibles en la terminal """
  2.  
  3. # PARA QUE FUNCIONEN LOS COLORES EN EL TERMINAL INCLUÍDO EN WINDOWS
  4. if __import__("platform").system() == "Windows": # si el Sistema Operativo es Windows
  5.     kernel32 = __import__("ctypes").windll.kernel32
  6.     kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
  7.     del kernel32
  8.  
  9. # MUESTRA UNA TABLA DE COLORES EN LA TERMINAL CON SUS CORRESPONDIENTES CÓDIGOS ANSI
  10. for estilo in range(10):
  11.     for color_texto in range(30,38):
  12.         codigo_ansi = ""
  13.         for color_fondo in range(40,48):
  14.             format = ';'.join([str(estilo), str(color_texto), str(color_fondo)])
  15.             codigo_ansi += f"\33[{format}m {format} \33[0m"
  16.         print(codigo_ansi)
  17.     print()
  18.  
Advertisement
Add Comment
Please, Sign In to add comment