Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.71 KB | None | 0 0
  1. from tkinter import *
  2. [enter image description here][1]import time
  3. from tkinter import messagebox
  4. import tkinter.ttk as ttk
  5. from sqlite3 import connect
  6.  
  7.  
  8. root=Tk()
  9. root.geometry("650x620")
  10. root.title("Factura")
  11. root.config(bg="light blue")
  12.  
  13.  
  14. #-----------------------StringVars------
  15.  
  16. S=StringVar()
  17. Imp=StringVar()
  18. Total=StringVar()
  19. x2=StringVar()
  20. fac=StringVar()
  21.  
  22. #------------------Lo Que Ya Viene-----------------
  23.  
  24. a=Label(root, text="Clínica Odontológica Sonrisas",font=("Time",15))
  25. a.place(x=50, y=2)
  26. a.config(width=50)
  27. a.config(bg="light blue")
  28.  
  29. a1=Label(root, text="Frente a la gasolinera UNO, Boulevard Cuarto Centenario",font=("Time",11))
  30. a1.place(x=175, y=35)
  31. a1.config(bg="light blue")
  32.  
  33. a2=Entry(root, textvariable=fac,font=("Time",9))
  34. a2.place(x=500, y=65)
  35.  
  36.  
  37. a3=Label(root, text="RTN Emp:08011982312150",font=("Time",9))
  38. a3.place(x=500, y=90)
  39. a3.config(bg="light blue")
  40.  
  41.  
  42. a4=Label(root, text="Tel Emp:27726842",font=("Time",9))
  43. a4.place(x=509, y=115)
  44. a4.config(bg="light blue")
  45.  
  46.  
  47.  
  48. #----------------- Introduzca / Cliente -------------------
  49.  
  50. fecha6=StringVar()
  51.  
  52. a6=Label(root, text="Fecha",font=("Time",8))
  53. a6.place(x=20, y=68)
  54. a6.config(width=15)
  55.  
  56. fecha6.set(time.strftime("%d/%m/%y %I:%M%p"))
  57. Fechafecha=Entry(root,textvariable=fecha6)
  58. Fechafecha.config(width=16)
  59. Fechafecha.place(x=130,y=70)
  60.  
  61. a7=Label(root, text="Cliente",font=("Time",8))
  62. a7.place(x=250, y=68)
  63. a7.config(width=15)
  64.  
  65. aa7=Entry(root)
  66. aa7.place(x=355, y=69)
  67. aa7.config(width=16)
  68.  
  69. a8=Label(root, text="RTN Cliente",font=("Time",8))
  70. a8.place(x=20, y=99)
  71. a8.config(width=15)
  72.  
  73. aa8=Entry(root)
  74. aa8.place(x=130, y=101)
  75. aa8.config(width=16)
  76.  
  77. a9=Label(root, text="Telefono Cliente",font=("Time",8))
  78. a9.place(x=250, y=99)
  79. a9.config(width=15)
  80. aa9=Entry(root)
  81. aa9.place(x=355, y=101)
  82. aa9.config(width=16)
  83.  
  84. a10=Label(root, text="Direccion Cliente",font=("Time",8))
  85. a10.place(x=20, y=128)
  86. a10.config(width=15)
  87. aa10=Entry(root)
  88. aa10.place(x=130, y=130)
  89. aa10.config(width=26)
  90.  
  91. #----------------- Introduzca / Producto -----------------
  92.  
  93. dc=Label(root, text="__________________Datos Compra__________________ ",font=("Time",8))
  94. dc.place(x=170, y=155)
  95. dc.config(bg="light blue")
  96.  
  97. a11=Label(root, text="Codigo Producto",font=("Time",8))
  98. a11.place(x=20, y=185)
  99. a11.config(width=15)
  100. aa11=Entry(root)
  101. aa11.place(x=130, y=187)
  102. aa11.config(width=16)
  103.  
  104. a12=Label(root, text="Descripcion",font=("Time",8))
  105. a12.place(x=250, y=185)
  106. a12.config(width=15)
  107. aa12=Entry(root)
  108. aa12.place(x=357, y=186)
  109. aa12.config(width=30)
  110.  
  111. a13=Label(root, text="Cantidad",font=("Time",8))
  112. a13.place(x=20, y=215)
  113. a13.config(width=15)
  114. aa13=Entry(root)
  115. aa13.place(x=130, y=216)
  116. aa13.config(width=12)
  117.  
  118. a14=Label(root, text="Precio",font=("Time",8))
  119. a14.place(x=230, y=215)
  120. a14.config(width=15)
  121. aa14=Entry(root)
  122. aa14.place(x=337, y=216)
  123. aa14.config(width=13)
  124.  
  125.  
  126. a16=Label(root, text="Sub Total",font=("Time",9))
  127. a16.place(x=150, y=265)
  128. a16.config(width=15)
  129.  
  130. aa16=Entry(root,textvariable=S)
  131. aa16.place(x=275, y=267)
  132. aa16.config(width=16)
  133.  
  134. a17=Label(root, text="Impuesto: 15%",font=("Time",12))
  135. a17.place(x=470, y=520)
  136.  
  137. a17=Label(root, text="Total",font=("Time",9))
  138. a17.place(x=430, y=560)
  139. a17.config(width=15)
  140.  
  141. aa17=Entry(root,textvariable=Total)
  142. aa17.place(x=550, y=560)
  143. aa17.config(width=12)
  144.  
  145. #-------------------Boton Salida----------------
  146.  
  147. def salir():
  148. root.destroy()
  149.  
  150. BotonSalida=Button(root,text="Salida",command=salir,font=("Time",13))
  151. BotonSalida.place(x=170,y=551)
  152. BotonSalida.config(width=10)
  153.  
  154. #-----Cuadro de los productos----
  155.  
  156. scrollbary=StringVar()
  157.  
  158. scrollbary= Scrollbar(root, orient=VERTICAL)
  159. scrollbary.place(x=620,y=400)
  160.  
  161. productos= ttk.Treeview(root, columns=("Nombre", "Cantidad", "Precio","Total"), selectmode="extended", height=7,yscrollcommand=scrollbary.set)
  162. scrollbary.config(command=productos.yview)
  163. productos.heading('Nombre', text="Nombre",anchor=W)
  164. productos.heading('Cantidad', text="Cantidad",anchor=W)
  165. productos.heading('Precio', text="Precio",anchor=W)
  166. productos.heading('Total', text="Total",anchor=W)
  167. productos.column('#0', stretch=NO, minwidth=0, width=0)
  168. productos.column('#1', stretch=NO, minwidth=0, width=200)
  169. productos.column('#2', stretch=NO, minwidth=0, width=120)
  170. productos.column('#3', stretch=NO, minwidth=0, width=120)
  171. productos.column('#4', stretch=NO, minwidth=0, width=120)
  172.  
  173. productos.place(x=45,y=340)
  174.  
  175. #-----------------Hola1--------
  176.  
  177. def Ingresar():
  178. global detalles
  179. detalles.append((aa12.get(),aa13.get(),float(aa14.get())))
  180. productos.insert('', 'end', values=(aa12.get(),aa13.get(),int(aa14.get()),int(aa13.get())*float(aa14.get())))
  181. try:
  182. S.set(round((float(S.get())+(int(aa13.get())*float(aa14.get()))),2))
  183. except:
  184. S.set(round((int(aa13.get())*float(aa14.get())),2))
  185. Imp.set(round(float(S.get())*0.15,2))
  186. Total.set(round(float(aa16.get())+float(Imp.get())))
  187. aa12.set("")
  188. aa13.set("")
  189. aa14.set("")
  190.  
  191. #--------
  192.  
  193. def base_de_datos():
  194. global conexion, cursor, detalles
  195. detalles=[]
  196.  
  197. base_de_datos()
  198.  
  199. BotonSub=Button(root,text="Calcular",command=Ingresar,font=("Time",10))
  200. BotonSub.place(x=425,y=265)
  201. BotonSub.config(width=18)
  202.  
  203. #------------Guardar-----------
  204. def Guardar():
  205. MiCon=connect("Facturas")
  206. MiCur=MiCon.cursor()
  207. MiCur.execute("INSERT INTO FACTURAS VALUES(NULL, '" + x2.get() +
  208. "','" + aa7.get() +
  209. "','" + aa8.get() +
  210. "','" + aa10.get() +
  211. "','" + aa9.get() +
  212. "','" + aa12.get() +
  213. "','" + aa13.get() +
  214. "','" + aa14.get() +
  215. "','" + Fechafecha.get() +
  216. "','" + aa16.get() +
  217. "','" + Total.get() + "')")
  218. MiCon.commit()
  219. messagebox.showinfo("Guardar", "La factura fue guardada con éxito.")
  220.  
  221. BotonSub=Button(root,text="Guardar",command=Guardar,font=("Time",10))
  222. BotonSub.place(x=30,y=555)
  223. BotonSub.config(width=12)
  224.  
  225.  
  226. mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement