PROGRAMAS INTERFACES GRÁFICOS -CONEXIÓN MONGO ALMACENAMIENTO DE DATOS .
Programa cajero comercial
El siguiente programa tiene la función de contar la cantidad de billetes y monedas que hay en un corte de caja y al final muestra el total de la cantidad
Utilizando la base de datos mongodb para guardar la información y también agregamos que muestre la fecha de acuerdo a la hora de la maquina actual
Dentro de la base de datos Store: esta la colección: corte_dia
CÓDIGO:
from Tkinter import *
import tkMessageBox
from pymongo import MongoClient
def SumMul():
try:
_e0= int(v0.get())
_e0=_e0*.50
_e1 = int(v1.get())
_e1 = _e1 * 1
_e2 = int(v2.get())
_e2 = _e2 * 2
_e3 = int(v3.get())
_e3 = _e3 * 5
_e4 = int(v4.get())
_e4 = _e4 * 10
_e5 = int(v5.get())
_e5 = _e5 * 20
_e6 = int(v6.get())
_e6 = _e6 * 50
_e7 = int(v7.get())
_e7 = _e7 * 100
_e8 = int(v8.get())
_e8 = _e8 * 200
_e9 = int(v9.get())
_e9 = _e9 * 500
_e10= _e0 + _e1 + _e2 + _e3 + _e4 + _e5 + _e6 + _e7 + _e8 + _e9
tkMessageBox.showinfo("El resultado es", _e10)
conexion(_e0,_e1,_e2,_e3,_e4,_e5,_e6,_e7,_e8,_e9,_e10)
except ValueError:
tkMessageBox.showerror("Introduce un numero entero")
def conexion(_e0,_e1,_e2,_e3,_e4,_e5,_e6,_e7,_e8,_e9,_e10):
client = MongoClient('localhost', 27017)
db = client['store'] # me conecto con la bd store
# collection = db['empleados']
document = {"Moneda_50":_e0 , "Moneda_1": _e1, "Moneda_5": _e2,
"Moneda_10": _e4, "Monedo_20":_e5, "Billete_50": _e6,
"Billete_100":_e7, "Billete_200":_e8, "Billete_500":_e9,
"Total_dia:":_e10}
_id = db['corte_dia'].insert(document)
print _id
return
v=Tk()
v.title("")
v.geometry("200x450")
vp = Frame(v)
vp.grid(column=0, row=0, padx=(50,50), pady=(10,10))
vp.columnconfigure(0, weight=1)
vp.rowconfigure(0, weight =1)
ET0=Label(vp,text="MONEDAS")
ET0.grid(column=2, row=1)
e0=Label(vp,text="0.50")
e0.grid(column=1, row=3)
e1=Label(vp,text="1.00")
e1.grid(column=1, row=4)
e2=Label(vp,text="2.00")
e2.grid(column=1, row=5)
e3=Label(vp,text="5.00")
e3.grid(column=1, row=6)
e3=Label(vp,text="10.00")
e3.grid(column=1, row=7)
v0 = ""
v0 = Entry(vp, width=5, textvariable=v0)
v0.grid(row=3, column=2)
v1 = ""
v1 = Entry(vp, width=5, textvariable=v1)
v1.grid(row=4, column=2)
v2 = ""
v2 = Entry(vp, width=5, textvariable=v2)
v2.grid(row=5, column=2)
v3 = ""
v3 = Entry(vp, width=5, textvariable=v3)
v3.grid(row=6, column=2)
v4 = ""
v4 = Entry(vp, width=5, textvariable=v4)
v4.grid(row=7, column=2)
ET1=Label(vp,text="BILLETES")
ET1.grid(column=2, row=9)
e4=Label(vp,text="20.00")
e4.grid(column=1, row=11)
e5=Label(vp,text="50.00")
e5.grid(column=1, row=12)
e6=Label(vp,text="100.00")
e6.grid(column=1, row=13)
e7=Label(vp,text="200.00")
e7.grid(column=1, row=14)
e8=Label(vp,text="500.00")
e8.grid(column=1, row=15)
v5 = ""
v5 = Entry(vp, width=5, textvariable=v5)
v5.grid(row=11, column=2)
v6 = ""
v6 = Entry(vp, width=5, textvariable=v6)
v6.grid(row=12, column=2)
v7 = ""
v7 = Entry(vp, width=5, textvariable=v7)
v7.grid(row=13, column=2)
v8 = ""
v8 = Entry(vp, width=5, textvariable=v8)
v8.grid(row=14, column=2)
v9 = ""
v9 = Entry(vp, width=5, textvariable=v9)
v9.grid(row=15, column=2)
b = Button(vp, text="TOTAL", command=SumMul)
b.grid(row=17, column=2, padx=(20, 20), pady=(20, 20))
bc = Button(vp, text="Conectar BD", command=conexion)
bc.grid(row=19, column=2, padx=(20, 20), pady=(20, 20))
v.mainloop()
PROGRAMA PIZZERIA -CONEXION MONGO , ETIQUETAS,LISTBOX,FECHA,BD,OPCIONES
Programa cajero comercial
El siguiente programa tiene la función de contar la cantidad de billetes y monedas que hay en un corte de caja y al final muestra el total de la cantidad
Utilizando la base de datos mongodb para guardar la información y también agregamos que muestre la fecha de acuerdo a la hora de la maquina actual
Dentro de la base de datos Store: esta la colección: corte_dia
CÓDIGO:
from Tkinter import *
import tkMessageBox
from pymongo import MongoClient
def SumMul():
try:
_e0= int(v0.get())
_e0=_e0*.50
_e1 = int(v1.get())
_e1 = _e1 * 1
_e2 = int(v2.get())
_e2 = _e2 * 2
_e3 = int(v3.get())
_e3 = _e3 * 5
_e4 = int(v4.get())
_e4 = _e4 * 10
_e5 = int(v5.get())
_e5 = _e5 * 20
_e6 = int(v6.get())
_e6 = _e6 * 50
_e7 = int(v7.get())
_e7 = _e7 * 100
_e8 = int(v8.get())
_e8 = _e8 * 200
_e9 = int(v9.get())
_e9 = _e9 * 500
_e10= _e0 + _e1 + _e2 + _e3 + _e4 + _e5 + _e6 + _e7 + _e8 + _e9
tkMessageBox.showinfo("El resultado es", _e10)
conexion(_e0,_e1,_e2,_e3,_e4,_e5,_e6,_e7,_e8,_e9,_e10)
except ValueError:
tkMessageBox.showerror("Introduce un numero entero")
def conexion(_e0,_e1,_e2,_e3,_e4,_e5,_e6,_e7,_e8,_e9,_e10):
client = MongoClient('localhost', 27017)
db = client['store'] # me conecto con la bd store
# collection = db['empleados']
document = {"Moneda_50":_e0 , "Moneda_1": _e1, "Moneda_5": _e2,
"Moneda_10": _e4, "Monedo_20":_e5, "Billete_50": _e6,
"Billete_100":_e7, "Billete_200":_e8, "Billete_500":_e9,
"Total_dia:":_e10}
_id = db['corte_dia'].insert(document)
print _id
return
v=Tk()
v.title("")
v.geometry("200x450")
vp = Frame(v)
vp.grid(column=0, row=0, padx=(50,50), pady=(10,10))
vp.columnconfigure(0, weight=1)
vp.rowconfigure(0, weight =1)
ET0=Label(vp,text="MONEDAS")
ET0.grid(column=2, row=1)
e0=Label(vp,text="0.50")
e0.grid(column=1, row=3)
e1=Label(vp,text="1.00")
e1.grid(column=1, row=4)
e2=Label(vp,text="2.00")
e2.grid(column=1, row=5)
e3=Label(vp,text="5.00")
e3.grid(column=1, row=6)
e3=Label(vp,text="10.00")
e3.grid(column=1, row=7)
v0 = ""
v0 = Entry(vp, width=5, textvariable=v0)
v0.grid(row=3, column=2)
v1 = ""
v1 = Entry(vp, width=5, textvariable=v1)
v1.grid(row=4, column=2)
v2 = ""
v2 = Entry(vp, width=5, textvariable=v2)
v2.grid(row=5, column=2)
v3 = ""
v3 = Entry(vp, width=5, textvariable=v3)
v3.grid(row=6, column=2)
v4 = ""
v4 = Entry(vp, width=5, textvariable=v4)
v4.grid(row=7, column=2)
ET1=Label(vp,text="BILLETES")
ET1.grid(column=2, row=9)
e4=Label(vp,text="20.00")
e4.grid(column=1, row=11)
e5=Label(vp,text="50.00")
e5.grid(column=1, row=12)
e6=Label(vp,text="100.00")
e6.grid(column=1, row=13)
e7=Label(vp,text="200.00")
e7.grid(column=1, row=14)
e8=Label(vp,text="500.00")
e8.grid(column=1, row=15)
v5 = ""
v5 = Entry(vp, width=5, textvariable=v5)
v5.grid(row=11, column=2)
v6 = ""
v6 = Entry(vp, width=5, textvariable=v6)
v6.grid(row=12, column=2)
v7 = ""
v7 = Entry(vp, width=5, textvariable=v7)
v7.grid(row=13, column=2)
v8 = ""
v8 = Entry(vp, width=5, textvariable=v8)
v8.grid(row=14, column=2)
v9 = ""
v9 = Entry(vp, width=5, textvariable=v9)
v9.grid(row=15, column=2)
b = Button(vp, text="TOTAL", command=SumMul)
b.grid(row=17, column=2, padx=(20, 20), pady=(20, 20))
bc = Button(vp, text="Conectar BD", command=conexion)
bc.grid(row=19, column=2, padx=(20, 20), pady=(20, 20))
v.mainloop()
CÓDIGO DE PROGRAMA ///
from Tkinter import *import tkMessageBox
from Tkinter import *import tkMessageBox
from Tkinter import OptionMenu
from pymongo import MongoClient
import datetime
global numeropizza,cargo,total,finalconcargos,fecha
format= "%d/%m/%Y"today = datetime.date.today()
fecha=today.strftime(format)
ventana = Tk()
ventana.title("Pizzeria MRJ")
ventana = Canvas(width = 100, height = 130, bg = 'black')
ventana.pack(expand = YES, fill = BOTH)
banner1 = PhotoImage(file = "C:/Users/mario/Pictures/imagen2/piz.gif")
ventana.create_image(10, 10, image = banner1, anchor = NW)
vp = Frame(ventana)
vp.config(bg="red4")
vp.grid(column=0, row=0, padx=(100, 100), pady=(100, 100))
vp.rowconfigure(0, weight=1)
Fecha=Label(vp,text="Fecha de Corte")
Fecha.grid(column=0, row=7)
Fecha.config(background="SkyBlue",foreground="black")
FechaEntry = " "FechaEntry = Entry(vp, width=10, textvariable=FechaEntry)
FechaEntry.grid(row=8, column=0)
FechaEntry.config(background="SkyBlue",foreground="black")
FechaEntry.insert(0, fecha)
print fecha
tipo = StringVar(vp)
tipo.set("...")
cantidad = StringVar(vp)
cantidad.set("...")
pago = StringVar(vp)
pago.set("...")
etiqueta_tipo = Label(vp, text='Tipo de Pizza a Seleccionar : ')
etiqueta_tipo.config(background="pale violet red",foreground="black")
ent_tipo = OptionMenu(vp, tipo, "Peperoni", "Hawahiana", "3 Carnes","Paquete Familiar y Refresco")
etiqueta_tipo.grid(row=1, column=1, padx=(10, 10), pady=(10, 10), sticky=W)
ent_tipo.grid(row=1, column=0)
ent_tipo.config(background="dark orange",foreground="black")
print ent_tipo
etiqueta_cantidad =Label(vp, text='Cantidad a Ordenar: ')
etiqueta_cantidad.config(background="pale violet red",foreground="black")
ent_numero = OptionMenu(vp, cantidad, "1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
etiqueta_cantidad.grid(row=4, column=1, padx=(10, 10), pady=(10, 10), sticky=W)
ent_numero.grid(row=4, column=0)
ent_numero.config(background="dark orange",foreground="black")
etiqueta_pago =Label(vp, text='Forma de pago: ')
etiqueta_pago.config(background="pale violet red",foreground="black")
ent_pago =OptionMenu(vp, pago, "Efectivo", "Tarjeta","Cupon Peperoni 20%")
etiqueta_pago.grid(row=6, column=1, padx=(10, 10), pady=(10, 10), sticky=W)
ent_pago.grid(row=6, column=0)
ent_pago.config(background="dark orange",foreground="black")
def Conexion(numeropizza,cargo,total,final): client = MongoClient('localhost',27017)
db = client['pizza']
document = {'numero_pizzas':numeropizza,'pago_tarjeta':cargo,'pago_efectivo':total,'pago_finalcontarjeta':final,"Fecha_dia":fecha }
_id= db['registro'].insert(document)
def calcular(): pizza = str(tipo.get())
numeropizza = int(cantidad.get())
dinero = str(pago.get())
if pizza == "Peperoni" and numeropizza > 0 and dinero == "Tarjeta": total = numeropizza * 89 cargo = total * 0.08 finalconcargos = total + cargo
tkMessageBox.showinfo("[Pizza de Peperoni : Pago con Tarjeta], su total es de: " ,finalconcargos)
print numeropizza
print cargo
print total
print finalconcargos
elif pizza == "Peperoni" and numeropizza > 0 and dinero == "Cupon Peperoni 20%": total = numeropizza * 89 cargo = total * 0.20 finalconcargos = total - cargo
tkMessageBox.showinfo("[Pizza Peperoni : Descuento de Cupon ], su total es de: " ,finalconcargos)
print numeropizza
print cargo
print total
print finalconcargos
elif pizza == "Peperoni" and numeropizza > 0 and dinero == "Efectivo": total = numeropizza * 89 cargo = 0 finalconcargos = 0 tkMessageBox.showinfo("[Pizza de Peperoni : Pago con Efectivo], su total es de: ", total)
print numeropizza
print cargo
print total
print finalconcargos
elif pizza == "Hawahiana" and numeropizza > 0 and dinero == "Tarjeta": total = numeropizza * 100 cargo = total * 0.08 finalconcargos = total + cargo
tkMessageBox.showinfo("[Pizza Hawahiana : Pago con Tarjeta], su total es de: " ,finalconcargos)
print numeropizza
print cargo
print total
print finalconcargos
elif pizza == "Hawahiana" and numeropizza > 0 and dinero == "Efectivo": total = numeropizza * 100 cargo = 0 finalconcargos = 0 tkMessageBox.showinfo("[Pizza Hawahiana : Pago con Efectivo], su total es de: " , total)
print numeropizza
print cargo
print total
print finalconcargos
elif pizza == "3 Carnes" and numeropizza > 0 and dinero == "Tarjeta": total = numeropizza * 120 cargo = total * 0.05 finalconcargos = total + cargo
tkMessageBox.showinfo("[Pizza de 3 Carnes : Pago con Tarjeta], su total es de: " ,finalconcargos)
print numeropizza
print cargo
print total
print finalconcargos
elif pizza == "3 Carnes" and numeropizza > 0 and dinero == "Efectivo": total = numeropizza * 120 cargo = 0 finalconcargos = 0 tkMessageBox.showinfo("[Pizza de 3 carnes : Pago con Efectivo], su total es de: " ,total)
print numeropizza
print cargo
print total
print finalconcargos
elif pizza == "Paquete Familiar y Refresco" and numeropizza > 0 and dinero == "Tarjeta": total = numeropizza * 120 cargo = total * 0.08 finalconcargos = total + cargo
tkMessageBox.showinfo("[Paquete Familiar y Refresco : Pago con Tarjeta], su total es de: ", finalconcargos)
print numeropizza
print cargo
print total
print finalconcargos
elif pizza == "Paquete Familiar y Refresco" and numeropizza > 0 and dinero == "Efectivo": total = numeropizza * 300 cargo = 0 finalconcargos = 0 tkMessageBox.showinfo("[Paquete Familiar y Refresco: Pago con Efectivo], su total es de: ", total)
print numeropizza
print cargo
print total
print finalconcargos
Conexion(numeropizza, cargo, total, finalconcargos)
boton = Button(vp, text='Total a Facturar', command=calcular, width=20)
boton.grid(row=8, column=1, padx=(10, 10), pady=(10, 10), sticky=N)
boton.config(background="goldenrod",foreground="black")
ventana.mainloop()
PROGRAMA CAMIÓN DE VIAJES (Caja de texto,boton,etiquetas,imagen,gif,mensajebox , operaciones.
from Tkinter import *
import tkMessageBox
from tkMessageBox import *
ventana = Tk()
ventana.title("Camion de Viajes ")
ventana = Canvas(width=650, height=410, bg = 'white')
ventana.pack(expand = YES, fill = BOTH)
gif1 = PhotoImage(file = 'C:/Users/mr. robot/Desktop/1.gif')
ventana.create_image(452, 1, image = gif1, anchor = NW)
#ETIQUETAS
e1 = Label(ventana, text="Camion 1",font=('Blackside',40),background="white", foreground="blue").place(x=10, y=65)
et1 = Label(ventana, text="Cantidad de pasajeros",font=('Console',12)).place(x=100, y=180)
#ENTRADA DE CANTIDAD
ent1 = " "
ent1 = Entry(ventana, width=15, textvariable=ent1)
ent1.place(x=300, y=180)
#CALCULAR TOTAL A PAGAR
def calcular():
cantidad = int(ent1.get())
total=0
if cantidad>=100:
total=cantidad*65
tkMessageBox.showinfo("Total", "Cada pasajero pagara 65 y el autobus costara " + str(total))
elif cantidad>=50 and cantidad<=99:
total = cantidad *70
tkMessageBox.showinfo("Total", "Cada pasajero pagara 70 y el autobus costara " + str(total))
elif cantidad>=30 and cantidad<=49:
total = cantidad * 95
tkMessageBox.showinfo("Total", "Cada pasajero pagara 95 y el autobus costara " + str(total))
elif cantidad<30:
tkMessageBox.showinfo("Total", "El camion se cobra a 4,000")
b1=Button(ventana, text='Calcular', command=calcular,font=('Arial',10)).place(x=400, y=180)
ventana.mainloop()

PROGRAMA CAMIÓN DE VIAJES (Caja de texto,boton,etiquetas,imagen,gif,mensajebox , operaciones.
from Tkinter import *
import tkMessageBox
from tkMessageBox import *
ventana = Tk()
ventana.title("Camion de Viajes ")
ventana = Canvas(width=650, height=410, bg = 'white')
ventana.pack(expand = YES, fill = BOTH)
gif1 = PhotoImage(file = 'C:/Users/mr. robot/Desktop/1.gif')
ventana.create_image(452, 1, image = gif1, anchor = NW)
#ETIQUETAS
e1 = Label(ventana, text="Camion 1",font=('Blackside',40),background="white", foreground="blue").place(x=10, y=65)
et1 = Label(ventana, text="Cantidad de pasajeros",font=('Console',12)).place(x=100, y=180)
#ENTRADA DE CANTIDAD
ent1 = " "
ent1 = Entry(ventana, width=15, textvariable=ent1)
ent1.place(x=300, y=180)
#CALCULAR TOTAL A PAGAR
def calcular():
cantidad = int(ent1.get())
total=0
if cantidad>=100:
total=cantidad*65
tkMessageBox.showinfo("Total", "Cada pasajero pagara 65 y el autobus costara " + str(total))
elif cantidad>=50 and cantidad<=99:
total = cantidad *70
tkMessageBox.showinfo("Total", "Cada pasajero pagara 70 y el autobus costara " + str(total))
elif cantidad>=30 and cantidad<=49:
total = cantidad * 95
tkMessageBox.showinfo("Total", "Cada pasajero pagara 95 y el autobus costara " + str(total))
elif cantidad<30:
tkMessageBox.showinfo("Total", "El camion se cobra a 4,000")
b1=Button(ventana, text='Calcular', command=calcular,font=('Arial',10)).place(x=400, y=180)
ventana.mainloop()
PROGRAMA CALCULADORA
El programa consta de una interfaz gráfica donde puedes realizar operaciones matematicas basicas de una calculadora +,-,x.Etiquetas ,cajas de texto, botones
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from Tkinter import *
def sumar():
try:
_valor1 = int(entrada_texto.get())
_valor2 = int(entrada2_texto.get())
_valor = _valor1+_valor2
etiqueta3.config(text=_valor)
except ValueError:
etiqueta3.config(text="Introduce un numero")
def restar():
try:
_valor1 = int(entrada_texto.get())
_valor2 = int(entrada2_texto.get())
_valor = _valor1 - _valor2
etiqueta4.config(text=_valor)
except ValueError:
etiqueta4.config(text="Introduce un numero")
def multiplicar():
try:
_valor1 = int(entrada_texto.get())
_valor2 = int(entrada2_texto.get())
_valor = _valor1 * _valor2
etiqueta5.config(text=_valor)
except ValueError:
etiqueta5.config(text="Introduce un numero")
app = Tk()
app.title("Operaciones")
# Ventana Principal
vp = Frame(app)
vp.grid(column=0, row=0, padx=(50, 50), pady=(10, 10))
vp.columnconfigure(0, weight=1)
vp.rowconfigure(0, weight=1)
etiqueta = Label(vp, text="Numero 1")
etiqueta.grid(column=1, row=1, sticky=(W, E))
etiqueta2 = Label(vp, text="Numero 2")
etiqueta2.grid(column=3, row=1, sticky=(W, E))
etiqueta3= Label(vp, text="suma")
etiqueta3.grid(column=1, row=5, sticky=(W, E))
etiqueta4= Label(vp, text="resta")
etiqueta4.grid(column=2, row=5, sticky=(W, E))
etiqueta5= Label(vp, text="multiplicacion")
etiqueta5.grid(column=3, row=5, sticky=(W, E))
boton = Button(vp, text="sumar", command=sumar)
boton.grid(column=1, row=4)
boton2 = Button(vp, text="restar", command=restar)
boton2.grid(column=2, row=4)
boton3= Button(vp, text="multiplicar", command=multiplicar)
boton3.grid(column=3, row=4)
valor = ""
entrada_texto = Entry(vp, width=10, textvariable=valor)
entrada_texto.grid(column=2, row=1)
valor2 = ""
entrada2_texto = Entry(vp, width=10, textvariable=valor2)
entrada2_texto.grid(column=4, row=1)
app.mainloop()
PROGRAMA AGENDA FORMULARIO
from Tkinter import * root = Tk() root.title('formulario 1') # row 1 : the name nombre_label = Label(root,text="Nombre :") nombre_label.grid(row=1,column=1) nombre_str = StringVar() nombre_entry = Entry(root,textvariable=nombre_str) nombre_entry.grid(row=1,column=2) #row 2 : the last name last_label= Label(root,text="Apellido : ") last_label.grid(row=2,column=1) last_str = StringVar() last_entry = Entry(root,textvariable=last_str) last_entry.grid(row=2,column=2) #row 3 : the email mail_label = Label(root,text="Email : ") mail_label.grid(row=3,column=1) mail_str = StringVar() mail_entry = Entry(root,textvariable=mail_str) mail_entry.grid(row=3,column=2) #row 4 : end finish = Button(root,text="finalizar",relief=FLAT) finish.grid(row=4,column=2) root.mainloop()
Comentarios
Publicar un comentario