Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- [enter image description here][1]import time
- from tkinter import messagebox
- import tkinter.ttk as ttk
- from sqlite3 import connect
- root=Tk()
- root.geometry("650x620")
- root.title("Factura")
- root.config(bg="light blue")
- #-----------------------StringVars------
- S=StringVar()
- Imp=StringVar()
- Total=StringVar()
- x2=StringVar()
- fac=StringVar()
- #------------------Lo Que Ya Viene-----------------
- a=Label(root, text="Clínica Odontológica Sonrisas",font=("Time",15))
- a.place(x=50, y=2)
- a.config(width=50)
- a.config(bg="light blue")
- a1=Label(root, text="Frente a la gasolinera UNO, Boulevard Cuarto Centenario",font=("Time",11))
- a1.place(x=175, y=35)
- a1.config(bg="light blue")
- a2=Entry(root, textvariable=fac,font=("Time",9))
- a2.place(x=500, y=65)
- a3=Label(root, text="RTN Emp:08011982312150",font=("Time",9))
- a3.place(x=500, y=90)
- a3.config(bg="light blue")
- a4=Label(root, text="Tel Emp:27726842",font=("Time",9))
- a4.place(x=509, y=115)
- a4.config(bg="light blue")
- #----------------- Introduzca / Cliente -------------------
- fecha6=StringVar()
- a6=Label(root, text="Fecha",font=("Time",8))
- a6.place(x=20, y=68)
- a6.config(width=15)
- fecha6.set(time.strftime("%d/%m/%y %I:%M%p"))
- Fechafecha=Entry(root,textvariable=fecha6)
- Fechafecha.config(width=16)
- Fechafecha.place(x=130,y=70)
- a7=Label(root, text="Cliente",font=("Time",8))
- a7.place(x=250, y=68)
- a7.config(width=15)
- aa7=Entry(root)
- aa7.place(x=355, y=69)
- aa7.config(width=16)
- a8=Label(root, text="RTN Cliente",font=("Time",8))
- a8.place(x=20, y=99)
- a8.config(width=15)
- aa8=Entry(root)
- aa8.place(x=130, y=101)
- aa8.config(width=16)
- a9=Label(root, text="Telefono Cliente",font=("Time",8))
- a9.place(x=250, y=99)
- a9.config(width=15)
- aa9=Entry(root)
- aa9.place(x=355, y=101)
- aa9.config(width=16)
- a10=Label(root, text="Direccion Cliente",font=("Time",8))
- a10.place(x=20, y=128)
- a10.config(width=15)
- aa10=Entry(root)
- aa10.place(x=130, y=130)
- aa10.config(width=26)
- #----------------- Introduzca / Producto -----------------
- dc=Label(root, text="__________________Datos Compra__________________ ",font=("Time",8))
- dc.place(x=170, y=155)
- dc.config(bg="light blue")
- a11=Label(root, text="Codigo Producto",font=("Time",8))
- a11.place(x=20, y=185)
- a11.config(width=15)
- aa11=Entry(root)
- aa11.place(x=130, y=187)
- aa11.config(width=16)
- a12=Label(root, text="Descripcion",font=("Time",8))
- a12.place(x=250, y=185)
- a12.config(width=15)
- aa12=Entry(root)
- aa12.place(x=357, y=186)
- aa12.config(width=30)
- a13=Label(root, text="Cantidad",font=("Time",8))
- a13.place(x=20, y=215)
- a13.config(width=15)
- aa13=Entry(root)
- aa13.place(x=130, y=216)
- aa13.config(width=12)
- a14=Label(root, text="Precio",font=("Time",8))
- a14.place(x=230, y=215)
- a14.config(width=15)
- aa14=Entry(root)
- aa14.place(x=337, y=216)
- aa14.config(width=13)
- a16=Label(root, text="Sub Total",font=("Time",9))
- a16.place(x=150, y=265)
- a16.config(width=15)
- aa16=Entry(root,textvariable=S)
- aa16.place(x=275, y=267)
- aa16.config(width=16)
- a17=Label(root, text="Impuesto: 15%",font=("Time",12))
- a17.place(x=470, y=520)
- a17=Label(root, text="Total",font=("Time",9))
- a17.place(x=430, y=560)
- a17.config(width=15)
- aa17=Entry(root,textvariable=Total)
- aa17.place(x=550, y=560)
- aa17.config(width=12)
- #-------------------Boton Salida----------------
- def salir():
- root.destroy()
- BotonSalida=Button(root,text="Salida",command=salir,font=("Time",13))
- BotonSalida.place(x=170,y=551)
- BotonSalida.config(width=10)
- #-----Cuadro de los productos----
- scrollbary=StringVar()
- scrollbary= Scrollbar(root, orient=VERTICAL)
- scrollbary.place(x=620,y=400)
- productos= ttk.Treeview(root, columns=("Nombre", "Cantidad", "Precio","Total"), selectmode="extended", height=7,yscrollcommand=scrollbary.set)
- scrollbary.config(command=productos.yview)
- productos.heading('Nombre', text="Nombre",anchor=W)
- productos.heading('Cantidad', text="Cantidad",anchor=W)
- productos.heading('Precio', text="Precio",anchor=W)
- productos.heading('Total', text="Total",anchor=W)
- productos.column('#0', stretch=NO, minwidth=0, width=0)
- productos.column('#1', stretch=NO, minwidth=0, width=200)
- productos.column('#2', stretch=NO, minwidth=0, width=120)
- productos.column('#3', stretch=NO, minwidth=0, width=120)
- productos.column('#4', stretch=NO, minwidth=0, width=120)
- productos.place(x=45,y=340)
- #-----------------Hola1--------
- def Ingresar():
- global detalles
- detalles.append((aa12.get(),aa13.get(),float(aa14.get())))
- productos.insert('', 'end', values=(aa12.get(),aa13.get(),int(aa14.get()),int(aa13.get())*float(aa14.get())))
- try:
- S.set(round((float(S.get())+(int(aa13.get())*float(aa14.get()))),2))
- except:
- S.set(round((int(aa13.get())*float(aa14.get())),2))
- Imp.set(round(float(S.get())*0.15,2))
- Total.set(round(float(aa16.get())+float(Imp.get())))
- aa12.set("")
- aa13.set("")
- aa14.set("")
- #--------
- def base_de_datos():
- global conexion, cursor, detalles
- detalles=[]
- base_de_datos()
- BotonSub=Button(root,text="Calcular",command=Ingresar,font=("Time",10))
- BotonSub.place(x=425,y=265)
- BotonSub.config(width=18)
- #------------Guardar-----------
- def Guardar():
- MiCon=connect("Facturas")
- MiCur=MiCon.cursor()
- MiCur.execute("INSERT INTO FACTURAS VALUES(NULL, '" + x2.get() +
- "','" + aa7.get() +
- "','" + aa8.get() +
- "','" + aa10.get() +
- "','" + aa9.get() +
- "','" + aa12.get() +
- "','" + aa13.get() +
- "','" + aa14.get() +
- "','" + Fechafecha.get() +
- "','" + aa16.get() +
- "','" + Total.get() + "')")
- MiCon.commit()
- messagebox.showinfo("Guardar", "La factura fue guardada con éxito.")
- BotonSub=Button(root,text="Guardar",command=Guardar,font=("Time",10))
- BotonSub.place(x=30,y=555)
- BotonSub.config(width=12)
- mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement