示例#1
0
def SISTEMA_INTERFAZ():
  print(Style.BRIGHT + Fore.RED + Back.BLACK)
  print("Obteniendo...")
  for arch in ["SO","Kernel","Procesador","Arquitectura"]: #pequeño truco para que se vea como más coqueto el programa
    numero = random.randrange(1,2)
    sleep(numero-.5)
    print(Cursor.UP(1)+Cursor.FORWARD(20) +str(arch))
示例#2
0
def MEMORIA_INTERFAZ():
  print(Style.BRIGHT + Fore.BLUE + Back.WHITE)
  print("Obteniendo...")
  for arch in ["cat", "proc", "meminfo"]:
    numero = random.randrange(1,2)
    sleep(numero-.5)
    print(Cursor.UP(1)+Cursor.FORWARD(20) +str(arch))
示例#3
0
 def __printInfo(self, flag, listProcess):
     os.system("cls")
     process = None
     if listProcess.numberProcess() > 0:
         process = listProcess.getAcualProcess()
     numberBatch = self.__listBatch.numberBatch()
     if numberBatch == 0:
         numberBatch = 1
     listProcess.printListProcessToExecute(1, 2, numberBatch - 1)
     print("\n")
     self.__listProcessFinish.printListCompleteOfProcess(80, 9)
     print("\n")
     print(Fore.RESET)
     print(Fore.LIGHTCYAN_EX + Cursor.FORWARD(46) +
           Cursor.UP(self.__cursorY) + "proceso en ejecucion",
           end="\n")
     print(Fore.RESET)
     if flag:
         self.__printProcessActual(process)
         self.__flagToContinuePrintProcess = True
         self.__statusOfInterruptionOutside(listProcess, process)
     else:
         self.__printProcessActual(process)
     print("\n\n\n\n")
     if not flag:
         self.__listProcessFinish.numberProcessComplete()
示例#4
0
def printNewPhrase(phrase, shift=0):
    os.system('cls')
    printInfo()
    print("\n[S] Salir")
    print("\nSu frase:", phrase)

    dir = ""
    newPhrase = getPhrase(phrase)
    while (dir != 115) & (dir != 83):
        contP = 0
        contT = 0
        for i in range(len(phrase)):
            color = randColor()
            cont = 0
            for j in newPhrase[i]:
                if (contP >= 120):
                    contP = 0
                    contT = 6
                cont += 1
                if (contP == shift):
                    print(Cursor.POS(2 + contP, 10 + cont + contT) + color + j,
                          end="")
                else:
                    print(Cursor.POS(2 + contP, 10 + cont + contT) + j, end="")
            contP += 8
        change_color(phrase, shift)
示例#5
0
 def gato(posicion_x, posicion_y, colorear):
     if colorear == True:  #valida que la letra sea la seleccionada
         print(
             Cursor.POS(posicion_x, posicion_y) + Back.WHITE + Fore.WHITE +
             "#")
     else:
         print(Cursor.POS(posicion_x, posicion_y) + "#")
def mostrar_colores(errorcatch, nombre_copia):#muestra el contenido del archivo en colores,tiene
    #un limite de archivos de hasta 39 lineas
    dibujoej(errorcatch,2);
    archivo = open(nombre_copia,mode = "r",encoding="utf-8");
    abajo = 5;#que tan abajo se imprimira
    derecha = 6;#que tan a la derecha se imprimira
    mover_derecha = False;#indicara si debe de mover la columna a la derecha
    while True:#recorremos por lineas el archivo
        linea = archivo.readline();
        if not linea:#si ya no hay lineas se acaba
            break;
        else:
            palabras = linea.split();#dividimos la linea en palabras
        
        if abajo <= 27 and mover_derecha == False:#si la impresion no ha llegado hasta el fondo
            print(Cursor.POS(derecha,abajo)+"",end="");#posicionamos el donde empezara a imprimir las palabras
            for palabra in palabras:#recorremos la linea
                codigo_color = "\033["+str(randint(31,37))+"m";#generamos un codigo de color aleatorio para cada palabra
                print(Back.BLACK+codigo_color+palabra,end=" ");#imprimimos cada palabra en la misma linea
        elif abajo == 28:#si llego hasta el fondo, mueve el donde empezara a imprimir
            abajo = 5;
            derecha = 50;
            mover_derecha = True;

        if abajo <= 20 and mover_derecha == True:#si la impresion no ha llegado hasta el cuadro de errores
            print(Cursor.POS(derecha,abajo)+"",end="");#posicionamos el donde empezara a imprimir las palabras
            for palabra in palabras:#recorremos la linea
                codigo_color = "\033["+str(randint(31,37))+"m";#generamos un codigo de color aleatorio para cada palabra
                print(Back.BLACK+codigo_color+palabra,end=" ");#imprimimos cada palabra en la misma linea
        
        abajo += 1;#indicamos que baje a la siguientes linea
def mostrar_colores_Ejercicio3(errorcatch, diccionario_repeticiones):#muestra las expresiones con sus repeticiones en colores,tiene
    #un limite de archivos de hasta 39 lineas
    dibujoej(errorcatch,3);
    abajo = 5;#que tan abajo se imprimira
    derecha = 6;#que tan a la derecha se imprimira
    mover_derecha = False;#indicara si debe de mover la columna a la derecha
    for llave in diccionario_repeticiones:#recorremos el diccionario
        if abajo <= 27 and mover_derecha == False:#si la impresion no ha llegado hasta el fondo
            print(Cursor.POS(derecha,abajo)+"",end="");#posicionamos el donde empezara a imprimir las palabras
            codigo_color = "\033["+str(randint(31,37))+"m";#generamos un codigo de color aleatorio para cada palabra
            print(Back.BLACK+codigo_color+llave,end="");#imprimimos la expresion
            abajo += 1;#indicamos que la impresion sera abajo de la expresion
            print(Cursor.POS(derecha,abajo)+"",end="");#posicionamos el donde empezara a imprimir las palabras
            numero_repeticiones = diccionario_repeticiones[llave];#le asignamos el valor del diccionario a un string porque no 
            #podemos concatenar directamente
            numero_repeticiones_str = str(numero_repeticiones[0]);
            print("N. repeticiones:"+numero_repeticiones_str,end="");#imprimimos el numero de repeticiones
        elif abajo == 28:#si llego hasta el fondo, mueve el donde empezara a imprimir
            abajo = 5;
            derecha = 50;
            mover_derecha = True;

        if abajo <= 20 and mover_derecha == True:#si la impresion no ha llegado hasta el cuadro de errores
            print(Cursor.POS(derecha,abajo)+"",end="");#posicionamos el donde empezara a imprimir las palabras
            codigo_color = "\033["+str(randint(31,37))+"m";#generamos un codigo de color aleatorio para cada palabra
            print(Back.BLACK+codigo_color+llave,end="");#imprimimos la expresion
            abajo += 1;#indicamos que la impresion sera abajo de la expresion
            print(Cursor.POS(derecha,abajo)+"",end="");#posicionamos el donde empezara a imprimir las palabras
            numero_repeticiones = diccionario_repeticiones[llave];#le asignamos el valor del diccionario a un string porque no 
            #podemos concatenar directamente
            numero_repeticiones_str = str(numero_repeticiones[0]);
            print("N. repeticiones:"+numero_repeticiones_str,end="");#imprimimos el numero de repeticiones
        
        abajo += 1;#indicamos que baje a la siguientes linea
def present_dice(player, current_roll : list, roll_num : int, reroll_list : list, show_animation : bool):
    roll = current_roll.copy()
    cursor.set_cursor_visible(False)
    if roll_num == 1:
        x_centering = 31
        y_drop = 7
        if show_animation:
            setup_dice_numbers(0.15)
        else:
            setup_dice_numbers(0)
        setup_dice()
        print(color_lib[3] + Style.BRIGHT + Cursor.POS(x_centering,y_drop) + (player.get_name() + ":  Roll #1").center(centering))
    else:
        x_centering = 31
        y_drop = 7
        setup_dice_numbers(0)
        if roll_num == 2:
            print(color_lib[2] + Style.BRIGHT + Cursor.POS(x_centering,y_drop) + (player.get_name() + ":  Roll #2").center(centering))
        else:
            print(color_lib[1] + Style.BRIGHT + Cursor.POS(x_centering,y_drop) + (player.get_name() + ":  Roll #3").center(centering))
    if show_animation:
        rolling_animation(roll, reroll_list)
    if show_animation:
        show_roll(roll, 0.025)
    else:
        show_roll(roll,0)
    if show_animation and yahtzee_score(player) > 0 and yahtzee_test(roll) == 1:
        excited()
        setup_dice_numbers(0)
        show_roll(roll,0)
    player.display_score()
    cursor.set_cursor_visible(True)
示例#9
0
    def render(self, offset = 0):

        # Border
        cprint("%s%s" % ((Cursor.UP(self.heightwb - offset) if offset <= self.heightwb else ''), '*' + '-' * (self.width + 2) + '*'), *self.borderstyle)
        for i in range(self.height):
            cprint("| %s |" % (' ' * self.width), *self.borderstyle)
        cprint("%s" % ('*' + '-' * (self.width + 2) + '*'), *self.borderstyle)

        print("%s" % Cursor.UP(self.heightwb), end = '')

        # CLI Name
        print("%s" % Cursor.FORWARD(3), end = '')
        print(self.title)

        # for l in range(self.height):
        #     print("%s" % Cursor.FORWARD(), end = '')
        #     print("%d" % self.cnt)
        for line in self.components:
            print("%s" % Cursor.FORWARD(2), end = '')
            for comp in line:
                print(comp, end = '')
            print('')

        # Footer
        print("%s" % Cursor.FORWARD(30), end = '')
        print(self.footer)
示例#10
0
def menu():
    errorcatch=0; #Inicializa la variables de errores except
    opcion=1;
    while opcion != 0: #Mientras la opcion no sea 0 para salir, seguira en el menu
        dibujo(errorcatch);
        print(Fore.BLACK+Cursor.POS(3,4)+Back.WHITE+Style.DIM+"Ingrese el numero de ejercicio a ejecutar o 0 para salir: ", end="");
        opcion=str(input(Fore.BLACK+Back.WHITE));
        print("",end="");
        try:
            opcion=int(opcion);
            if opcion < 0 or opcion > 4: #Si esta fuera de rango
                dibujo(errorcatch);
                print(Fore.BLACK+Cursor.POS(3,4)+Back.WHITE+Cursor.POS(3,4)+"Ingresa un numero valido!",end ="");
                sleep(1);   
            
            else: #En otro caso realizara la opcion pedida
                if opcion == 1:
                    errorcatch=e1(errorcatch);
                   
                if opcion == 2:
                    errorcatch=e2(errorcatch);
                    
                if opcion == 3:
                    errorcatch=e3(errorcatch);
                    
                if opcion == 4:
                    errorcatch=e4(errorcatch);
                   
                
        except: #Si ingresa caracteres
            errorcatch+=1;
            dibujo(errorcatch);
            print(Fore.BLACK+Cursor.POS(3,4)+Back.WHITE+Cursor.POS(3,4)+"ERROR! Ingrese un numero entero!", end="");
            sleep(1);
示例#11
0
def ayuda():
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(5) + Back.BLUE + Fore.WHITE +
        "==================== AYUDA ===============\n\n" + Fore.WHITE)
    print(" lista => lista todos los archivos existentes")
    print(Cursor.FORWARD(5) + "Ejemplo: ~ $$lista ")
    print(" agrega => Agrega una cadena a un archivo")
    print(Cursor.FORWARD(5) + "Ejemplo: ~ $$agrega mi_archivo.txt 'Mi nombre'")
    print(
        Cursor.FORWARD(5) +
        "La cadena debe ir entre comillas simples si contiene algun espacio")
    print(" nuevo => Crea un archivo")
    print(Cursor.FORWARD(5) + "Ejemplo: ~ $$nuevo mi_archivo.txt 'Mi nombre'")
    print(
        Cursor.FORWARD(5) +
        "La cadena debe ir entre comillas simples si contiene algun espacio")
    print(" borra => Borra un archivo")
    print(Cursor.FORWARD(5) + "Ejemplo: ~ $$borra mi_archivo.txt")
    print(" ver => Muestra el contenido de un archivo")
    print(Cursor.FORWARD(5) + "Ejemplo: ~ $$ver mi_archivo.txt")
    print(
        Cursor.FORWARD(5) +
        "\nPara seleccionar una opción teclea el número correspondiente y presiona la tecla enter ;) "
    )
    espera = input("\npresiona enter para volver al menu... ")
    print(Style.RESET_ALL)
示例#12
0
def e4(errorcatch):
    errorcatch = repetidos(errorcatch)
    print(Fore.BLACK + Back.LIGHTMAGENTA_EX + Cursor.POS(3, 8) + "Ejercicio 4",
          end="")
    input(Fore.BLACK + Cursor.POS(3, 9) + Back.WHITE + "")
    print("", end="")
    return errorcatch
示例#13
0
def e3(_m, _n, _w):  #Cadena mas corta para cada caracter
    try:
        import time
        from colorama import Cursor, init, Fore, Back, Style
        init(autoreset=True)
        ven(100, 12)
        q = 0
        dic = {}
        print(
            Cursor.POS(2, 3) + Back.WHITE + Fore.BLUE + Style.BRIGHT +
            ("Igrese su cadena: "))
        a = input()
        print(
            Cursor.POS(2, 4) + Back.WHITE + (" ") * 98,
            Cursor.POS(1, 4) + Back.MAGENTA + (" "))
        a = a.split(" ")
        cad = sorted(a, key=len, reverse=True)
        for x in range(len(cad)):
            for i in (cad[x]):
                dic[i] = cad[x]
        print(
            Cursor.POS(2, 6) + Back.WHITE + Fore.BLUE + Style.BRIGHT +
            (f"Las cadenas mas chicas son {dic}"))
        time.sleep(25)
        print("\033[2J\033[1;1F")
        return menu(q, _n, _m, _w)

    except:
        q += 1
        print("Valor no valido")
        print("\033[2J\033[1;1F")
        return menu(q, _n, _m, _w)
    input()
示例#14
0
def e1(errorcatch):
    errorcatch = estacionamiento(errorcatch)
    print(Fore.BLACK + Back.LIGHTMAGENTA_EX + Cursor.POS(3, 6) + "Ejercicio 1",
          end="")
    input(Fore.BLACK + Cursor.POS(3, 7) + Back.WHITE + "")
    print("", end="")
    return errorcatch
def buscar_archivo(errorcatch):  #busca un archivo
    dibujoej(errorcatch, 2)
    print(Fore.WHITE + Style.BRIGHT + Cursor.POS(6, 6) +
          "Ingresa el nombre del archivo: ",
          end="")
    nombre = str(input())
    if len(nombre) > 0:  #si ingreso algo
        try:  #tratar de abrir archivo
            archivo = open(nombre, mode="r", encoding="utf-8")
            repeticiones = buscar_repeticiones(
                errorcatch, nombre
            )  #si existe, contar el numero de archivos con el mismo nombre antes de ()
            copia_creada = crea_copia(
                errorcatch, nombre, repeticiones
            )  #crear un nuevo archivo con mismo nombre terminacion (n)
            da_formato(errorcatch, copia_creada, repeticiones)
            #copiar el contenido del archivo (n-1), alternando las palabras en mayuscula y minuscula y cambiandolas de color
            mostrar_colores(errorcatch, copia_creada)
            #mostrar el contenido del archivo con colores
            input()
        except:  #si no existe, avisar y permitir ingresar un nombre que exista
            errorcatch += 1
            dibujoej(errorcatch, 2)
            print(Fore.WHITE + Style.BRIGHT + Cursor.POS(6, 6) +
                  "El archivo no existe",
                  end="")
            sleep(1)
    if len(nombre) == 0:  #si no ingreso nada
        dibujoej(errorcatch, 2)
        print(Fore.WHITE + Style.BRIGHT + Cursor.POS(6, 6) +
              "Debe ingresar un nombre de archivo",
              end="")
        sleep(1)
    return errorcatch
def printNewPhrase(phrase, shift=0):#funcion que imprime la nueva frase
    os.system('cls')
    printInfo()
    print("\n[S] Salir")
    print("\nSu frase:",phrase) 
    
    dir = ""
    newPhrase = getPhrase(phrase)
    while(dir != 115) & (dir != 83):  
        contP = 0
        contT = 0
        for i in range(len(phrase)):
            color = randColor()
            cont = 0
            for j in newPhrase[i]:		    		    		    
                if(contP >= 120):
                    contP = 0
                    contT = 6
                cont += 1
                if(phrase == "psicodelico"):#easter egg
                        print(Cursor.POS(2+contP,10+cont+contT)+color+j, end="")
                else:
                    if(contP == shift):                  
                        print(Cursor.POS(2+contP,10+cont+contT)+color+j, end="")
                    else:
                        print(Cursor.POS(2+contP,10+cont+contT)+j, end="")
            contP += 8
        if(phrase == "psicodelico"):
            pass
        else:
            changeColor(phrase, shift)
示例#17
0
def e4(errorcatch):
    errorcatch = longitud(errorcatch)
    print(Fore.WHITE + Style.BRIGHT + Back.LIGHTMAGENTA_EX +
          Cursor.POS(3, 11) + "Ejercicio 4 Terminado",
          end="")
    input(Fore.WHITE + Style.BRIGHT + Cursor.POS(3, 12) + "")
    print("", end="")
    return errorcatch
示例#18
0
def show_roll(roll : list, pause : float):
    for x in range(0,dice_number):
        print(color_lib[roll[x]] + Cursor.POS((dice_indent + (dice_spacing * x)),(y_indent + 2)) + dice_graphic[0], end='')
        print(color_lib[roll[x]] + Cursor.POS((dice_indent + (dice_spacing * x)),(y_indent + 3)) + dice_graphic[1], end='')
        print(color_lib[roll[x]] + Cursor.POS((dice_indent + (dice_spacing * x)),(y_indent + 4)) + dice_graphic[2], end='')
        print(color_lib[roll[x]] + Cursor.POS((dice_indent + 2 + (dice_spacing * x)),(y_indent + 3)) + str(roll[x]), end='')
        time.sleep(pause)
    print(Fore.WHITE)
示例#19
0
def e3(errorcatch):
    errorcatch = fecha(errorcatch)
    print(Fore.BLACK + Back.LIGHTMAGENTA_EX + Cursor.POS(3, 10) +
          "Ejercicio 3",
          end="")
    input(Fore.BLACK + Cursor.POS(3, 11) + Back.WHITE + "")
    print("", end="")
    return errorcatch
示例#20
0
 def backspace_f(n=1):
     puts(
         Cursor.BACK(n) + self.line[self.cursor_pos:] + ' ' * n +
         Cursor.BACK(len(self.line) - self.cursor_pos + n))
     self.line = self.line[:self.cursor_pos -
                           1] + self.line[self.cursor_pos:]
     self.cursor_pos -= n
     if self.cursor_pos < 0: self.cursor_pos = 0
示例#21
0
def e3(errorcatch):
    errorcatch = prefijo(errorcatch)
    print(Fore.WHITE + Style.BRIGHT + Back.LIGHTMAGENTA_EX +
          Cursor.POS(3, 10) + "Ejercicio 3 Terminado",
          end="")
    input(Fore.WHITE + Style.BRIGHT + Cursor.POS(3, 11) + "")
    print("", end="")
    return errorcatch
示例#22
0
def e2(errorcatch):
    errorcatch = cadena_corta(errorcatch)
    print(Fore.WHITE + Style.BRIGHT + Back.LIGHTMAGENTA_EX +
          Cursor.POS(3, 10) + "Ejercicio 2 Terminado",
          end="")
    input(Fore.WHITE + Style.BRIGHT + Cursor.POS(3, 11) + "")
    print("", end="")
    return errorcatch
示例#23
0
def e1(errorcatch):
    errorcatch = nombres(errorcatch)
    print(Fore.WHITE + Style.BRIGHT + Back.LIGHTMAGENTA_EX + Cursor.POS(3, 9) +
          "Ejercicio 1 Terminado",
          end="")
    input(Fore.WHITE + Style.BRIGHT + Cursor.POS(3, 10) + "")
    print("", end="")
    return errorcatch
示例#24
0
def dibujomenu(
        em, e1, e2, e3, e4
):  #Esta funcion creara la ventana siempre que se necesite con colores
    os.system("cls")
    #Borrara la ventana
    #Los siguiente 4 for sera para hacer el marco de la ventana
    x = 1
    y = 3
    for i in range(80):
        print(Cursor.POS(x, y) + Back.RED + " ")
        x += 1
    for i in range(11):
        print(Cursor.POS(x, y) + Back.RED + "   ")
        y += 1
    x = 1
    y = 3
    for i in range(10):
        print(Cursor.POS(x, y) + Back.RED + "  ")
        y += 1

    for i in range(80):
        print(Cursor.POS(x, y) + Back.RED + " ")
        x += 1
    #Este for sera para rellenar la ventana de errores
    x = 3
    y = 14
    for i in range(3):
        for i2 in range(79):
            print(Cursor.POS(x, y) + Back.LIGHTBLUE_EX + " ")
            x += 1
        x = 3
        y += 1
    #En la esquina mandara a imprimir los errores con parametros
    else:
        errorcatch = str(em)
        print(Fore.WHITE + Style.BRIGHT + Cursor.POS(3, 16) +
              Back.LIGHTBLUE_EX + Style.BRIGHT + "Errores Menu: " + errorcatch,
              end="")
        errorcatch = str(e1)
        print(Fore.WHITE + Style.BRIGHT + Cursor.POS(3, 14) +
              Back.LIGHTBLUE_EX + Style.BRIGHT + "Errores en Ej. 1: " +
              errorcatch,
              end="")
        errorcatch = str(e2)
        print(Fore.WHITE + Style.BRIGHT + Cursor.POS(35, 14) +
              Back.LIGHTBLUE_EX + Style.BRIGHT + "Errores en Ej. 2: " +
              errorcatch,
              end="")
        errorcatch = str(e3)
        print(Fore.WHITE + Style.BRIGHT + Cursor.POS(3, 15) +
              Back.LIGHTBLUE_EX + Style.BRIGHT + "Errores en Ej. 3: " +
              errorcatch,
              end="")
        errorcatch = str(e4)
        print(Fore.WHITE + Style.BRIGHT + Cursor.POS(35, 15) +
              Back.LIGHTBLUE_EX + Style.BRIGHT + "Errores en Ej. 4: " +
              errorcatch,
              end="")
示例#25
0
 def printListProcessToExecute(self, x, y, lotsPending):
     print(Fore.LIGHTRED_EX +  Cursor.UP(y) + Cursor.FORWARD(x) +
           "Numero de lotes pendientes: ", lotsPending)
     print(Fore.RESET)
     for index in range(1, 6):
         if index >= len(self.__list):
             print(" ", end="\n")
         elif index < len(self.__list):
             print(Cursor.FORWARD(x) + "process: ", self.__list[index], end="\n")
