UNIDAD 4-PROGRAMAS HECHOS DESDE CERO

Imagen
#PROGRAMA QUE PIDE EL NOMBRE DE UNA PERSONA Y LA SALUDA. from Tkinter import * from tkMessageBox import * ventana=Tk() ventana.geometry("300x300") ventana.title('Hola.........') nombre= StringVar() nombre.set('') dato=Entry(ventana,textvariable=str(nombre)).place(x=100,y=100) button=Button(ventana,text='hola',command=lambda:showinfo(title='hola', message='hola '+ nombre.get())).place(x=100,y=150) ventana.mainloop() ejecucion del programa: #Programa que abre el explorador de archivos y copia la ruta y la muestra en un Entry. from Tkinter import * from PIL import * from tkFileDialog import askopenfilename ventana=Tk() ventana.geometry('450x300') def llamada(): hey = StringVar() nombre = askopenfilename() print nombre hey.set(nombre) label = Entry(ventana, textvariable=hey,width=50).place(x=100, y=100) nombre=Label(ventana,text='pulse el boton y elija una ruta').place(x=10,y=10) label=

EJERCICIO DEL DIA 09 DE OCTUBRE DEL 2018


programa mejorado por el compañero Lyvan Alejandro Lumbreras Hernandez:


from colorama import Fore, Style

opc = 1
while opc != 4:
    print (
                Fore.CYAN + "\t\tMENU\n\n1.- Capturar nuevo registro\n2.- Mostrar registros\n3.- Eliminar registro\n4.- Salir" + Style.RESET_ALL)
    opcion = raw_input("Elige la opcion:\n")

    if opcion == "1":
        op = "si"
        x = 0
        while op != "no":
            rc = "no"
            while rc != "si":
                print (Fore.BLUE + "\t\tNUEVO REGISTRO\n" + Style.RESET_ALL)
                archivo = open("ejemplo1.csv", "a")
                nombre = raw_input("Ingresa un nombre:\n")
                apellido = raw_input("Ingresa un apellido\n")
                print (
                            Fore.BLUE + "\t\tEL REGISTRO INGRESADO ES : " + nombre + " " + apellido + "\n\t\tES CORRECTO? si/no\n" + Style.RESET_ALL)
                rc = raw_input()
                while x != 1:
                    if rc != "si" and rc != "no":
                        print (Fore.RED + "\t\tINGRESE UNA RESPUESTA CORRECTA si/no\n" + Style.RESET_ALL)
                        rc = raw_input()
                    else:
                        x = 1
                if rc == "si":
                    rc = "si"
                else:
                    rc = "no"

            print (Fore.RED + "\t\tSE A CAPTURADO EL REGISTRO : " + Style.RESET_ALL + nombre + " " + apellido)
            archivo.write(nombre + "," + apellido + "\n")
            print (Fore.BLUE + "\t\tREQUIERE INGRESAR OTRO REGISTRO? si/no" + Style.RESET_ALL)
            op = raw_input()

    elif opcion == "2":
        print (Fore.GREEN + "\t\tMOSTRAR REGISTROS\n" + Style.RESET_ALL)
        archivo = open("ejemplo1.csv")
        r = archivo.read()
        if r == "":
            print (Fore.RED + "\t\tEL ARCHIVO ESTA VACIO\n\n")
            archivo.close()
            time.sleep(3)
        else:
            print "Cargando.."
            time.sleep(2)
            print (Fore.GREEN + "Carga lista:" + Style.RESET_ALL)
            print r
            archivo.close()
            time.sleep(3)

    elif opcion == "3":
        print Fore.RED + "\t\tBORRAR\n"
        archivo = open("ejemplo1.csv", "a")
        a = open("ejemplo1.csv")
        r = a.read()
        if r == "":
            print ("\t\tEL ARCHIVO ESTA VACIO\n\n")
            archivo.close()
            time.sleep(3)
        else:
            archivo.truncate()
            print (Fore.RED + "\t\tLOS REGISTROS HAN SIDO BORRADOS\n" + Style.RESET_ALL)
            archivo.close()
            time.sleep(3)

    elif opcion == "4":
        print (Fore.RED + "\t\tSALIR DEL PROGRAMA")
        print ("\t\tADIOS" + Style.RESET_ALL)
        opc = 4
ejecucio del programa:

Comentarios

Entradas más populares de este blog

Modulos de Python

1.2 Dispositivos de hardware y software para el despliegue gráfico.

ejercicios del dia 06-11-18(ejercicios de ventanas,showinfo....)