0% encontró este documento útil (0 votos)
58 vistas6 páginas

Ferreteria Py

Este documento contiene el código para crear una interfaz gráfica de usuario para una ferretería utilizando Tkinter en Python. Se crean frames, etiquetas, cuadros de entrada y botones para registrar clientes, ingresar códigos y descripciones de productos, y realizar cálculos de precios y totales. El código también incluye funciones para procesar los datos ingresados y limpiar los campos.
Derechos de autor
© © All Rights Reserved
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como PDF, TXT o lee en línea desde Scribd
0% encontró este documento útil (0 votos)
58 vistas6 páginas

Ferreteria Py

Este documento contiene el código para crear una interfaz gráfica de usuario para una ferretería utilizando Tkinter en Python. Se crean frames, etiquetas, cuadros de entrada y botones para registrar clientes, ingresar códigos y descripciones de productos, y realizar cálculos de precios y totales. El código también incluye funciones para procesar los datos ingresados y limpiar los campos.
Derechos de autor
© © All Rights Reserved
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como PDF, TXT o lee en línea desde Scribd
Está en la página 1/ 6

from tkinter import *

from tkinter import messagebox

def banner():
root = Tk()
root.title('Ferretería El tornillo feliz')
root.config(bg= "#BDDCE1")
root.resizable(False,False)

miFrame = Frame(root)
miFrame.pack()
miFrame.config(bg = "#A4D8D4")

lDni = Label(miFrame, text='Registrarse', font=("calibri", 25),bg= "#A4D8D4" )


lDni.grid(row=0, column=3, pady=15, padx=15)

obtenerDni=StringVar()
lDni = Label(miFrame, text='Usuario',bg = "#FFEEDD")
lDni.grid(row=5, column=2, sticky='e', pady=5, padx=5)
tDni = Entry(miFrame,textvariable=obtenerDni)
tDni.grid(row=5, column=3, pady=5, padx=5)

obtenerApellido=StringVar()
lApellido = Label(miFrame, text='Contraseña',bg = "#FFEEDD")
lApellido.grid(row=7, column=2, sticky='e', pady=5, padx=5)
tApellido = Entry(miFrame,textvariable=obtenerApellido)
tApellido.grid(row=7, column=3, pady=5, padx=5)

obtenerNombre=StringVar()
lNombre = Label(miFrame, text='Pais',bg = "#FFEEDD")
lNombre.grid(row=9, column=2, sticky='e', pady=5, padx=5)
tNombre = Entry(miFrame,textvariable=obtenerNombre)
tNombre.grid(row=9, column=3, pady=5, padx=5)

obtenerDir=StringVar()
lDireccion = Label(miFrame, text='Empresa',bg = "#FFEEDD")
lDireccion.grid(row=11, column=2, sticky='e', pady=10, padx=10)
tDireccion = Entry(miFrame,textvariable=obtenerDir)
tDireccion.grid(row=11, column=3, columnspan=3, sticky='we',pady=10, padx=10)
#Label y entry Teléfono --------------------------------

obtenerTel=StringVar()
lTel = Label(miFrame, text='Correo',bg = "#FFEEDD")
lTel.grid(row=8, column=2, sticky='e', pady=5, padx=5)
tTel = Entry(miFrame,textvariable=obtenerTel)
tTel.grid(row=8, column=3,columnspan=3, sticky='we', pady=5, padx=5)

guardar = Button(miFrame, text='Registrarse', font=("calibri", 15),bg=


"#00CD63")
guardar.grid(row=13, column=3, pady=5, padx=5)
guardar = Button(miFrame, text='Iniciar sesion', font=("calibri", 12),bg=
"#00CD63")
guardar.grid(row=4, column=4, pady=5, padx=5)

def Operacion():
try:
cant=int(getquantity1.get());
cant1=int(getquantity2.get());

This study source was downloaded by 100000867250967 from CourseHero.com on 05-15-2023 13:59:15 GMT -05:00

https://www.coursehero.com/file/177296548/ferreteriapy/
cant2=int(getquantity3.get());
prec=float(getprice1.get());
prec2=float(getprice2.get());
prec3=float(getprice3.get());
subt=(cant*prec);
subt1=(cant1*prec2);
subt2=(cant2*prec3);
totl = (subt+subt1+subt2);
obtenerSubtotal.set(str(subt));
obtenerSubtotal1.set(str(subt1));
obtenerSubtotal2.set(str(subt2));
obtenerTotal.set(str(totl));
except ValueError:
messagebox.showinfo("ERROR","Ingrese valores validos");
def Codigos():
try:
codg=int(getidcode1.get());
codg2=int(getidcode2.get());
codg3=int(getidcode3.get());
desc=getdescription1.get();
desc2=getdescription2.get();
desc3=getdescription3.get();
prec=getprice1.get();
prec2=getprice2.get();
prec3=getprice3.get();
uni=getunit1.get();
uni2=getunit2.get();
uni3=getunit3.get();

if codg>1 and codg<10:


desc="Stock"
prec=15
uni = "Kilogramos"
elif codg>10 and codg <30:
desc="Sin Oferta!"
prec=30
uni= "Metros"
else:
desc= "Oferta!"
prec=50
uni ="Litros"

if codg2>1 and codg<10:


desc2="Stock"
prec2=60
uni2 = "Kilos"
elif codg2>10 and codg <30:
desc2="Sin Oferta!"
prec2= 80
uni2= "Metros"
else:
desc2= "Oferta!"
prec2=90
uni2 ="Litros"

if codg3>1 and codg<10:


desc3="Stock"
prec3=90
uni3 ="Litros"

This study source was downloaded by 100000867250967 from CourseHero.com on 05-15-2023 13:59:15 GMT -05:00

https://www.coursehero.com/file/177296548/ferreteriapy/
elif codg3>10 and codg <30:
desc3="Sin Oferta!"
prec3=120
uni3="Kilos"
else:
desc3= "Oferta!"
prec3=190
uni3= "Metros"

getprice1.set(str(prec));
getprice2.set(str(prec2));
getprice3.set(str(prec3));

getdescription1.set(str(desc));
getdescription2.set(str(desc2));
getdescription3.set(str(desc3));

getidcode1.set(str(codg));
getidcode2.set(str(codg2));
getidcode3.set(str(codg3));

getunit1.set(str(uni));
getunit2.set(str(uni2));
getunit3.set(str(uni3));
except ValueError:
messagebox.showinfo("ERROR","Ingrese valores correctos");

def Clear():
getidcode1.set("");
getidcode2.set("");
getidcode3.set("");
getdescription1.set("");
getdescription2.set("");
getdescription3.set("");
getunit1.set("");
getunit2.set("");
getunit3.set("");
getquantity1.set("");
getquantity2.set("");
getquantity3.set("");
getprice1.set("");
getprice2.set("");
getprice3.set("")
obtenerSubtotal.set("");
obtenerSubtotal1.set("");
obtenerSubtotal2.set("");
obtenerTotal.set("");
tDni.focus();

root = Tk()
root.title('Ferretería El tornillo feliz')
root.config(bg= "#BDDCE1")
root.geometry("600x370")

miFrame = Frame(root)
miFrame.pack()
miFrame.config(bg = "#A4D8D4")

This study source was downloaded by 100000867250967 from CourseHero.com on 05-15-2023 13:59:15 GMT -05:00

https://www.coursehero.com/file/177296548/ferreteriapy/
lDni = Label(miFrame, text='Ferretria El tornillo Feliz', font=("calibri", 18),bg=
"#A4D8D4" )
lDni.grid(row=0, column=2, pady=10, padx=10)

obtenerDni=StringVar()
lDni = Label(miFrame, text='DNI:')
lDni.grid(row=5, column=0, sticky='e', pady=5, padx=5)
tDni = Entry(miFrame,textvariable=obtenerDni)
tDni.grid(row=5, column=1, pady=5, padx=5)

obtenerApellido=StringVar()
lApellido = Label(miFrame, text='Apellido:')
lApellido.grid(row=6, column=0, sticky='e', pady=5, padx=5)
tApellido = Entry(miFrame,textvariable=obtenerApellido)
tApellido.grid(row=6, column=1, pady=5, padx=5)

obtenerNombre=StringVar()
lNombre = Label(miFrame, text='Nombre:')
lNombre.grid(row=6, column=2, sticky='e', pady=5, padx=5)
tNombre = Entry(miFrame,textvariable=obtenerNombre)
tNombre.grid(row=6, column=3, pady=5, padx=5)

obtenerDir=StringVar()
lDireccion = Label(miFrame, text='Dirección:')
lDireccion.grid(row=7, column=0, sticky='e', pady=5, padx=5)
tDireccion = Entry(miFrame,textvariable=obtenerDir)
tDireccion.grid(row=7, column=1, columnspan=3, sticky='we',pady=5, padx=5)

obtenerTel=StringVar()
lTel = Label(miFrame, text='Teléfono:')
lTel.grid(row=8, column=0, sticky='e', pady=5, padx=5)
tTel = Entry(miFrame,textvariable=obtenerTel)
tTel.grid(row=8, column=1,columnspan=3, sticky='we', pady=5, padx=5)

miFrame1 = Frame(root)
miFrame1.pack()

getidcode1 = StringVar()
getidcode2 = StringVar()
getidcode3 = StringVar()

lcode = Label(miFrame1, text='Cod_Prod')


lcode.grid(row=9, column=0,sticky='e', pady=5, padx=5)
tcode1 = Entry(miFrame1, width=7, textvariable =getidcode1)
tcode1.grid(row=10, column=0, pady=5, padx=5)
tcode2 = Entry(miFrame1, width=7,textvariable =getidcode2 )
tcode2.grid(row=11, column=0, pady=5, padx=5)
tcode3 = Entry(miFrame1, width=7,textvariable =getidcode3)
tcode3.grid(row=12, column=0, pady=5, padx=5)

getdescription1 = StringVar()
getdescription2 =StringVar()
getdescription3 =StringVar()

lDes = Label(miFrame1, text='Descripción')


lDes.grid(row=9, column=1,sticky='ew', pady=5, padx=5)
tDes1 = Entry(miFrame1, width=7, state="readonly",textvariable = getdescription1)
tDes1.grid(row=10, column=1, pady=5, padx=5)

This study source was downloaded by 100000867250967 from CourseHero.com on 05-15-2023 13:59:15 GMT -05:00

https://www.coursehero.com/file/177296548/ferreteriapy/
tDes2 = Entry(miFrame1, width=7, state="readonly",textvariable = getdescription2)
tDes2.grid(row=11, column=1, pady=5, padx=5)
tDes3 = Entry(miFrame1, width=7, state="readonly",textvariable = getdescription3)
tDes3.grid(row=12, column=1, pady=5, padx=5)

getunit1 = StringVar()
getunit2 = StringVar()
getunit3 = StringVar()

lUni = Label(miFrame1, text='Unidad')


lUni.grid(row=9, column=2,sticky='ew', pady=5, padx=5)
tuni2 = Entry(miFrame1, width=7, state="readonly", textvariable = getunit1)
tuni2.grid(row=10, column=2, pady=5, padx=5)
tuni3 = Entry(miFrame1, width=7, state="readonly",textvariable = getunit2 )
tuni3.grid(row=11, column=2, pady=5, padx=5)
tUni3 = Entry(miFrame1, width=7, state="readonly",textvariable = getunit3)
tUni3.grid(row=12, column=2, pady=5, padx=5)

getquantity1 = StringVar()
getquantity2 = StringVar()
getquantity3 = StringVar()

lquantity = Label(miFrame1, text='Cantidad')


lquantity.grid(row=9, column=3,sticky='ew', pady=5, padx=5)
tquantity1 = Entry(miFrame1, width=7, textvariable = getquantity1)
tquantity1.grid(row=10, column=3, pady=5, padx=5)
tquantity2 = Entry(miFrame1, width=7, textvariable = getquantity2)
tquantity2.grid(row=11, column=3, pady=5, padx=5)
tquantity3 = Entry(miFrame1, width=7, textvariable = getquantity3)
tquantity3.grid(row=12, column=3, pady=5, padx=5)

getprice1 = StringVar()
getprice2 = StringVar()
getprice3 = StringVar()

lPrecio = Label(miFrame1, text='Precio')


lPrecio.grid(row=9, column=4,sticky='ew', pady=5, padx=5)
tPrecio1 = Entry(miFrame1, width=7,textvariable = getprice1)
tPrecio1.grid(row=10, column=4, pady=5, padx=5)
tPrecio2 = Entry(miFrame1, width=7,textvariable = getprice2)
tPrecio2.grid(row=11, column=4, pady=5, padx=5)
tPrecio3 = Entry(miFrame1, width=7,textvariable = getprice3)
tPrecio3.grid(row=12, column=4, pady=5, padx=5)
obtenerSubtotal = StringVar()
obtenerSubtotal1 = StringVar()
obtenerSubtotal2 = StringVar()
lSubtotal = Label(miFrame1, text='Subtotal')
lSubtotal.grid(row=9, column=5,sticky='ew', pady=5, padx=5)
tSubtotal1 = Entry(miFrame1, width=7, state="readonly",textvariable =
obtenerSubtotal)
tSubtotal1.grid(row=10, column=5, pady=5, padx=5)
tSubtotal2 = Entry(miFrame1, width=7, state="readonly",textvariable =
obtenerSubtotal1)
tSubtotal2.grid(row=11, column=5, pady=5, padx=5)
tSubtotal3 = Entry(miFrame1, width=7, state="readonly",textvariable =
obtenerSubtotal2)
tSubtotal3.grid(row=12, column=5, pady=5, padx=5)
obtenerTotal = StringVar()
lTotal = Label(miFrame1, text='Total',font=("calibri", 12),bg= "#A4D8D4")

This study source was downloaded by 100000867250967 from CourseHero.com on 05-15-2023 13:59:15 GMT -05:00

https://www.coursehero.com/file/177296548/ferreteriapy/
lTotal.grid(row=12, column=6,sticky='ew', pady=5, padx=5)
tTotal = Entry(miFrame1, width=7, textvariable = obtenerTotal)
tTotal.grid(row=12, column=7, pady=5, padx=5)
guardar=Button(miFrame1, text='Calcular',font=("calibri", 15),bg= "#A4D8D4",
command=Operacion)
guardar.grid(row=13, column=5, pady=10, padx=10)
guardar=Button(miFrame1, text='Informacion',font=("calibri", 12),bg= "#A4D8D4",
command=Codigos)
guardar.grid(row=13, column=1, pady=5, padx=5)
guardar=Button(miFrame1, text='Limpiar', font=("calibri", 12),bg= "Yellow",
command= Clear)
guardar.grid(row=13, column=0, pady=5, padx=5)

root.mainloop()

This study source was downloaded by 100000867250967 from CourseHero.com on 05-15-2023 13:59:15 GMT -05:00

https://www.coursehero.com/file/177296548/ferreteriapy/
Powered by TCPDF (www.tcpdf.org)

También podría gustarte