示例#26
0
def async_alert_str(*, terminal_columns: int, prompt: str, line: str,
                    cursor_offset: int, alert_msg: str) -> str:
    """Calculate the desired string, including ANSI escape codes, for displaying an asynchronous alert message.

    :param terminal_columns: terminal width (number of columns)
    :param prompt: prompt that is displayed on the current line
    :param line: current contents of the Readline line buffer
    :param cursor_offset: the offset of the current cursor position within line
    :param alert_msg: the message to display to the user
    :return: the correct string so that the alert message appears to the user to be printed above the current line.
    """
    from colorama import (
        Cursor, )

    # Split the prompt lines since it can contain newline characters.
    prompt_lines = prompt.splitlines()

    # Calculate how many terminal lines are taken up by all prompt lines except for the last one.
    # That will be included in the input lines calculations since that is where the cursor is.
    num_prompt_terminal_lines = 0
    for line in prompt_lines[:-1]:
        line_width = style_aware_wcswidth(line)
        num_prompt_terminal_lines += int(line_width / terminal_columns) + 1

    # Now calculate how many terminal lines are take up by the input
    last_prompt_line = prompt_lines[-1]
    last_prompt_line_width = style_aware_wcswidth(last_prompt_line)

    input_width = last_prompt_line_width + style_aware_wcswidth(line)

    num_input_terminal_lines = int(input_width / terminal_columns) + 1

    # Get the cursor's offset from the beginning of the first input line
    cursor_input_offset = last_prompt_line_width + cursor_offset

    # Calculate what input line the cursor is on
    cursor_input_line = int(cursor_input_offset / terminal_columns) + 1

    # Create a string that when printed will clear all input lines and display the alert
    terminal_str = ''

    # Move the cursor down to the last input line
    if cursor_input_line != num_input_terminal_lines:
        terminal_str += Cursor.DOWN(num_input_terminal_lines -
                                    cursor_input_line)

    # Clear each line from the bottom up so that the cursor ends up on the first prompt line
    total_lines = num_prompt_terminal_lines + num_input_terminal_lines
    terminal_str += (colorama.ansi.clear_line() +
                     Cursor.UP(1)) * (total_lines - 1)

    # Clear the first prompt line
    terminal_str += colorama.ansi.clear_line()

    # Move the cursor to the beginning of the first prompt line and print the alert
    terminal_str += '\r' + alert_msg
    return terminal_str
示例#27
0
 def printListCompleteOfProcess(self, x, y):
     print(
         Cursor.UP(y) + Cursor.FORWARD(x) + Fore.GREEN +
         "Procesos completados")
     print(Fore.RESET)
     for index in range(0, len(self.__list)):
         print(
             Cursor.FORWARD(x) +
             self.__list[index].toStringProcessComplete())
示例#28
0
def nombres(errorcatch):#guarda nombres y devuelve los nombres que terminen con cierta letra
    #declarar las variables
    nombre = "";#guardara el nombre a agregar
    letra = "";#guardara la letra a buscar
    opcion = 1;#guardara la opcion elegida, se inicializa en 1 para que entre al while al principio
    nombresL = set();#conjunto que guardara los nombres
    while opcion != 3:#mientras opcion sea != 3
        dibujoej(errorcatch);
        
        print(Fore.WHITE+Style.BRIGHT+Cursor.POS(3,4)+"Ingresa 1 para agregar un nombre",end="");
        print(Fore.WHITE+Style.BRIGHT+Cursor.POS(3,5)+"Ingresa 2 para buscar nombres que terminen con cierta letra",end="");
        print(Fore.WHITE+Style.BRIGHT+Cursor.POS(3,6)+"Ingresa 3 para ir al menu: ",end="");
        opcion = str(input());
        try:
            opcion = int(opcion);
            if opcion < 0 and opcion > 3:#si no esta dentro del rango
                dibujoej(errorcatch);
                print(Fore.WHITE+Style.BRIGHT+Cursor.POS(3,4)+"Debes de ingresar una opcion dentro del rango",end="");
                sleep(1);
            if opcion == 1:#si opcion = 1
                dibujoej(errorcatch);
                nombre = str(input(Fore.WHITE+Style.BRIGHT+Cursor.POS(3,4)+"Ingresa un nombre: "));#ingresa un nombre
                print("",end="");
                #se busca el nombre
                if nombre in nombresL: #si el nombre existe
                    dibujoej(errorcatch);
                    print(Fore.WHITE+Style.BRIGHT+Cursor.POS(3,4)+"El nombre ya existe",end="");
                    sleep(1);
                else:#en otro caso
                    nombresL.add(nombre);#se guarda el nombre
            if opcion == 2:#si opcion = 2
                contador=0;
                dibujoej(errorcatch);
                letra = str(input(Fore.WHITE+Style.BRIGHT+Cursor.POS(3,4)+"Ingresa la letra a buscar al final: "));#ingresa una letra a buscar
                print("",end="");
                dibujoej(errorcatch);
                for i in nombresL:
                    if i[-1] == letra:#si la ultima letra es igual a la letra a buscar
                        contador+=1;
                        dibujoej(errorcatch);
                        aux=str(contador);
                        print(Fore.WHITE+Style.BRIGHT+Cursor.POS(3,4)+aux+"# Nombre en coincidencia: "+i,end="");#imprimir el nombre    
                        input(); 
                if contador==0:
                    dibujoej(errorcatch);
                    print(Fore.WHITE+Style.BRIGHT+Cursor.POS(3,4)+"No hubo ningun nombre",end="");#imprimir el nombre 
                    sleep(1);   
            if opcion == 3:#si opcion = 3
                pass;#sale
        except:
            errorcatch+=1;
            dibujoej(errorcatch);
            print(Fore.WHITE+Style.BRIGHT+Cursor.POS(3,4)+"1.-Debes de ingresar numeros como opcion",end="");
            sleep(1);
            #errore1 += 1;#se suma 1 al contador de errores
    return errorcatch;
