[ Foro de Python ]

Python

16-Feb-2020 22:09
Invitado (jose caro)
1 Respuestas

from tkinter import *
from tkinter import messagebox
from tkinter import filedialog
from tkinter import ttk
import sqlite3
import os
from datetime import date

def mentry():
   NumeroEntry.delete(0,END)


def cerrarDocumentos():
valor=messagebox.askretrycancel("Reintentar", "No es posible cerrar documento")

if valor==False:
principal.destroy()

def abreFichero():
fichero=fileProfecionlog.askopenfilename(title="Abrir")


def crearCandidato():
miConexion=sqlite3.connect("datosCandidato")
miCursor=miConexion.cursor()
try:
miCursor.execute('''CREATE TABLE BASECandidato (
Numero INTEGER(3),
Nombre VARCHAR(10),
Apellido VARCHAR(10),
Profecion VARCHAR(6),
Contrato VARCHAR(6),
Salario VARCHAR(6),
ENE VARCHAR(2),
FEB VARCHAR(2),
MAR VARCHAR(2),
ABR VARCHAR(2),
MAY VARCHAR(2),
JUN VARCHAR(2),
JUL VARCHAR(2),
AGO VARCHAR(2),
SEP VARCHAR(2),
OCT VARCHAR(2),
NOV VARCHAR(2),
DIC VARCHAR(2))''')

messagebox.showinfo("Base de Candidato", "Creada con Exito")
except:
messagebox.showwarning("¡Atencion!", "La base de Candidato ya existe")

def guardarCandidato():
miConexion=sqlite3.connect("datosCandidato")
miCursor=miConexion.cursor()
miCursor.execute("INSERT INTO BASECandidato VALUES('"
+ miNumero.get() + "','"
+ miNombre.get() + "','"
+ miApellido.get() + "','"
+ miProfecion.get() + "','"
+ miContrato.get() + "','"
+ miSalario.get() +"','"
+ miENE.get() + "','"
+ miFEB.get() + "','"
+ miMAR.get() + "','"
+ miABR.get() + "','"
+ miMAY.get() + "','"
+ miJUN.get() + "','"
+ miJUL.get() + "','"
+ miAGO.get() + "','"
+ miSEP.get() + "','"
+ miOCT.get() + "','"
+ miNOV.get() + "','"
+ miDIC.get() + "')")

miConexion.commit()
messagebox.showwarning("Base de Candidato", "Registro guardado con exito")

def actualizarCandidato():
miConexion=sqlite3.connect("datosCandidato")
miCursor=miConexion.cursor()

miCursor=miConexion.cursor()
Candidato=miNumero.get(),
miNombre.get(),
miApellido.get(),
miProfecion.get(),
miContrato.get(),
miSalario.get(),
miENE.get(),
miFEB.get(),
miMAR.get(),
miABR.get(),
miMAY.get(),
miJUN.get(),
miJUL.get(),
miAGO.get(),
miSEP.get(),
miOCT.get(),
miNOV.get(),
miDIC.get()



miCursor.execute("UPDATE BASECandidato SET Numero=?, Nombre=?, Apellido=?, Profecion=?, Contrato=?, Salario=?, ENE=?,FEB=?,MAR=?,ABR=?,MAY=?,JUN=?,\
JUL=?,AGO=?,SEP=?,OCT=?,NOV=?,DIC=?"  + "WHERE Numero=" + miNumero.get(),(Candidato))

miConexion.commit()
messagebox.showwarning("Base de Candidato", "Registro Actualizado con exito")


def buscarCandidato():
miConexion=sqlite3.connect("datosCandidato")
miCursor=miConexion.cursor()

miCursor.execute("SELECT * FROM BASECandidato WHERE Numero=" + miNumero.get())
elUsuario=miCursor.fetchall()
for usuario in elUsuario:
miNumero.set(usuario[0])
miNombre.set(usuario[1])
miApellido.set(usuario[2])
miProfecion.set(usuario[3])
miContrato.set(usuario[4])
miSalario.set(usuario[5])
miENE.set(usuario[6])
miFEB.set(usuario[7])
miMAR.set(usuario[8])
miABR.set(usuario[9])
miMAY.set(usuario[10])
miJUN.set(usuario[11])
miJUL.set(usuario[12])
miAGO.set(usuario[13])
miSEP.set(usuario[14])
miOCT.set(usuario[15])
miNOV.set(usuario[16])
miDIC.set(usuario[17])

miConexion.commit()

def eliminarCandidato():
miConexion=sqlite3.connect("datosCandidato")
miCursor=miConexion.cursor()
miCursor.execute("DELETE FROM BASECandidato WHERE Codigo=" + miNumero.get())
miConexion.commit()
messagebox.showwarning("Base de Datos", "Registro Borrado con exito")

def borrarCandidato():
miNumero.set("")
miNombre.set("")
miApellido.set("")
miProfecion.set("")
miContrato.set("")
miSalario.set("")
miENE.set("")
miFEB.set("")
miMAR.set("")
miABR.set("")
miMAY.set("")
miJUN.set("")
miJUL.set("")
miAGO.set("")
miSEP.set("")
miOCT.set("")
miNOV.set("")
miDIC.set("")


def salirEmpresa():
valor=messagebox.askokcancel("salir", "Deseas salir del pograma ")
if valor==True:
Empresa.destroy()


def llamarCandidato():
Candidato.pack()

def llamarInforme():
informe.pack()

def salirCandidato():
Candidato.pack_forget()

def salirInforme():
informe.pack_forget()

def removeValue(event):
       self.entry.delete(0, 'end')
       return None

def validar():
   if entrada1.get()=='Jose':
       messagebox.showwarning("OK","Password Correcto")
       crearCandidato
   else:
       messagebox.showwarning("Cuidado","Password incorrecto")



Empresa=Tk()
Empresa.title(" Colegio ")
Empresa.resizable(1,1)
Empresa.config(bg="Light grey")
Empresa.geometry("700x600+300+50")

nombreLabel=Label(Empresa, text="Ventana Empresa", bg="light grey", font=("Bernard MT Condensed", 44))
nombreLabel.place(x=50, y=60)

barraMenu=Menu(Empresa)
Empresa.config(menu=barraMenu)
archivoMenu=Menu(barraMenu, tearoff=0)


archivoMenu.add_command(label="Candidato", command=llamarCandidato)
archivoMenu.add_command(label="Informe", command=llamarInforme)
archivoMenu.add_command(label="Salir", command=salirEmpresa)
barraMenu.add_cascade(label="Ventanas", menu=archivoMenu)

#---------------------------Ventana Candidato----------------------------

Candidato = Frame(Empresa)
Candidato.pack()
Candidato.config(widt="400", height="600")
Candidato.config(bd=5)
Candidato.config(relief="groove")
Candidato.config(cursor="hand2")


miNumero=StringVar()
miNombre=StringVar()
miApellido=StringVar()
miProfecion=StringVar()
miContrato=StringVar()
miSalario=StringVar()
miENE=StringVar()
miFEB=StringVar()
miMAR=StringVar()
miABR=StringVar()
miMAY=StringVar()
miJUN=StringVar()
miJUL=StringVar()
miAGO=StringVar()
miSEP=StringVar()
miOCT=StringVar()
miNOV=StringVar()
miDIC=StringVar()
miMes=StringVar()

today = date.today()
final_date=today
 
 
nombreLabel=Label(Candidato, text="Ventana Candidato", bg="light grey", font=("FreeStyle Script", 34))
nombreLabel.place(x=50, y=10)

NumeroLabel=Label(Candidato, text="Numero", bg="light grey")
NumeroLabel.place(x=20, y=100)
NumeroEntry=Entry(Candidato, textvariable=miNumero, width=3)
NumeroEntry.place(x=100, y=100)
NumeroEntry.config(justify="center")
NumeroEntry.delete(0,END)

nombreLabel=Label(Candidato, text="Nombre", bg="light grey")
nombreLabel.place(x=20, y=130)
nombreEntry=Entry(Candidato, textvariable=miNombre)
nombreEntry.place(x=100, y=130)
nombreEntry.config(justify="center")
nombreEntry.delete(0,END)

apelliLabel=Label(Candidato, text="Apellido", bg="light grey")
apelliLabel.place(x=20, y=160)
apelliEntry=Entry(Candidato, textvariable=miApellido)
apelliEntry.place(x=100, y=160)
apelliEntry.config(justify="center")
apelliEntry.delete(0,END)

ProfecionLabel=Label(Candidato, text="Profecion", bg="light grey")
ProfecionLabel.place(x=20, y=190)
ProfecionLabel=ttk.Combobox(Candidato, width=15, textvariable=miProfecion)
ProfecionLabel.place(x=100, y=190)
ProfecionLabel['values']=('Abogado','Arquitecto','Mecanico', 'Electricista','Plomero','OficiosVarios')
ProfecionLabel.config(justify="center")
ProfecionLabel.delete(0,END)

Contrato=Label(Candidato, text="Contrato", bg="light grey")
Contrato.place(x=20, y=220)
Contrato=ttk.Combobox(Candidato, width=15, textvariable=miContrato)
Contrato.place(x=100, y=220)
Contrato['values']=('Indefinido','Fijo','Prestacion de Servicios')
Contrato.config(justify="center")
Contrato.delete(0,END)

Salario=Label(Candidato, text="Salario", bg="light grey")
Salario.place(x=20, y=250)
Salario=ttk.Combobox(Candidato, width=15, textvariable=miSalario)
Salario.place(x=100, y=250)
Salario['values']=('Minimo','Basico Integral','Gerencial')
Salario.config(justify="center")
Salario.delete(0,END)

mestrabajo=Label(Candidato, text="Mes de Trabajo", bg="light grey")
mestrabajo.place(x=150, y=300)

programaEne=Label(Candidato, text="ENE", bg="light grey")
programaEne.place(x=24, y=320)
comboEne=ttk.Combobox(Candidato, width=3, textvariable=miENE)
comboEne.place(x=25, y=340)
comboEne['values']=('ENE',' ')
comboEne.config(justify="center")

programaJUL=Label(Candidato, text="JUL", bg="light grey")
programaJUL.place(x=20, y=360)
comboJUL=ttk.Combobox(Candidato, width=3, textvariable=miJUL)
comboJUL.place(x=20, y=380)
comboJUL['values']=('JUL',' ')
comboJUL.config(justify="center")

programaFEB=Label(Candidato, text="FEB", bg="light grey")
programaFEB.place(x=80, y=320)
comboFEB=ttk.Combobox(Candidato, width=3, textvariable=miFEB)
comboFEB.place(x=80, y=340)
comboFEB['values']=('FEB',' ')
comboFEB.config(justify="center")

programaAGO=Label(Candidato, text="AGO", bg="light grey")
programaAGO.place(x=80, y=360)
comboAGO=ttk.Combobox(Candidato, width=3, textvariable=miAGO)
comboAGO.place(x=80, y=380)
comboAGO['values']=('AGO',' ')
comboAGO.config(justify="center")

programaMAR=Label(Candidato, text="MAR", bg="light grey")
programaMAR.place(x=140, y=320)
comboMAR=ttk.Combobox(Candidato, width=3, textvariable=miMAR)
comboMAR.place(x=140, y=340)
comboMAR['values']=('MAR',' ')
comboMAR.config(justify="center")

programaSEP=Label(Candidato, text="SEP", bg="light grey")
programaSEP.place(x=140, y=360)
comboSEP=ttk.Combobox(Candidato, width=3, textvariable=miSEP)
comboSEP.place(x=140, y=380)
comboSEP['values']=('SEP',' ')
comboSEP.config(justify="center")

programaABR=Label(Candidato, text="ABR", bg="light grey")
programaABR.place(x=200, y=320)
comboABR=ttk.Combobox(Candidato, width=3, textvariable=miABR)
comboABR.place(x=200, y=340)
comboABR['values']=('ABR',' ')
comboABR.config(justify="center")

programaOCT=Label(Candidato, text="OCT", bg="light grey")
programaOCT.place(x=200, y=360)
comboOCT=ttk.Combobox(Candidato, width=3, textvariable=miOCT)
comboOCT.place(x=200, y=380)
comboOCT['values']=('OCT',' ')
comboOCT.config(justify="center")


programaMAY=Label(Candidato, text="MAY", bg="light grey")
programaMAY.place(x=260, y=320)
comboMAY=ttk.Combobox(Candidato, width=3, textvariable=miMAY)
comboMAY.place(x=260, y=340)
comboMAY['values']=('MAY',' ')
comboMAY.config(justify="center")

programaNOV=Label(Candidato, text="NOV", bg="light grey")
programaNOV.place(x=260, y=360)
comboNOV=ttk.Combobox(Candidato, width=3, textvariable=miNOV)
comboNOV.place(x=260, y=380)
comboNOV['values']=('NOV',' ')
comboNOV.config(justify="center")

programaJUN=Label(Candidato, text="JUN", bg="light grey")
programaJUN.place(x=320, y=320)
comboJUN=ttk.Combobox(Candidato, width=3, textvariable=miJUN)
comboJUN.place(x=320, y=340)
comboJUN['values']=('JUN',' ')
comboJUN.config(justify="center")


   
programaDIC=Label(Candidato, text="DIC", bg="light grey")
programaDIC.place(x=320, y=360)
comboDIC=ttk.Combobox(Candidato, width=3, textvariable=miDIC)
comboDIC.place(x=320, y=380)
comboDIC['values']=('DIC',' ')
comboDIC.config(justify="center")



entrada1=Label(Candidato, text="Contraseña", bg="light grey")
entrada1.place(x=320, y=82)
entrada1=Entry(Candidato)
entrada1.place(x=330, y=100)
entrada1.config(width=7)


botonCrearbase=Button(Candidato, text="Crear", command=validar)
botonCrearbase.place(x=250, y=100)
botonCrearbase.configure(background="red")
botonCrearbase.config(width=7)

botonGuarda=Button(Candidato, text="Guadar", command=(guardarCandidato))
botonGuarda.place(x=250, y=150)
botonGuarda.config(width=7)

botonActual=Button(Candidato, text="Actualizar", command=actualizarCandidato)
botonActual.place(x=250, y=200)
botonActual.config(width=7)

botonElimin=Button(Candidato, text="Eliminar", command=eliminarCandidato)
botonElimin.place(x=250, y=250)
botonElimin.config(width=7)

botonBuscar=Button(Candidato, text="Buscar", command=buscarCandidato)
botonBuscar.place(x=250, y=420)
botonBuscar.config(width=7)

botonBorrar=Button(Candidato, text="Borrar", command=borrarCandidato)
botonBorrar.place(x=170, y=420)
botonBorrar.config(width=7)

Salir1=Button(Candidato, text="Salir", command=salirCandidato)
Salir1.place(x=100, y=420)
Salir1.config(width=7)

nombreLabe=Label(Candidato, text="1) Cuando el box de Nombre no sea digitalizado, no me deje continuar", bg="light grey", font=("arial", 8))
nombreLabe.place(x=5, y=490)
nombreLabe=Label(Candidato, text="con otra digitalizacion y me envie una señal de alerta", bg="light grey", font=("arial", 8))
nombreLabe.place(x=5, y=510)
nombreLabe=Label(Candidato, text="2) Que al terminar de grabar me envie una orden que limpie los box, ", bg="light grey", font=("arial", 8))
nombreLabe.place(x=5, y=530)
nombreLabe=Label(Candidato, text="y no se salga se la ventana sino que permanezca en ella, para nuevo datos.", bg="light grey", font=("arial", 8))
nombreLabe.place(x=5, y=550)

Candidato.config(bg="light grey")


Candidato.pack_forget()



#---------------------------Informe----------------------------

informe = Frame(Empresa, )
informe.pack()
informe.config(widt="400", height="400")
informe.config(bd=5)
informe.config(relief="groove")
informe.config(cursor="hand2")

nombreLabel=Label(informe, text="Ventana Informe", bg="light grey", font=("FreeStyle Script", 34))
nombreLabel.place(x=50, y=10)

Elaborar1=Button(informe, text="Elaborar",)
Elaborar1.config(width=7)
Elaborar1.place(x=300, y=100)

Imprimir1=Button(informe, text="Iprimir",)
Imprimir1.place(x=300, y=140)
Imprimir1.config(width=7)

Salir1=Button(informe, text="Salir", command=salirInforme)
Salir1.place(x=300, y=180)
Salir1.config(width=7)

ProfecionLabel=Label(informe, text="Profecion", bg="light grey")
ProfecionLabel.place(x=100, y=120)
#ProfecionLabel=ttk.Combobox(informe, width=15, textvariable=miProfecion)
ProfecionLabel = Spinbox(informe, width=15, values=('Abogado','Arquitecto','Mecanico', 'Electricista','Plomero','OficiosVarios'), increment=1,)
#ProfecionLabel['values']=('Abogado','Arquitecto','Mecanico', 'Electricista','Plomero','OficiosVarios')
ProfecionLabel.place(x=160, y=120)
ProfecionLabel.config(justify="center")

valor = IntVar()
Mes=Label(informe, text="Mes", bg="light grey")
Mes.place(x=100, y=160)


Mes = Spinbox(informe, width=6, values=('Ene','Feb', 'Abr','May','Jun','Jul', 'Ago','Sep', 'Oct', 'Nov','DIC'), increment=1,)
Mes.place(x=160, y=160)
Mes.config(justify="center")


informe.config(bg="light grey")

nombreLabe=Label(informe, text="1) Enviar una orden a la base de datos para que me busque ", bg="light grey", font=("arial", 8))
nombreLabe.place(x=5, y=250)
nombreLabe=Label(informe, text="toda la información para un mes indicado", bg="light grey", font=("arial", 8))
nombreLabe.place(x=5, y=270)
nombreLabe=Label(informe, text="2) Enviar una orden a la base de datos, para que en cierto mes  ", bg="light grey", font=("arial", 8))
nombreLabe.place(x=5, y=300)
nombreLabe=Label(informe, text="me diga los datos de las profesiones requeridas", bg="light grey", font=("arial", 8))
nombreLabe.place(x=5, y=320)

informe.pack_forget()

Empresa.mainloop()


16-Feb-2020 22:37
Nacho Cabanes (+84)

Y la pregunta es...?






(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)