示例#29
0
def e3(
    errorcatch
):  #recibe un texto y para cada caracter imprime la palabra mas larga donde se encuentra
    errorcatch = agrupacion_3(errorcatch)
    print(Fore.WHITE + Style.BRIGHT + Back.LIGHTMAGENTA_EX +
          Cursor.POS(6, 15) + "Ejercicio 3 Terminado",
          end="")
    input(Fore.WHITE + Style.BRIGHT + Cursor.POS(5, 14) + "")
    print("", end="")
    return errorcatch
def inverso(errorcatch): 
    aumento=[0];
    for i in aumento:
        dibujoej(errorcatch,1);
        print(Fore.WHITE+Style.BRIGHT+Cursor.POS(6,7)+"Ingrese el nombre del archivo a abrir: ", end=""); 
        name=str(input());
        try:
            archivo=open(name,mode="r",encoding="utf-8"); #Abre el archivo
            cont=0;
            inc=0;
            dibujoej(errorcatch,1);
            while(True):
                cont+=1;
                if cont+8>25: #Si ya no cabe en un lado, cambiara el parrafo hacia el otro lado
                    x=60;
                    inc+=1;
                    y=inc+8;
    
                else: #Si no lo deja del otro
                    x=6; 
                    y=cont+8;
                
                linea=archivo.readline();#Lee por linea los caracteres
                if not linea: #Si ya no hay lineas
                    break;
                
                imprimir=str(reverse(linea)); #Hace al reves las lineas
                imprimir=imprimir[1:];
                print(Back.BLACK+Fore.WHITE+Style.BRIGHT+Cursor.POS(x,y)+" ",imprimir, end=""); 
            archivo.close;

            archivo=open(name,mode="r",encoding="utf-8"); #Vuelve a abrir el archivo para evitar problemas
            leer=archivo.read(); #Por caracter lo lee
            palabras=leer.split();
            p_contador=0;
            c_contador=0;
            for i in palabras: #Cuenta el total de palabras en el texto
                p_contador+=1;
            for i in leer: #Cuenta el total de caracteres exceptuando espacios
                if i == " ":
                    pass;
                else:
                    c_contador+=1;
            archivo.close;
            aux=str(c_contador);
            print(Fore.WHITE+Style.BRIGHT+Cursor.POS(6,6)+"El total de caracteres del archivo fue de: ",aux, end="");
            aux=str(p_contador);
            print(Fore.WHITE+Style.BRIGHT+Cursor.POS(6,7)+"El total de palabras del archivo fue de: ",aux, end="");
        except:
            errorcatch+=1;
            aumento.append(0);
            dibujoej(errorcatch,1);
            print(Fore.WHITE+Style.BRIGHT+Cursor.POS(6,7)+"Ese archivo no se encontro, Verifique el nombre ", end=""); 
            sleep(2);
    return errorcatch;