├── APP_DESKTOP ├── Buscador.py ├── __pycache__ │ └── Buscador.cpython-37.pyc └── main.py ├── CALCULADORA ├── calculadora.png └── calculadora.py ├── ENVIAR_EMAIL ├── enviar_email_smtlib.py └── logo_gmail.png ├── PROYECTO_TIENDA ├── img │ ├── app_logo_2.png │ ├── buscar.png │ ├── cliente.png │ ├── codigo.png │ ├── codigos.png │ ├── informacion.png │ ├── logo-tienda.png │ ├── nueva_venta.png │ ├── registrar.png │ └── ventas.png └── main.py ├── SISTEMA DESKTOP ├── 1-Formulario_registro.py ├── 2-Login.py ├── 3-Recuperar_password.py ├── 4-CRUD.py ├── 5-Buscador.py ├── Imagenes │ ├── app_logo.png │ ├── app_logo_2.png │ ├── arduino-logo.png │ ├── buscar.png │ ├── informacion.png │ ├── login.png │ ├── nodemcu-logo.png │ ├── nuevo_usuario.png │ ├── raspberry-logo.png │ ├── recuperar_contraseña.png │ └── registrar.png └── __pycache__ │ └── Formulario_registro.cpython-39.pyc ├── construcciónes rojas └── construcciónes rojas │ ├── bolseado.png │ ├── casa.ico │ ├── casa2.png │ ├── ceramica.png │ ├── enlucido.png │ ├── pared.png │ ├── piso.png │ ├── proyrcto final rojas version2.py │ ├── revoque.png │ └── techado.png ├── database_proyecto.db ├── tienda.db └── tienda_diaz.db /APP_DESKTOP/Buscador.py: -------------------------------------------------------------------------------- 1 | """ 2 | BUSCADOR-PRODUCTOS 3 | -Buscar Prouctos 4 | -Buscar en bd SQlite 5 | """ 6 | from tkinter import * 7 | from tkinter import ttk 8 | from tkinter import messagebox 9 | #Python image Library 10 | from PIL import ImageTk, Image 11 | import sqlite3 12 | 13 | 14 | class Producto(): 15 | db_name='database_proyecto.db' 16 | def __init__(self, ventana_producto): 17 | menubar=Menu(ventana_producto) 18 | ventana_producto.title("APLICACION") 19 | ventana_producto.geometry("769x660") 20 | ventana_producto.resizable(0,0) 21 | ventana_producto.config(bd=10,menu=menubar) 22 | 23 | "---------------------Menu---------------------------" 24 | Productos=Menu(menubar,tearoff=0) 25 | Ventas=Menu(menubar,tearoff=0) 26 | Reportes=Menu(menubar,tearoff=0) 27 | Informacion=Menu(menubar,tearoff=0) 28 | menubar.add_cascade(label="Productos",menu=Productos) 29 | menubar.add_cascade(label="Ventas",menu=Ventas) 30 | menubar.add_cascade(label="Reportes",menu=Reportes) 31 | menubar.add_cascade(label="Ayuda",menu=Informacion) 32 | #Iconos 33 | self.img_registrar=PhotoImage(file="D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/registrar.png") 34 | self.img_buscar=PhotoImage(file="D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/buscar.png") 35 | self.img_informacion=PhotoImage(file="D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/informacion.png") 36 | #Acciones de menu 37 | self.boton_registrar=Productos.add_command(label="Registrar",command= self.widgets_crud,image=self.img_registrar,compound=LEFT) 38 | self.boton_buscar=Productos.add_command(label="Buscar",command=self.widgets_buscador,image=self.img_buscar,compound=LEFT) 39 | self.boton_informacion=Informacion.add_command(label="Informacion del sistema",command=self.widgets_informacion,image=self.img_informacion,compound=LEFT) 40 | 41 | "---------------------Widgets---------------------------" 42 | #widgets crud 43 | self.Label_titulo_crud=LabelFrame(ventana_producto) 44 | self.frame_logo_productos = LabelFrame(ventana_producto) 45 | self.frame_registro = LabelFrame(ventana_producto, text="Informacion del producto",font=("Comic Sans", 10,"bold"),pady=5) 46 | self.frame_botones_registro=LabelFrame(ventana_producto) 47 | self.frame_tabla_crud=LabelFrame(ventana_producto) 48 | #widgets buscador 49 | self.Label_titulo_buscador=LabelFrame(ventana_producto) 50 | self.frame_buscar_producto = LabelFrame(ventana_producto, text="Buscar producto",font=("Comic Sans", 10,"bold"),pady=10) 51 | self.frame_boton_buscar=LabelFrame(ventana_producto) 52 | #widgets informacion 53 | self.Label_informacion = LabelFrame(ventana_producto) 54 | 55 | #Pantalla inicial 56 | self.widgets_crud() 57 | 58 | def widgets_crud(self): 59 | self.Label_titulo_crud.config(bd=0) 60 | self.Label_titulo_crud.grid(row=0,column=0,padx=5,pady=5) 61 | "--------------- Titulo --------------------" 62 | self.titulo_crud= Label(self.Label_titulo_crud, text="REGISTRO DE PRODUCTOS ELECTRONICOS",fg="black",font=("Comic Sans", 17,"bold")) 63 | self.titulo_crud.grid(row=0,column=0) 64 | 65 | "--------------- Logos productos --------------------" 66 | self.frame_logo_productos.config(bd=0) 67 | self.frame_logo_productos.grid(row=1,column=0,padx=5,pady=5) 68 | 69 | #Logo arduino 70 | imagen_arduino=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/arduino-logo.png") 71 | nueva_imagen=imagen_arduino.resize((60,60)) 72 | render=ImageTk.PhotoImage(nueva_imagen) 73 | label_imagen= Label(self.frame_logo_productos, image= render) 74 | label_imagen.image=render 75 | label_imagen.grid(row=0, column=0,padx=15,pady=5) 76 | 77 | #Logo nodemcu 78 | imagen_nodemcu=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/nodemcu-logo.png") 79 | nueva_imagen=imagen_nodemcu.resize((60,60)) 80 | render=ImageTk.PhotoImage(nueva_imagen) 81 | label_imagen= Label(self.frame_logo_productos, image= render) 82 | label_imagen.image=render 83 | label_imagen.grid(row=0, column=1,padx=15,pady=5) 84 | 85 | #Logo raspberry 86 | imagen_raspberry=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/raspberry-logo.png") 87 | nueva_imagen=imagen_raspberry.resize((60,60)) 88 | render=ImageTk.PhotoImage(nueva_imagen) 89 | label_imagen= Label(self.frame_logo_productos, image= render) 90 | label_imagen.image=render 91 | label_imagen.grid(row=0, column=2,padx=15,pady=5) 92 | 93 | "--------------- Frame marco --------------------" 94 | self.frame_registro.config(bd=2) 95 | self.frame_registro.grid(row=2,column=0,padx=5,pady=5) 96 | 97 | "--------------- Formulario --------------------" 98 | label_codigo=Label(self.frame_registro,text="Codigo del producto: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 99 | self.codigo=Entry(self.frame_registro,width=25) 100 | self.codigo.focus() 101 | self.codigo.grid(row=0, column=1, padx=5, pady=8) 102 | 103 | label_nombre=Label(self.frame_registro,text="Nombre del producto: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=5,pady=8) 104 | self.nombre=Entry(self.frame_registro,width=25) 105 | self.nombre.grid(row=1, column=1, padx=5, pady=8) 106 | 107 | label_categoria=Label(self.frame_registro,text="Categoria: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=5,pady=9) 108 | self.combo_categoria=ttk.Combobox(self.frame_registro,values=["Microcontrolador","Microordenador","Sensores","Accesorios"], width=22,state="readonly") 109 | self.combo_categoria.current(0) 110 | self.combo_categoria.grid(row=2,column=1,padx=5,pady=0) 111 | 112 | label_cantidad=Label(self.frame_registro,text="Cantidad: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=8) 113 | self.cantidad=Entry(self.frame_registro,width=25) 114 | self.cantidad.grid(row=0, column=3, padx=5, pady=8) 115 | 116 | label_precio=Label(self.frame_registro,text="Precio (S/.): ",font=("Comic Sans", 10,"bold")).grid(row=1,column=2,sticky='s',padx=5,pady=8) 117 | self.precio=Entry(self.frame_registro,width=25) 118 | self.precio.grid(row=1, column=3, padx=5, pady=8) 119 | 120 | label_descripcion=Label(self.frame_registro,text="Descripcion: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=2,sticky='s',padx=10,pady=8) 121 | self.descripcion=Entry(self.frame_registro,width=25) 122 | self.descripcion.grid(row=2, column=3, padx=10, pady=8) 123 | 124 | "--------------- Frame botones --------------------" 125 | self.frame_botones_registro.config(bd=0) 126 | self.frame_botones_registro.grid(row=3,column=0,padx=5,pady=5) 127 | 128 | "--------------- Botones --------------------" 129 | boton_registrar=Button(self.frame_botones_registro,text="REGISTRAR",command=self.Agregar_producto,height=2,width=12,bg="green",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=1, padx=10, pady=15) 130 | boton_editar=Button(self.frame_botones_registro,text="EDITAR",command=self.Editar_producto ,height=2,width=12,bg="gray",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=2, padx=10, pady=15) 131 | boton_eliminar=Button(self.frame_botones_registro,text="ELIMINAR",command=self.Eliminar_producto,height=2,width=12,bg="red",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=3, padx=10, pady=15) 132 | 133 | "--------------- Tabla --------------------" 134 | self.frame_tabla_crud.config(bd=2) 135 | self.frame_tabla_crud.grid(row=4,column=0,padx=5,pady=5) 136 | 137 | self.tree=ttk.Treeview(self.frame_tabla_crud,height=11, columns=("columna1","columna2","columna3","columna4","columna5")) 138 | self.tree.heading("#0",text='Codigo', anchor=CENTER) 139 | self.tree.column("#0", width=90, minwidth=75, stretch=NO) 140 | 141 | self.tree.heading("columna1",text='Nombre', anchor=CENTER) 142 | self.tree.column("columna1", width=150, minwidth=75, stretch=NO) 143 | 144 | self.tree.heading("columna2",text='Categoria', anchor=CENTER) 145 | self.tree.column("columna2", width=150, minwidth=75, stretch=NO) 146 | 147 | self.tree.heading("columna3",text='Cantidad', anchor=CENTER) 148 | self.tree.column("columna3", width=70, minwidth=60, stretch=NO) 149 | 150 | self.tree.heading("columna4",text='Precio', anchor=CENTER) 151 | self.tree.column("columna4", width=70, minwidth=60, stretch=NO) 152 | 153 | self.tree.heading("columna5",text='Descripcion', anchor=CENTER) 154 | 155 | self.tree.grid(row=0,column=0,sticky=E) 156 | 157 | self.Obtener_productos() 158 | 159 | #REMOVER OTROS WIDGETS 160 | self.widgets_buscador_remove() 161 | self.Label_informacion.grid_remove() 162 | 163 | def widgets_buscador(self): 164 | self.Label_titulo_buscador.config(bd=0) 165 | self.Label_titulo_buscador.grid(row=0,column=0,padx=5,pady=5) 166 | 167 | "--------------- Titulo --------------------" 168 | self.titulo_buscador= Label(self.Label_titulo_buscador, text="BUSCADOR DE PRODUCTOS ELECTRONICOS",fg="black",font=("Comic Sans", 17,"bold")) 169 | self.titulo_buscador.grid(row=0,column=0) 170 | 171 | "--------------- Frame buscar --------------------" 172 | self.frame_buscar_producto.config(bd=2) 173 | self.frame_buscar_producto.grid(row=2,column=0,padx=5,pady=5) 174 | 175 | "--------------- Formulario Buscar--------------------" 176 | self.label_buscar=Label(self.frame_buscar_producto,text="Buscar Por: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=5) 177 | self.combo_buscar=ttk.Combobox(self.frame_buscar_producto,values=["Codigo","Nombre"], width=22,state="readonly") 178 | self.combo_buscar.current(0) 179 | self.combo_buscar.grid(row=0,column=1,padx=5,pady=5) 180 | 181 | label_codigo_codigo=Label(self.frame_buscar_producto,text="Codigo / Nombre del producto: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=5) 182 | self.codigo_nombre=Entry(self.frame_buscar_producto,width=25) 183 | self.codigo_nombre.focus() 184 | self.codigo_nombre.grid(row=0, column=3, padx=10, pady=5) 185 | 186 | "--------------- Frame marco --------------------" 187 | self.frame_boton_buscar.config(bd=0) 188 | self.frame_boton_buscar.grid(row=3,column=0,padx=5,pady=5) 189 | "--------------- Boton --------------------" 190 | self.boton_buscar=Button(self.frame_boton_buscar,text="BUSCAR",command=self.Buscar_productos,height=2,width=20,bg="black",fg="white",font=("Comic Sans", 10,"bold")) 191 | self.boton_buscar.grid(row=0,column=0,padx=5,pady=5) 192 | 193 | self.tree.delete(*self.tree.get_children()) 194 | 195 | #REMOVER OTROS WIDGETS 196 | self.widgets_crud_remove() 197 | self.Label_informacion.grid_remove() 198 | 199 | def widgets_crud_remove(self): 200 | self.Label_titulo_crud.grid_remove() 201 | self.frame_registro.grid_remove() 202 | self.frame_botones_registro.grid_remove() 203 | 204 | def widgets_buscador_remove(self): 205 | self.Label_titulo_buscador.grid_remove() 206 | self.frame_buscar_producto.grid_remove() 207 | self.frame_boton_buscar.grid_remove() 208 | 209 | def widgets_informacion(self): 210 | self.Label_informacion.config(bd=0) 211 | self.Label_informacion.grid(row=0,column=0) 212 | "--------------- Titulo --------------------" 213 | self.Label_titulo = Label(self.Label_informacion,text="APLICACION DE ESCRITORIO",fg="white",bg="black",font=("Comic Sans", 25,"bold"),padx=137,pady=20) 214 | self.Label_titulo.grid(row=0,column=0) 215 | 216 | "--------------- Logos imagenes--------------------" 217 | #Logo 218 | imagen_arduino=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/app_logo_2.png") 219 | nueva_imagen=imagen_arduino.resize((170,170)) 220 | render=ImageTk.PhotoImage(nueva_imagen) 221 | label_imagen= Label(self.Label_informacion, image= render) 222 | label_imagen.image=render 223 | label_imagen.grid(row=1,column=0,padx=10,pady=15) 224 | 225 | "--------------- opciones--------------------" 226 | self.Label_titulo = Label(self.Label_informacion,text="> CONTROL DE PRODUCTOS ",fg="black",font=("Comic Sans", 18,"bold")) 227 | self.Label_titulo.grid(row=2,column=0,sticky=W,padx=30,pady=10) 228 | 229 | self.Label_titulo = Label(self.Label_informacion,text="> BUSCADOR DE PRODUCTOS ",fg="black",font=("Comic Sans", 18,"bold")) 230 | self.Label_titulo.grid(row=3,column=0,sticky=W,padx=30,pady=10) 231 | 232 | self.Label_titulo = Label(self.Label_informacion,text="> REGISTRO VENTAS ",fg="black",font=("Comic Sans", 18,"bold")) 233 | self.Label_titulo.grid(row=4,column=0,sticky=W,padx=30,pady=10) 234 | 235 | self.Label_titulo = Label(self.Label_informacion,text="> GENERACION DE REPORTE ",fg="black",font=("Comic Sans", 18,"bold")) 236 | self.Label_titulo.grid(row=5,column=0,sticky=W,padx=30,pady=10) 237 | 238 | self.Label_titulo = Label(self.Label_informacion,text="Creado por Luis Ochoa - 2023",fg="black",font=("Comic Sans",10,"bold")) 239 | self.Label_titulo.grid(row=6,column=0,pady=60) 240 | 241 | #Remove 242 | self.widgets_buscador_remove() 243 | self.widgets_crud_remove() 244 | 245 | "--------------- CRUD --------------------" 246 | def Obtener_productos(self): 247 | records=self.tree.get_children() 248 | for element in records: 249 | self.tree.delete(element) 250 | query='SELECT * FROM Productos ORDER BY Nombre desc' 251 | db_rows=self.Ejecutar_consulta(query) 252 | for row in db_rows: 253 | self.tree.insert("",0, text=row[1],values=(row[2],row[3],row[4],row[5],row[6])) 254 | 255 | def Agregar_producto(self): 256 | if self.Validar_formulario_completo() and self.Validar_registrar(): 257 | query='INSERT INTO Productos VALUES(NULL, ?, ?, ?, ?, ?, ?)' 258 | parameters = (self.codigo.get(),self.nombre.get(),self.combo_categoria.get(),self.cantidad.get(),self.precio.get(),self.descripcion.get()) 259 | self.Ejecutar_consulta(query, parameters) 260 | messagebox.showinfo("REGISTRO EXITOSO", f'Producto registrado: {self.nombre.get()}') 261 | print('REGISTRADO') 262 | self.Limpiar_formulario() 263 | self.Obtener_productos() 264 | 265 | def Eliminar_producto(self): 266 | try: 267 | self.tree.item(self.tree.selection())['text'][0] 268 | except IndexError as e: 269 | messagebox.showerror("ERROR","Porfavor selecciona un elemento") 270 | return 271 | dato=self.tree.item(self.tree.selection())['text'] 272 | nombre=self.tree.item(self.tree.selection())['values'][0] 273 | query="DELETE FROM Productos WHERE Codigo = ?" 274 | respuesta=messagebox.askquestion("ADVERTENCIA",f"¿Seguro que desea eliminar el producto: {nombre}?") 275 | if respuesta == 'yes': 276 | self.Ejecutar_consulta(query,(dato,)) 277 | self.Obtener_productos() 278 | messagebox.showinfo('EXITO',f'Producto eliminado: {nombre}') 279 | else: 280 | messagebox.showerror('ERROR',f'Error al eliminar el producto: {nombre}') 281 | 282 | def Editar_producto(self): 283 | try: 284 | self.tree.item(self.tree.selection())['text'][0] 285 | except IndexError as e: 286 | messagebox.showerror("ERROR","Porfavor selecciona un elemento") 287 | return 288 | codigo=self.tree.item(self.tree.selection())['text'] 289 | nombre=self.tree.item(self.tree.selection())['values'][0] 290 | categoria=self.tree.item(self.tree.selection())['values'][1] 291 | cantidad=self.tree.item(self.tree.selection())['values'][2] 292 | precio=self.tree.item(self.tree.selection())['values'][3] 293 | descripcion=self.tree.item(self.tree.selection())['values'][4] 294 | 295 | self.Ventana_editar = Toplevel() 296 | self.Ventana_editar.title('EDITAR PRODUCTO') 297 | self.Ventana_editar.resizable(0,0) 298 | 299 | 300 | #Valores ventana editar 301 | label_codigo=Label(self.Ventana_editar,text="Codigo del producto: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 302 | nuevo_codigo=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=codigo),width=25) 303 | nuevo_codigo.grid(row=0, column=1, padx=5, pady=8) 304 | 305 | label_nombre=Label(self.Ventana_editar,text="Nombre del producto: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=5,pady=8) 306 | nuevo_nombre=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=nombre),width=25) 307 | nuevo_nombre.grid(row=1, column=1, padx=5, pady=8) 308 | 309 | label_categoria=Label(self.Ventana_editar,text="Categoria: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=5,pady=9) 310 | nuevo_combo_categoria=ttk.Combobox(self.Ventana_editar,values=["Microcontrolador","Microordenador","Sensores","Accesorios"], width=22,state="readonly") 311 | nuevo_combo_categoria.set(categoria) 312 | nuevo_combo_categoria.grid(row=2,column=1,padx=5,pady=0) 313 | 314 | label_cantidad=Label(self.Ventana_editar,text="Cantidad: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=8) 315 | nueva_cantidad=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=cantidad),width=25) 316 | nueva_cantidad.grid(row=0, column=3, padx=5, pady=8) 317 | 318 | label_precio=Label(self.Ventana_editar,text="Precio (S/.): ",font=("Comic Sans", 10,"bold")).grid(row=1,column=2,sticky='s',padx=5,pady=8) 319 | nuevo_precio=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=precio),width=25) 320 | nuevo_precio.grid(row=1, column=3, padx=5, pady=8) 321 | 322 | label_descripcion=Label(self.Ventana_editar,text="Descripcion: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=2,sticky='s',padx=10,pady=8) 323 | nueva_descripcion=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=descripcion),width=25) 324 | nueva_descripcion.grid(row=2, column=3, padx=10, pady=8) 325 | 326 | boton_actualizar=Button(self.Ventana_editar,text="ACTUALIZAR",command= lambda: self.Actualizar(nuevo_codigo.get(),nuevo_nombre.get(),nuevo_combo_categoria.get(),nueva_cantidad.get(),nuevo_precio.get(),nueva_descripcion.get(),codigo,nombre),height=2,width=20,bg="black",fg="white",font=("Comic Sans", 10,"bold")) 327 | boton_actualizar.grid(row=3, column=1,columnspan=2, padx=10, pady=15) 328 | 329 | self.Ventana_editar.mainloop() 330 | 331 | def Actualizar(self,nuevo_codigo,nuevo_nombre,nuevo_combo_categoria,nueva_cantidad,nuevo_precio,nueva_descripcion,codigo,nombre): 332 | query='UPDATE Productos SET Codigo = ?, Nombre = ?, Categoria = ?, Cantidad =?, Precio=?, Descripcion =? WHERE Codigo = ? AND Nombre =?' 333 | parameters=(nuevo_codigo,nuevo_nombre,nuevo_combo_categoria,nueva_cantidad,nuevo_precio,nueva_descripcion,codigo,nombre) 334 | self.Ejecutar_consulta(query,parameters) 335 | messagebox.showinfo('EXITO',f'Producto actualizado:{nuevo_nombre}') 336 | self.Ventana_editar.destroy() 337 | self.Obtener_productos() 338 | 339 | def Buscar_productos(self): 340 | #Obtener todos los elementos con get_children(), que retorna una tupla de ID. 341 | records=self.tree.get_children() 342 | for element in records: 343 | self.tree.delete(element) 344 | 345 | if (self.combo_buscar.get()=='Codigo'): 346 | query=("SELECT * FROM Productos WHERE Codigo LIKE ? ") 347 | parameters=(self.codigo_nombre.get()+"%") 348 | db_rows=self.Ejecutar_consulta(query,(parameters,)) 349 | for row in db_rows: 350 | self.tree.insert("",0, text=row[1],values=(row[2],row[3],row[4],row[5],row[6])) 351 | if(list(self.tree.get_children())==[]): 352 | messagebox.showerror("ERROR","Producto no encontrado") 353 | else: 354 | query=("SELECT * FROM Productos WHERE Nombre LIKE ? ") 355 | parameters=("%"+self.codigo_nombre.get()+"%") 356 | db_rows=self.Ejecutar_consulta(query,(parameters,)) 357 | for row in db_rows: 358 | self.tree.insert("",0, text=row[1],values=(row[2],row[3],row[4],row[5],row[6])) 359 | if(list(self.tree.get_children())==[]): 360 | messagebox.showerror("ERROR","Producto no encontrado") 361 | 362 | "--------------- OTRAS FUNCIONES --------------------" 363 | def Ejecutar_consulta(self, query, parameters=()): 364 | with sqlite3.connect(self.db_name) as conexion: 365 | cursor=conexion.cursor() 366 | result=cursor.execute(query,parameters) 367 | conexion.commit() 368 | return result 369 | 370 | def Validar_formulario_completo(self): 371 | if len(self.codigo.get()) !=0 and len(self.nombre.get()) !=0 and len(self.combo_categoria.get()) !=0 and len(self.cantidad.get()) !=0 and len(self.precio.get()) !=0 and len(self.descripcion.get()) !=0: 372 | return True 373 | else: 374 | messagebox.showerror("ERROR", "Complete todos los campos del formulario") 375 | 376 | def Limpiar_formulario(self): 377 | self.codigo.delete(0, END) 378 | self.nombre.delete(0, END) 379 | self.cantidad.delete(0, END) 380 | self.precio.delete(0, END) 381 | self.descripcion.delete(0, END) 382 | 383 | def Validar_registrar(self): 384 | parameters= self.codigo.get() 385 | query="SELECT * FROM Productos WHERE Codigo = ?" 386 | dato = self.Ejecutar_consulta(query,(parameters,)) 387 | if (dato.fetchall() == []): 388 | return True 389 | else: 390 | messagebox.showerror("ERROR EN REGISTRO", "Codigo registrado anteriormente") 391 | 392 | if __name__ == '__main__': 393 | ventana_producto=Tk() 394 | label_crud=Label(ventana_producto) 395 | application=Producto(ventana_producto) 396 | ventana_producto.mainloop() 397 | -------------------------------------------------------------------------------- /APP_DESKTOP/__pycache__/Buscador.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/APP_DESKTOP/__pycache__/Buscador.cpython-37.pyc -------------------------------------------------------------------------------- /APP_DESKTOP/main.py: -------------------------------------------------------------------------------- 1 | """ 2 | FORMULARIO DE LOGIN 3 | Ingresar al sistema con su dni y contraseña 4 | Mostrar messagebox 5 | """ 6 | from tkinter import * 7 | from tkinter import ttk 8 | from tkinter import messagebox 9 | #Python image Library 10 | from PIL import ImageTk, Image 11 | import sqlite3 12 | from Buscador import Producto 13 | 14 | class Login: 15 | db_name='database_proyecto.db' 16 | 17 | def __init__(self,ventana_login): 18 | self.window=ventana_login 19 | self.window.title("INGRESAR AL SISTEMA") 20 | self.window.geometry("330x370") 21 | self.window.resizable(0,0) 22 | self.window.config(bd=10) 23 | 24 | "--------------- Titulo --------------------" 25 | titulo= Label(ventana_login, text="INICIAR SESION",fg="black",font=("Comic Sans", 13,"bold"),pady=10).pack() 26 | 27 | "--------------- Loginlogo --------------------" 28 | imagen_login=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/login.png") 29 | nueva_imagen=imagen_login.resize((40,40)) 30 | render=ImageTk.PhotoImage(nueva_imagen) 31 | label_imagen= Label(ventana_login, image= render) 32 | label_imagen.image=render 33 | label_imagen.pack(pady=5) 34 | 35 | 36 | "--------------- Marco --------------------" 37 | marco = LabelFrame(ventana_login, text="Ingrese sus datos",font=("Comic Sans", 10,"bold")) 38 | marco.config(bd=2) 39 | marco.pack() 40 | 41 | "--------------- Formulario --------------------" 42 | label_dni=Label(marco,text="DNI: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=10) 43 | self.dni_login=Entry(marco,width=25) 44 | self.dni_login.focus() 45 | self.dni_login.grid(row=0, column=1, padx=5, pady=10) 46 | 47 | label_nombres=Label(marco,text="Contraseña: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=10,pady=10) 48 | self.password_login=Entry(marco,width=25,show="*") 49 | self.password_login.grid(row=1, column=1, padx=10, pady=10) 50 | 51 | "--------------- Frame botones --------------------" 52 | frame_botones=Frame(ventana_login) 53 | frame_botones.pack() 54 | 55 | "--------------- Botones --------------------" 56 | boton_ingresar=Button(frame_botones,text="INGRESAR",command=self.Login,height=2,width=12,bg="green",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=1, padx=10, pady=15) 57 | boton_registrar=Button(frame_botones,text="REGISTRAR",command=self.Ventana_registrar_usuario,height=2,width=12,bg="blue",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=2, padx=10, pady=15) 58 | label_=Label(frame_botones,text="⬇ ¿Olvido su contraseña? ⬇",font=("Comic Sans", 10,"bold")).grid(row=1,column=1,columnspan=2,sticky='s') 59 | boton_olvido=Button(frame_botones,text="RECUPERAR CONTRASEÑA",command=self.Ventana_recuperar_password ,height=2,width=24,bg="gray",fg="white",font=("Comic Sans", 10,"bold")).grid(row=2, column=1, columnspan=2, padx=10, pady=8) 60 | 61 | def Validar_login(self, dni, password): 62 | with sqlite3.connect(self.db_name) as conexion: 63 | cursor=conexion.cursor() 64 | sql= f"SELECT * FROM Usuarios WHERE DNI = {dni} AND Contraseña = '{password}'" 65 | cursor.execute(sql) 66 | validacion= cursor.fetchall() # obtener respuesta como lista 67 | cursor.close() 68 | return validacion 69 | 70 | def Validar_formulario_completo(self): 71 | if len(self.dni_login.get()) !=0 and len(self.password_login.get()) !=0: 72 | return True 73 | else: 74 | messagebox.showerror("ERROR DE INGRESO", "Ingrese su DNI y contraseña!!!") 75 | self.Limpiar_login() 76 | 77 | def Limpiar_login(self): 78 | self.dni_login.delete(0, END) 79 | self.password_login.delete(0, END) 80 | 81 | def Login(self): 82 | try: 83 | if(self.Validar_formulario_completo()): 84 | dni= self.dni_login.get() 85 | password= self.password_login.get() 86 | dato = self.Validar_login(dni, password) 87 | if (dato != []): 88 | messagebox.showinfo("BIENVENIDO", "Datos ingresados correctamente") 89 | Producto.__init__(self,ventana_producto=ventana_login) 90 | else: 91 | messagebox.showerror("ERROR DE INGRESO", "DNI o contraseña incorrecto") 92 | self.Limpiar_login() 93 | except: 94 | messagebox.showerror("ERROR", "Ha ocurrido un error, reinicie el programa") 95 | self.Limpiar_login() 96 | "--------------------------------------------- REGISTRAR USUARIO --------------------------------------------------" 97 | def Ventana_registrar_usuario(self): 98 | self.Ventana_registrar=Toplevel() 99 | self.Ventana_registrar.title("FORMULARIO DE REGISTRO") 100 | self.Ventana_registrar.geometry("390x630") 101 | self.Ventana_registrar.resizable(0,0) 102 | self.Ventana_registrar.config(bd=10) 103 | 104 | "--------------- Titulo --------------------" 105 | titulo= Label(self.Ventana_registrar, text="REGISTRO DE USUARIO",fg="black",font=("Comic Sans", 13,"bold"),pady=5).pack() 106 | 107 | "--------------- Nuevo usuario logo --------------------" 108 | imagen_registro=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/nuevo_usuario.png") 109 | nueva_imagen=imagen_registro.resize((40,40)) 110 | render=ImageTk.PhotoImage(nueva_imagen) 111 | label_imagen= Label(self.Ventana_registrar, image= render) 112 | label_imagen.image=render 113 | label_imagen.pack(pady=5) 114 | 115 | 116 | "--------------- Marco --------------------" 117 | marco = LabelFrame(self.Ventana_registrar, text="Datos personales",font=("Comic Sans", 10,"bold")) 118 | marco.config(bd=2,pady=5) 119 | marco.pack() 120 | 121 | "--------------- Formulario --------------------" 122 | label_dni=Label(marco,text="DNI: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 123 | self.dni=Entry(marco,width=25) 124 | self.dni.focus() 125 | self.dni.grid(row=0, column=1, padx=5, pady=8) 126 | 127 | label_nombres=Label(marco,text="Nombre: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=10,pady=8) 128 | self.nombres=Entry(marco,width=25) 129 | self.nombres.grid(row=1, column=1, padx=10, pady=8) 130 | 131 | label_apellidos=Label(marco,text="Apellidos: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=10,pady=8) 132 | self.apellidos=Entry(marco,width=25) 133 | self.apellidos.grid(row=2, column=1, padx=10, pady=8) 134 | 135 | label_sexo=Label(marco,text="Sexo: ",font=("Comic Sans", 10,"bold")).grid(row=3,column=0,sticky='s',padx=10,pady=8) 136 | self.combo_sexo=ttk.Combobox(marco,values=["Masculino", "Femenino"], width=22,state="readonly") 137 | self.combo_sexo.current(0) 138 | self.combo_sexo.grid(row=3,column=1,padx=10,pady=8) 139 | 140 | label_edad=Label(marco,text="Edad: ",font=("Comic Sans", 10,"bold")).grid(row=4,column=0,sticky='s',padx=10,pady=8) 141 | self.edad=Entry(marco,width=25) 142 | self.edad.grid(row=4, column=1, padx=10, pady=8) 143 | 144 | label_correo=Label(marco,text="Correo electronico: ",font=("Comic Sans", 10,"bold")).grid(row=5,column=0,sticky='s',padx=10,pady=8) 145 | self.correo=Entry(marco,width=25) 146 | self.correo.grid(row=5, column=1, padx=10, pady=8) 147 | 148 | label_password=Label(marco,text="Contraseña: ",font=("Comic Sans", 10,"bold")).grid(row=6,column=0,sticky='s',padx=10,pady=8) 149 | self.password=Entry(marco,width=25,show="*") 150 | self.password.grid(row=6, column=1, padx=10, pady=8) 151 | 152 | label_password=Label(marco,text="Repetir contraseña: ",font=("Comic Sans", 10,"bold")).grid(row=7,column=0,sticky='s',padx=10,pady=8) 153 | self.repetir_password=Entry(marco,width=25,show="*") 154 | self.repetir_password.grid(row=7, column=1, padx=10, pady=8) 155 | 156 | "--------------- Marco pregunta --------------------" 157 | marco_pregunta = LabelFrame(self.Ventana_registrar, text="Si olvidas tu contraseña",font=("Comic Sans", 10,"bold"),pady=10) 158 | marco_pregunta.config(bd=2,pady=5) 159 | marco_pregunta.pack() 160 | "--------------- Pregunta --------------------" 161 | label_pregunta=Label(marco_pregunta,text="Pregunta: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=10,pady=8) 162 | self.combo_pregunta=ttk.Combobox(marco_pregunta,values=["¿Nombre de tu primera mascota?","¿Lugar dónde fuiste al colegio?","¿En que ciudad naciste?","¿Cómo se llama tu equipo favorito?"], width=30,state="readonly") 163 | self.combo_pregunta.current(0) 164 | self.combo_pregunta.grid(row=0,column=1,padx=10,pady=8) 165 | 166 | label_respuesta=Label(marco_pregunta,text="Respuesta: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=10,pady=8) 167 | self.respuesta=Entry(marco_pregunta,width=33) 168 | self.respuesta.grid(row=1, column=1, padx=10, pady=8) 169 | 170 | label_nota=Label(marco_pregunta,text="*Esta respuesta te permitira recuperar tu contraseña.",font=("Comic Sans", 9,"bold"),foreground="blue").grid(row=2,column=0,columnspan=2,sticky='s',padx=10) 171 | 172 | "--------------- Frame botones --------------------" 173 | frame_botones=Frame(self.Ventana_registrar) 174 | frame_botones.pack() 175 | 176 | "--------------- Botones --------------------" 177 | boton_registrar=Button(frame_botones,text="REGISTRAR",command=self.Registrar_usuario ,height=2,width=10,bg="green",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=1, padx=10, pady=15) 178 | boton_limpiar=Button(frame_botones,text="LIMPIAR",command=self.Limpiar_formulario_registro ,height=2,width=10,bg="gray",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=2, padx=10, pady=15) 179 | boton_cancelar=Button(frame_botones,text="CERRAR",command=self.Ventana_registrar.destroy ,height=2,width=10,bg="red",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=3, padx=10, pady=15) 180 | 181 | self.Ventana_registrar.mainloop() 182 | 183 | def Ejecutar_consulta(self, query, parameters=()): 184 | with sqlite3.connect(self.db_name) as conexion: 185 | cursor=conexion.cursor() 186 | result=cursor.execute(query,parameters) 187 | conexion.commit() 188 | return result 189 | 190 | def Limpiar_formulario_registro(self): 191 | self.dni.delete(0, END) 192 | self.nombres.delete(0, END) 193 | self.apellidos.delete(0, END) 194 | self.combo_sexo.delete(0, END) 195 | self.edad.delete(0, END) 196 | self.correo.delete(0, END) 197 | self.password.delete(0, END) 198 | self.repetir_password.delete(0, END) 199 | self.combo_pregunta.delete(0, END) 200 | self.respuesta.delete(0, END) 201 | 202 | def Validar_formulario_completo_registro(self): 203 | if len(self.dni.get()) !=0 and len(self.nombres.get()) !=0 and len(self.apellidos.get()) !=0 and len(self.combo_sexo.get()) !=0 and len(self.edad.get()) !=0 and len(self.password.get()) !=0 and len(self.repetir_password.get()) !=0 and len(self.correo.get()) !=0 and len(self.respuesta.get()) !=0: 204 | return True 205 | else: 206 | messagebox.showerror("ERROR EN REGISTRO", "Complete todos los campos del formulario") 207 | 208 | def Validar_contraseña_registro(self): 209 | if(str(self.password.get()) == str(self.repetir_password.get())): 210 | return True 211 | else: 212 | messagebox.showerror("ERROR EN REGISTRO", "Contraseñas no coinciden") 213 | 214 | def Buscar_dni(self, dni): 215 | with sqlite3.connect(self.db_name) as conexion: 216 | cursor=conexion.cursor() 217 | sql="SELECT * FROM Usuarios WHERE DNI = {}".format(dni) 218 | cursor.execute(sql) 219 | dnix= cursor.fetchall() # obtener respuesta como lista 220 | cursor.close() 221 | return dnix 222 | 223 | def Validar_dni(self): 224 | dni= self.dni.get() 225 | dato = self.Buscar_dni(dni) 226 | if (dato == []): 227 | return True 228 | else: 229 | messagebox.showerror("ERROR EN REGISTRO", "DNI registrado anteriormente") 230 | 231 | def Registrar_usuario(self): 232 | if self.Validar_formulario_completo_registro() and self.Validar_contraseña_registro() and self.Validar_dni(): 233 | query='INSERT INTO Usuarios VALUES(NULL, ?, ?, ?, ?, ?, ?, ?, ?)' 234 | parameters = (self.dni.get(),self.nombres.get(),self.apellidos.get(),self.combo_sexo.get(),self.edad.get(),self.correo.get(),self.password.get(),self.respuesta.get()) 235 | self.Ejecutar_consulta(query, parameters) 236 | messagebox.showinfo("REGISTRO EXITOSO", f'Bienvenido {self.nombres.get()} {self.apellidos.get()}') 237 | print('USUARIO CREADO') 238 | self.Limpiar_formulario_registro() 239 | 240 | "--------------------------------------------- RECUPERAR CONTRASEÑA --------------------------------------------------" 241 | def Ventana_recuperar_password(self): 242 | self.Ventana_recuperar = Toplevel() 243 | self.Ventana_recuperar.geometry("410x420") 244 | self.Ventana_recuperar.title('RECUPERAR CONTRASEÑA') 245 | self.Ventana_recuperar.resizable(0,0) 246 | self.Ventana_recuperar.config(bd=10) 247 | 248 | "--------------- Titulo --------------------" 249 | titulo= Label(self.Ventana_recuperar, text="RECUPERAR CONTRASEÑA",fg="black",font=("Comic Sans", 13,"bold"),pady=8).pack() 250 | 251 | "--------------- Recuperar password logo --------------------" 252 | imagen_password=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/recuperar_contraseña.png") 253 | nueva_imagen=imagen_password.resize((60,60)) 254 | render=ImageTk.PhotoImage(nueva_imagen) 255 | label_imagen= Label(self.Ventana_recuperar, image= render) 256 | label_imagen.image=render 257 | label_imagen.pack(pady=5) 258 | 259 | "--------------- Marco --------------------" 260 | marco = LabelFrame(self.Ventana_recuperar, text="Datos de recuperacion",font=("Comic Sans", 10,"bold")) 261 | marco.config(bd=2) 262 | marco.pack() 263 | 264 | "--------------- Formulario --------------------" 265 | label_dni=Label(marco,text="DNI: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 266 | self.dni=Entry(marco,width=25) 267 | self.dni.focus() 268 | self.dni.grid(row=0, column=1, padx=5, pady=8) 269 | 270 | label_nota=Label(marco,text="*Seleccione una pregunta y brinde la respuesta correcta.",font=("Comic Sans", 9,"bold"),foreground="blue").grid(row=1,column=0,columnspan=2,sticky='s',padx=8) 271 | 272 | label_pregunta=Label(marco,text="Pregunta: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=5,pady=8) 273 | self.combo_pregunta=ttk.Combobox(marco,values=["¿Nombre de tu primera mascota?","¿Lugar dónde fuiste al colegio?","¿En que ciudad naciste?","¿Cómo se llama tu equipo favorito?"], width=30,state="readonly") 274 | self.combo_pregunta.current(0) 275 | self.combo_pregunta.grid(row=2,column=1,padx=5,pady=8) 276 | 277 | label_respuesta=Label(marco,text="Respuesta: ",font=("Comic Sans", 10,"bold")).grid(row=3,column=0,sticky='s',padx=5,pady=8) 278 | self.respuesta=Entry(marco,width=33) 279 | self.respuesta.grid(row=3, column=1, padx=5, pady=8) 280 | 281 | label_password=Label(marco,text="Nueva Contraseña: ",font=("Comic Sans", 10,"bold")).grid(row=4,column=0,sticky='s',padx=5,pady=8) 282 | self.nuevo_password=Entry(marco,width=25,show="*") 283 | self.nuevo_password.grid(row=4, column=1, padx=5, pady=8) 284 | 285 | label_password=Label(marco,text="Repetir contraseña: ",font=("Comic Sans", 10,"bold")).grid(row=5,column=0,sticky='s',padx=10,pady=8) 286 | self.repetir_password=Entry(marco,width=25,show="*") 287 | self.repetir_password.grid(row=5, column=1, padx=5, pady=8) 288 | 289 | "--------------- Frame botones --------------------" 290 | frame_botones=Frame(self.Ventana_recuperar) 291 | frame_botones.pack() 292 | 293 | "--------------- Botones --------------------" 294 | boton_recuperar=Button(frame_botones,text="RECUPERAR",command=self.Restablecer_contraseña ,height=2,width=10,bg="green",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=1, padx=10, pady=10) 295 | boton_cancelar=Button(frame_botones,text="CANCELAR",command=self.Ventana_recuperar.destroy ,height=2,width=10,bg="red",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=3, padx=10, pady=10) 296 | 297 | self.Ventana_recuperar.mainloop() 298 | 299 | def Limpiar_formulario_recuperar(self): 300 | self.dni.delete(0, END) 301 | self.respuesta.delete(0, END) 302 | self.nuevo_password.delete(0, END) 303 | self.repetir_password.delete(0, END) 304 | 305 | def Validar_formulario_completo_recuperar(self): 306 | if len(self.dni.get()) !=0 and len(self.nuevo_password.get()) !=0 and len(self.repetir_password.get()) !=0 and len(self.respuesta.get()) !=0: 307 | return True 308 | else: 309 | messagebox.showerror("ERROR", "Complete todos los campos del formulario") 310 | 311 | def Validar_contraseña_recuperar(self): 312 | if(str(self.nuevo_password.get()) == str(self.repetir_password.get())): 313 | return True 314 | else: 315 | messagebox.showerror("ERROR DE RECUPERACION", "Contraseñas no coinciden") 316 | 317 | def Buscar_usuario(self, dni, respuesta): 318 | with sqlite3.connect(self.db_name) as conexion: 319 | cursor=conexion.cursor() 320 | sql=f"SELECT * FROM Usuarios WHERE DNI = {dni} AND Respuesta = '{respuesta}'" 321 | cursor.execute(sql) 322 | busqueda= cursor.fetchall() # obtener respuesta como lista 323 | cursor.close() 324 | return busqueda 325 | 326 | def Validar_datos_usuario(self): 327 | dni= self.dni.get() 328 | respuesta=self.respuesta.get() 329 | busqueda = self.Buscar_usuario(dni, respuesta) 330 | if (busqueda != []): 331 | return True 332 | else: 333 | messagebox.showerror("ERROR DE RECUPERACION", "Datos de recuperacion no son correctos") 334 | 335 | def Restablecer_contraseña(self): 336 | if self.Validar_formulario_completo_recuperar() and self.Validar_datos_usuario() and self.Validar_contraseña_recuperar(): 337 | query='UPDATE Usuarios SET Contraseña = (?) WHERE DNI= (?)' 338 | parameters = (self.nuevo_password.get(), self.dni.get()) 339 | self.Ejecutar_consulta(query, parameters) 340 | messagebox.showinfo("CONTRASEÑA RECUPERADA", f'Contraseña actualizada correctamente: {self.nuevo_password.get()}') 341 | print('DATOS ACTUALIZADO') 342 | self.Limpiar_formulario_recuperar() 343 | self.Ventana_recuperar.destroy() 344 | 345 | #verificar si el modulo ha sido ejecutado correctamente 346 | if __name__ == '__main__': 347 | ventana_login=Tk() 348 | application=Login(ventana_login) 349 | ventana_login.mainloop() 350 | 351 | -------------------------------------------------------------------------------- /CALCULADORA/calculadora.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/CALCULADORA/calculadora.png -------------------------------------------------------------------------------- /CALCULADORA/calculadora.py: -------------------------------------------------------------------------------- 1 | """" 2 | CALCULADORA 3 | -Se ingresara 2 valores a traves de campos de texto. 4 | -Se utilziara 4 botones que represente las operaciones matematicas. 5 | -Mostrara resultados 6 | """ 7 | 8 | from tkinter import * 9 | from tkinter import messagebox 10 | #Python image Library 11 | from PIL import ImageTk, Image 12 | 13 | ventana =Tk() 14 | ventana.title("CALCULADORA") 15 | ventana.geometry("350x360") 16 | ventana.resizable(0,0) 17 | ventana.config(bd=10) 18 | 19 | #Imagen calculadora 20 | imagen_calculadora=Image.open("D:/EIGHTA/PYTHON-TKINTER/CALCULADORA/calculadora.png") 21 | nueva_imagen=imagen_calculadora.resize((75,75)) 22 | render=ImageTk.PhotoImage(nueva_imagen) 23 | label_imagen= Label(ventana, image= render) 24 | label_imagen.image=render 25 | label_imagen.pack(pady=5) 26 | 27 | def cfloat(numero): 28 | try: 29 | result=float(numero) 30 | except: 31 | messagebox.showerror("ERROR","INTRODUCE BIEN LOS DATOS") 32 | return result 33 | 34 | def sumar(): 35 | 36 | resultado.set(cfloat(numero1.get())+cfloat(numero2.get())) 37 | mostrarResultado() 38 | 39 | def restar(): 40 | 41 | resultado.set(cfloat(numero1.get())-cfloat(numero2.get())) 42 | mostrarResultado() 43 | 44 | 45 | def multiplicar(): 46 | resultado.set(cfloat(numero1.get())*cfloat(numero2.get())) 47 | mostrarResultado() 48 | 49 | 50 | def dividir(): 51 | resultado.set(cfloat(numero1.get())/cfloat(numero2.get())) 52 | mostrarResultado() 53 | 54 | 55 | def mostrarResultado(): 56 | messagebox.showinfo("RESULTADO",f"El resultado de la operacion es: {resultado.get()}") 57 | 58 | numero1=StringVar() 59 | numero2=StringVar() 60 | resultado = StringVar() 61 | 62 | marco = Frame(ventana, width=300, heigh=200) 63 | marco.config(bd=4, 64 | padx=15, 65 | pady=15, 66 | relief=SOLID) 67 | marco.pack(side=TOP,anchor=CENTER) 68 | #No alterar su posicionamiento 69 | marco.pack_propagate(False) 70 | 71 | 72 | Label(marco, text="Primer numero:",fg="black",font=("Arial", 10,"bold")).pack() 73 | Entry(marco,textvariable=numero1,justify="center").pack() 74 | 75 | Label(marco, text="Segundo numero:",fg="black",font=("Arial", 10,"bold")).pack() 76 | Entry(marco,textvariable=numero2,justify="center").pack() 77 | 78 | Button(marco,text="Sumar",command=sumar,height=1,width=8,bg="black",fg="white",font=("Arial", 9,"bold")).pack(side="left",fill=X,padx=1) 79 | Button(marco,text="Restar",command=restar,height=1,width=8,bg="black",fg="white",font=("Arial", 9,"bold")).pack(side="left",fill=X,padx=1) 80 | Button(marco,text="Multiplicar",command=multiplicar,height=1,width=8,bg="black",fg="white",font=("Arial", 9,"bold")).pack(side="left",fill=X,padx=1) 81 | Button(marco,text="Dividir",command=dividir,height=1,width=8,bg="black",fg="white",font=("Arial", 9,"bold")).pack(side="left",fill=X,padx=1) 82 | 83 | 84 | Button(ventana,text="Cerrar",command=ventana.quit ,height=2,width=10,bg="red",fg="white",font=("Arial", 9,"bold")).pack(side=BOTTOM) 85 | 86 | ventana.mainloop() -------------------------------------------------------------------------------- /ENVIAR_EMAIL/enviar_email_smtlib.py: -------------------------------------------------------------------------------- 1 | """ 2 | SMTP 3 | ¿Qué es y para qué sirve SMTP? 4 | SMTP, Simple Mail Transfer Protocol por sus siglas en inglés, es un protocolo o conjunto de reglas 5 | de comunicación que utilizan los servidores de correo electrónico para enviar y recibir e-mails. 6 | """ 7 | from email.message import EmailMessage #Construir la estructura del email 8 | import smtplib # conectar con el servidor y enviarlo 9 | from tkinter import * 10 | from tkinter import messagebox 11 | #Python image Library 12 | from PIL import ImageTk, Image 13 | 14 | "------------INTERFAZ TKINTER------------" 15 | ventana =Tk() 16 | ventana.title("ALICACION DE MENSAJERIA") 17 | ventana.geometry("335x385") 18 | ventana.resizable(0,0) 19 | ventana.config(bd=10) 20 | 21 | Label(ventana, text="ENVIAR CORREO VIA GMAIL",fg="black",font=("Arial", 15,"bold"),padx=5,pady=5).grid(row=0,column=0,columnspan=2) 22 | 23 | #Imagen GMAIL 24 | imagen_gmail=Image.open("D:/EIGHTA/PYTHON-TKINTER/ENVIAR_EMAIL/logo_gmail.png") 25 | nueva_imagen=imagen_gmail.resize((125,84)) 26 | render=ImageTk.PhotoImage(nueva_imagen) 27 | label_imagen= Label(ventana, image= render) 28 | label_imagen.image=render 29 | label_imagen.grid(row=1,column=0,columnspan=2) 30 | 31 | #Variables 32 | destinatario=StringVar(ventana) 33 | asunto=StringVar(ventana) 34 | 35 | Label(ventana, text="Mi correo: luisochoa.1495@gmail.com",fg="white",bg="blue",font=("Arial", 10,"bold"),padx=5,pady=5).grid(row=2,column=0,columnspan=2,pady=5) 36 | 37 | Label(ventana, text="Destinatario:",fg="black",font=("Arial", 10,"bold"),padx=5,pady=5).grid(row=3,column=0) 38 | Entry(ventana,textvariable=destinatario, width=34).grid(row=3,column=1) 39 | 40 | Label(ventana, text="Asunto:",fg="black",font=("Arial", 10,"bold"),padx=5,pady=5).grid(row=4,column=0) 41 | Entry(ventana,textvariable=asunto, width=34).grid(row=4,column=1) 42 | 43 | Label(ventana, text="Mensaje:",fg="black",font=("Arial", 10,"bold"),padx=5,pady=5).grid(row=5,column=0) 44 | mensaje=Text(ventana,height=5,width=28,padx=5,pady=5) 45 | mensaje.grid(row=5,column=1) 46 | mensaje.config(font=("Arial", 9),padx=5, pady=5) 47 | 48 | 49 | "------------ENVIO DE CORREO------------" 50 | def enviar_email(): 51 | remitente = "luisochoa.1495@gmail.com" 52 | #Estrutura de email 53 | email = EmailMessage() 54 | email["From"] = remitente 55 | email["To"] = destinatario.get() 56 | email["Subject"] = asunto.get() 57 | email.set_content(str(mensaje.get(1.0, 'end'))) 58 | #Envio de email 59 | smtp = smtplib.SMTP_SSL("smtp.gmail.com") 60 | smtp.login(remitente, "clave-personal") 61 | smtp.sendmail(remitente, destinatario.get(), email.as_string()) 62 | messagebox.showinfo("MENSAJERIA","Mensaje enviado correctamente ") 63 | smtp.quit() 64 | 65 | "------------BOTON------------" 66 | Button(ventana,text="ENVIAR",command=enviar_email,height=2,width=10,bg="black",fg="white",font=("Arial", 10,"bold")).grid(row=6,column=0,columnspan=2,padx=5,pady=10) 67 | 68 | ventana.mainloop() 69 | -------------------------------------------------------------------------------- /ENVIAR_EMAIL/logo_gmail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/ENVIAR_EMAIL/logo_gmail.png -------------------------------------------------------------------------------- /PROYECTO_TIENDA/img/app_logo_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/PROYECTO_TIENDA/img/app_logo_2.png -------------------------------------------------------------------------------- /PROYECTO_TIENDA/img/buscar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/PROYECTO_TIENDA/img/buscar.png -------------------------------------------------------------------------------- /PROYECTO_TIENDA/img/cliente.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/PROYECTO_TIENDA/img/cliente.png -------------------------------------------------------------------------------- /PROYECTO_TIENDA/img/codigo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/PROYECTO_TIENDA/img/codigo.png -------------------------------------------------------------------------------- /PROYECTO_TIENDA/img/codigos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/PROYECTO_TIENDA/img/codigos.png -------------------------------------------------------------------------------- /PROYECTO_TIENDA/img/informacion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/PROYECTO_TIENDA/img/informacion.png -------------------------------------------------------------------------------- /PROYECTO_TIENDA/img/logo-tienda.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/PROYECTO_TIENDA/img/logo-tienda.png -------------------------------------------------------------------------------- /PROYECTO_TIENDA/img/nueva_venta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/PROYECTO_TIENDA/img/nueva_venta.png -------------------------------------------------------------------------------- /PROYECTO_TIENDA/img/registrar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/PROYECTO_TIENDA/img/registrar.png -------------------------------------------------------------------------------- /PROYECTO_TIENDA/img/ventas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/PROYECTO_TIENDA/img/ventas.png -------------------------------------------------------------------------------- /PROYECTO_TIENDA/main.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import ttk 3 | from tkinter import messagebox 4 | #Python image Library 5 | from PIL import ImageTk, Image 6 | import sqlite3 7 | from datetime import datetime 8 | 9 | class Tienda(): 10 | db_name='tienda_diaz.db' 11 | def __init__(self, ventana_producto): 12 | menubar=Menu(ventana_producto) 13 | ventana_producto.title("TIENDA DIAZ") 14 | ventana_producto.geometry("770x700") 15 | ventana_producto.resizable(0,0) 16 | ventana_producto.config(bd=10,menu=menubar) 17 | 18 | "---------------------Menu---------------------------" 19 | Productos=Menu(menubar,tearoff=0) 20 | Ventas=Menu(menubar,tearoff=0) 21 | Reportes=Menu(menubar,tearoff=0) 22 | Informacion=Menu(menubar,tearoff=0) 23 | menubar.add_cascade(label="Productos",menu=Productos) 24 | menubar.add_cascade(label="Ventas",menu=Ventas) 25 | #menubar.add_cascade(label="Reportes",menu=Reportes) 26 | menubar.add_cascade(label="Ayuda",menu=Informacion) 27 | #Iconos 28 | self.img_registrar=PhotoImage(file="./PROYECTO_TIENDA/img/registrar.png") 29 | self.img_buscar=PhotoImage(file="./PROYECTO_TIENDA/img/buscar.png") 30 | self.img_ventas=PhotoImage(file="./PROYECTO_TIENDA/img/ventas.png") 31 | self.img_nueva_venta=PhotoImage(file="./PROYECTO_TIENDA/img/nueva_venta.png") 32 | self.img_cliente=PhotoImage(file="./PROYECTO_TIENDA/img/cliente.png") 33 | self.img_codigo=PhotoImage(file="./PROYECTO_TIENDA/img/codigo.png") 34 | self.img_informacion=PhotoImage(file="./PROYECTO_TIENDA/img/informacion.png") 35 | #Acciones de menu 36 | self.boton_registrar=Productos.add_command(label="Registrar",command= self.widgets_crud,image=self.img_registrar,compound=LEFT) 37 | self.boton_buscar=Productos.add_command(label="Buscar",command=self.widgets_buscador,image=self.img_buscar,compound=LEFT) 38 | self.boton_nueva_venta=Ventas.add_command(label="Nueva Venta",command=self.widgets_nueva_venta,image=self.img_nueva_venta,compound=LEFT) 39 | self.boton_ventas=Ventas.add_command(label="Ventas",command=self.widgets_ventas,image=self.img_ventas,compound=LEFT) 40 | self.boton_cliente=Ventas.add_command(label="Clientes",command=self.widgets_cliente,image=self.img_cliente,compound=LEFT) 41 | self.boton_informacion=Informacion.add_command(label="Codigo Producto",command=self.widgets_codigos,image=self.img_codigo,compound=LEFT) 42 | self.boton_informacion=Informacion.add_command(label="Informacion del sistema",command=self.widgets_informacion,image=self.img_informacion,compound=LEFT) 43 | 44 | "---------------------Widgets---------------------------" 45 | #widgets crud 46 | self.frame_logo_productos = LabelFrame(ventana_producto) 47 | self.frame_registro = LabelFrame(ventana_producto, text="Registrar producto",font=("Comic Sans", 10,"bold"),pady=5) 48 | self.frame_botones_registro=LabelFrame(ventana_producto) 49 | self.frame_tabla_crud=LabelFrame(ventana_producto) 50 | #widgets buscador 51 | self.frame_buscar_producto = LabelFrame(ventana_producto, text="Buscar producto",font=("Comic Sans", 10,"bold"),pady=10) 52 | self.frame_boton_buscar=LabelFrame(ventana_producto) 53 | self.frame_tabla_buscador=LabelFrame(ventana_producto) 54 | #widgets nueva ventas 55 | self.frame_dni_venta=LabelFrame(ventana_producto) 56 | self.frame_nueva_venta = LabelFrame(ventana_producto,text="Nueva venta",font=("Comic Sans", 10,"bold"),pady=10) 57 | self.frame_finalizar_venta=LabelFrame(ventana_producto) 58 | self.frame_tabla_nueva_venta=LabelFrame(ventana_producto) 59 | #widgets ventas 60 | self.frame_buscar_ventas = LabelFrame(ventana_producto,text="Buscar venta",font=("Comic Sans", 10,"bold"),pady=10) 61 | self.frame_boton_buscar_ventas=LabelFrame(ventana_producto) 62 | self.frame_tabla_ventas=LabelFrame(ventana_producto) 63 | #widgets cliente 64 | self.frame_nuevo_cliente = LabelFrame(ventana_producto,text="Nuevo Cliente",font=("Comic Sans", 10,"bold"),pady=10) 65 | self.frame_botones_registro_cliente = LabelFrame(ventana_producto) 66 | self.frame_buscar_cliente = LabelFrame(ventana_producto,text="Buscar Cliente",font=("Comic Sans", 10,"bold"),pady=10) 67 | self.frame_tabla_clientes=LabelFrame(ventana_producto) 68 | #Codigos productos 69 | self.frame_codigo = LabelFrame(ventana_producto) 70 | #widgets informacion 71 | self.Label_informacion = LabelFrame(ventana_producto) 72 | 73 | #Pantalla inicial 74 | self.widgets_crud() 75 | 76 | "--------------- WIDGETS--------------------" 77 | def widgets_crud(self): 78 | "--------------- Logos tienda --------------------" 79 | self.frame_logo_productos.config(bd=0) 80 | self.frame_logo_productos.grid(row=0,column=0,padx=5,pady=5) 81 | 82 | #Logo 83 | imagen=Image.open("./PROYECTO_TIENDA/img/logo-tienda.png") 84 | nueva_imagen=imagen.resize((320,150)) 85 | render=ImageTk.PhotoImage(nueva_imagen) 86 | label_imagen= Label(self.frame_logo_productos, image= render) 87 | label_imagen.image=render 88 | label_imagen.grid(row=0, column=0) 89 | 90 | "--------------- Frame marco registro --------------------" 91 | self.frame_registro.config(bd=2) 92 | self.frame_registro.grid(row=1,column=0,padx=5,pady=5) 93 | 94 | "--------------- Formulario --------------------" 95 | label_codigo=Label(self.frame_registro,text="Codigo del producto: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 96 | self.codigo=Entry(self.frame_registro,width=25) 97 | self.codigo.focus() 98 | self.codigo.grid(row=0, column=1, padx=5, pady=8) 99 | 100 | label_nombre=Label(self.frame_registro,text="Nombre del producto: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=5,pady=8) 101 | self.nombre=Entry(self.frame_registro,width=25) 102 | self.nombre.grid(row=1, column=1, padx=5, pady=8) 103 | 104 | label_categoria=Label(self.frame_registro,text="Categoria: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=5,pady=9) 105 | self.combo_categoria=ttk.Combobox(self.frame_registro,values=["Componentes","Perifericos"], width=22,state="readonly") 106 | self.combo_categoria.current(0) 107 | self.combo_categoria.grid(row=2,column=1,padx=5,pady=0) 108 | 109 | label_cantidad=Label(self.frame_registro,text="Cantidad: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=8) 110 | self.cantidad=Entry(self.frame_registro,width=25) 111 | self.cantidad.grid(row=0, column=3, padx=5, pady=8) 112 | 113 | label_precio=Label(self.frame_registro,text="Precio ($): ",font=("Comic Sans", 10,"bold")).grid(row=1,column=2,sticky='s',padx=5,pady=8) 114 | self.precio=Entry(self.frame_registro,width=25) 115 | self.precio.grid(row=1, column=3, padx=5, pady=8) 116 | 117 | label_descripcion=Label(self.frame_registro,text="Descripcion: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=2,sticky='s',padx=10,pady=8) 118 | self.descripcion=Entry(self.frame_registro,width=25) 119 | self.descripcion.grid(row=2, column=3, padx=10, pady=8) 120 | 121 | "--------------- Frame botones --------------------" 122 | self.frame_botones_registro.config(bd=0) 123 | self.frame_botones_registro.grid(row=2,column=0,padx=5,pady=5) 124 | 125 | "--------------- Botones --------------------" 126 | boton_registrar=Button(self.frame_botones_registro,text="REGISTRAR",command=self.Agregar_producto,height=2,width=12,bg="green",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=1, padx=10, pady=10) 127 | boton_editar=Button(self.frame_botones_registro,text="EDITAR",command=self.Editar_producto ,height=2,width=12,bg="gray",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=2, padx=10, pady=10) 128 | boton_eliminar=Button(self.frame_botones_registro,text="ELIMINAR",command=self.Eliminar_producto,height=2,width=12,bg="red",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=3, padx=10, pady=10) 129 | 130 | "--------------- Tabla --------------------" 131 | self.frame_tabla_crud.config(bd=2) 132 | self.frame_tabla_crud.grid(row=3,column=0,padx=5,pady=5) 133 | 134 | self.tree=ttk.Treeview(self.frame_tabla_crud,height=11, columns=("columna1","columna2","columna3","columna4","columna5")) 135 | self.tree.heading("#0",text='Codigo', anchor=CENTER) 136 | self.tree.column("#0", width=90, minwidth=75, stretch=NO) 137 | 138 | self.tree.heading("columna1",text='Nombre', anchor=CENTER) 139 | self.tree.column("columna1", width=150, minwidth=75, stretch=NO) 140 | 141 | self.tree.heading("columna2",text='Categoria', anchor=CENTER) 142 | self.tree.column("columna2", width=150, minwidth=75, stretch=NO) 143 | 144 | self.tree.heading("columna3",text='Cantidad', anchor=CENTER) 145 | self.tree.column("columna3", width=70, minwidth=60, stretch=NO) 146 | 147 | self.tree.heading("columna4",text='Precio', anchor=CENTER) 148 | self.tree.column("columna4", width=70, minwidth=60, stretch=NO) 149 | 150 | self.tree.heading("columna5",text='Descripcion', anchor=CENTER) 151 | 152 | self.tree.grid(row=0,column=0,sticky=E) 153 | 154 | self.Obtener_productos() 155 | 156 | #REMOVER OTROS WIDGETS 157 | self.widgets_buscador_remove() 158 | self.widgets_informacion_remove() 159 | self.widgets_cliente_remove() 160 | self.widgets_codigos_remove() 161 | self.widgets_ventas_remove() 162 | self.widgets_nueva_venta_remove() 163 | 164 | def widgets_buscador(self): 165 | 166 | "--------------- Frame marco buscar --------------------" 167 | self.frame_buscar_producto.config(bd=2) 168 | self.frame_buscar_producto.grid(row=1,column=0,padx=5,pady=5) 169 | 170 | "--------------- Formulario Buscar--------------------" 171 | self.label_buscar=Label(self.frame_buscar_producto,text="Buscar Por: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=5) 172 | self.combo_buscar=ttk.Combobox(self.frame_buscar_producto,values=["Codigo","Nombre"], width=22,state="readonly") 173 | self.combo_buscar.current(0) 174 | self.combo_buscar.grid(row=0,column=1,padx=5,pady=5) 175 | 176 | label_codigo_codigo=Label(self.frame_buscar_producto,text="Codigo / Nombre del producto: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=5) 177 | self.codigo_nombre=Entry(self.frame_buscar_producto,width=25) 178 | self.codigo_nombre.focus() 179 | self.codigo_nombre.grid(row=0, column=3, padx=10, pady=5) 180 | 181 | "--------------- Frame marco --------------------" 182 | self.frame_boton_buscar.config(bd=0) 183 | self.frame_boton_buscar.grid(row=2,column=0,padx=5,pady=5) 184 | "--------------- Boton --------------------" 185 | self.boton_buscar=Button(self.frame_boton_buscar,text="BUSCAR",command=self.Buscar_productos,height=2,width=20,bg="black",fg="white",font=("Comic Sans", 10,"bold")) 186 | self.boton_buscar.grid(row=0,column=0,padx=5,pady=5) 187 | 188 | "--------------- Tabla --------------------" 189 | self.frame_tabla_buscador.config(bd=2) 190 | self.frame_tabla_buscador.grid(row=3,column=0,padx=5,pady=5) 191 | 192 | self.tree_buscar=ttk.Treeview(self.frame_tabla_buscador,height=11, columns=("columna1","columna2","columna3","columna4","columna5")) 193 | self.tree_buscar.heading("#0",text='Codigo', anchor=CENTER) 194 | self.tree_buscar.column("#0", width=90, minwidth=75, stretch=NO) 195 | 196 | self.tree_buscar.heading("columna1",text='Nombre', anchor=CENTER) 197 | self.tree_buscar.column("columna1", width=150, minwidth=75, stretch=NO) 198 | 199 | self.tree_buscar.heading("columna2",text='Categoria', anchor=CENTER) 200 | self.tree_buscar.column("columna2", width=150, minwidth=75, stretch=NO) 201 | 202 | self.tree_buscar.heading("columna3",text='Cantidad', anchor=CENTER) 203 | self.tree_buscar.column("columna3", width=70, minwidth=60, stretch=NO) 204 | 205 | self.tree_buscar.heading("columna4",text='Precio', anchor=CENTER) 206 | self.tree_buscar.column("columna4", width=70, minwidth=60, stretch=NO) 207 | 208 | self.tree_buscar.heading("columna5",text='Descripcion', anchor=CENTER) 209 | 210 | self.tree_buscar.grid(row=0,column=0,sticky=E) 211 | self.Obtener_productos() 212 | self.tree_buscar.delete(*self.tree_buscar.get_children()) 213 | 214 | #REMOVER OTROS WIDGETS 215 | self.widgets_crud_remove() 216 | self.widgets_informacion_remove() 217 | self.widgets_cliente_remove() 218 | self.widgets_codigos_remove() 219 | self.widgets_ventas_remove() 220 | self.widgets_nueva_venta_remove() 221 | 222 | def widgets_cliente(self): 223 | 224 | "--------------- Frame marco buscar --------------------" 225 | self.frame_nuevo_cliente.config(bd=2) 226 | self.frame_nuevo_cliente.grid(row=1,column=0,padx=5,pady=5) 227 | 228 | "--------------- Registrar cliente --------------------" 229 | self.label_dni=Label(self.frame_nuevo_cliente,text="DNI: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=5) 230 | self.dni=Entry(self.frame_nuevo_cliente,width=25) 231 | self.dni.focus() 232 | self.dni.grid(row=0,column=1,padx=5,pady=5) 233 | 234 | self.label_nombres=Label(self.frame_nuevo_cliente,text="Nombres: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=5,pady=5) 235 | self.nombres=Entry(self.frame_nuevo_cliente,width=25) 236 | self.nombres.grid(row=1, column=1, padx=10, pady=5) 237 | 238 | self.label_apellidos=Label(self.frame_nuevo_cliente,text="Apellidos: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=5,pady=5) 239 | self.apellidos=Entry(self.frame_nuevo_cliente,width=25) 240 | self.apellidos.grid(row=2, column=1, padx=10, pady=5) 241 | 242 | self.label_telefono=Label(self.frame_nuevo_cliente,text="Telefono: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=5) 243 | self.telefono=Entry(self.frame_nuevo_cliente,width=25) 244 | self.telefono.grid(row=0, column=3, padx=10, pady=5) 245 | 246 | self.label_email=Label(self.frame_nuevo_cliente,text="E-mail: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=2,sticky='s',padx=5,pady=5) 247 | self.email=Entry(self.frame_nuevo_cliente,width=25) 248 | self.email.grid(row=1, column=3, padx=10, pady=5) 249 | 250 | self.label_direccion=Label(self.frame_nuevo_cliente,text="Direccion: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=2,sticky='s',padx=5,pady=5) 251 | self.direccion=Entry(self.frame_nuevo_cliente,width=30) 252 | self.direccion.grid(row=2, column=3, padx=10, pady=5) 253 | 254 | "--------------- Frame botones --------------------" 255 | self.boton_registrar=Button(self.frame_nuevo_cliente,text="REGISTRAR",command=self.Agregar_cliente,height=1,width=15,bg="green",fg="white",font=("Comic Sans", 10,"bold")) 256 | self.boton_registrar.grid(row=0,column=4,padx=10,pady=5) 257 | 258 | self.boton_editar=Button(self.frame_nuevo_cliente,text="EDITAR",command=self.Editar_cliente,height=1,width=15,bg="gray",fg="white",font=("Comic Sans", 10,"bold")) 259 | self.boton_editar.grid(row=1,column=4,padx=10,pady=5) 260 | 261 | self.boton_eliminar=Button(self.frame_nuevo_cliente,text="ELIMINAR",command=self.Eliminar_cliente,height=1,width=15,bg="red",fg="white",font=("Comic Sans", 10,"bold")) 262 | self.boton_eliminar.grid(row=2,column=4,padx=10,pady=5) 263 | 264 | "--------------- Tabla --------------------" 265 | self.frame_tabla_clientes.config(bd=2) 266 | self.frame_tabla_clientes.grid(row=2,column=0,padx=5,pady=5) 267 | 268 | self.tree_cliente=ttk.Treeview(self.frame_tabla_clientes,height=11, columns=("columna1","columna2","columna3","columna4","columna5")) 269 | self.tree_cliente.heading("#0",text='DNI', anchor=CENTER) 270 | self.tree_cliente.column("#0", width=90, minwidth=75, stretch=NO) 271 | 272 | self.tree_cliente.heading("columna1",text='Nombre', anchor=CENTER) 273 | self.tree_cliente.column("columna1", width=150, minwidth=75, stretch=NO) 274 | 275 | self.tree_cliente.heading("columna2",text='Apellidos', anchor=CENTER) 276 | self.tree_cliente.column("columna2", width=150, minwidth=75, stretch=NO) 277 | 278 | self.tree_cliente.heading("columna3",text='Telefono', anchor=CENTER) 279 | self.tree_cliente.column("columna3", width=70, minwidth=60, stretch=NO) 280 | 281 | self.tree_cliente.heading("columna4",text='E-mail', anchor=CENTER) 282 | self.tree_cliente.column("columna4", width=70, minwidth=60, stretch=NO) 283 | 284 | self.tree_cliente.heading("columna5",text='Direccion', anchor=CENTER) 285 | 286 | self.tree_cliente.grid(row=0,column=0,sticky=E) 287 | self.Obtener_clientes() 288 | #self.tree_cliente.delete(*self.tree_cliente.get_children()) 289 | 290 | "--------------- Frame buscar --------------------" 291 | self.frame_buscar_cliente.config(bd=2) 292 | self.frame_buscar_cliente.grid(row=4,column=0,padx=5,pady=5) 293 | "--------------- Buscar cliente --------------------" 294 | self.label_buscar_cliente=Label(self.frame_buscar_cliente,text="DNI: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=20,pady=10) 295 | self.buscar_dni=Entry(self.frame_buscar_cliente,width=30) 296 | self.buscar_dni.grid(row=0, column=1, padx=30, pady=5) 297 | self.boton_buscar=Button(self.frame_buscar_cliente,text="BUSCAR",command=self.Buscar_cliente,height=1,width=15,bg="black",fg="white",font=("Comic Sans", 10,"bold")) 298 | self.boton_buscar.grid(row=0,column=2,padx=30,pady=5) 299 | 300 | self.widgets_buscador_remove() 301 | self.widgets_crud_remove() 302 | self.widgets_informacion_remove() 303 | self.widgets_codigos_remove() 304 | self.widgets_ventas_remove() 305 | self.widgets_nueva_venta_remove() 306 | 307 | def widgets_codigos(self): 308 | self.frame_codigo.config(bd=0) 309 | self.frame_codigo.grid(row=0,column=0) 310 | imagen=Image.open("./PROYECTO_TIENDA/img/codigos.png") 311 | nueva_imagen=imagen.resize((750,650)) 312 | render=ImageTk.PhotoImage(nueva_imagen) 313 | label_imagen= Label(self.frame_codigo, image= render) 314 | label_imagen.image=render 315 | label_imagen.grid(row=0,column=0) 316 | 317 | self.widgets_buscador_remove() 318 | self.widgets_crud_remove() 319 | self.widgets_cliente_remove() 320 | self.widgets_informacion_remove() 321 | self.widgets_ventas_remove() 322 | self.widgets_nueva_venta_remove() 323 | 324 | def widgets_informacion(self): 325 | 326 | self.Label_informacion.config(bd=0) 327 | self.Label_informacion.grid(row=0,column=0) 328 | "--------------- Titulo --------------------" 329 | self.Label_titulo = Label(self.Label_informacion,text="APLICACION DE ESCRITORIO",fg="white",bg="black",font=("Comic Sans", 23,"bold"),padx=150,pady=20) 330 | self.Label_titulo.grid(row=0,column=0) 331 | 332 | "--------------- Logos imagenes--------------------" 333 | #Logo 334 | imagen=Image.open("./PROYECTO_TIENDA/img/app_logo_2.png") 335 | nueva_imagen=imagen.resize((170,170)) 336 | render=ImageTk.PhotoImage(nueva_imagen) 337 | label_imagen= Label(self.Label_informacion, image= render) 338 | label_imagen.image=render 339 | label_imagen.grid(row=1,column=0,padx=10,pady=15) 340 | 341 | "--------------- opciones--------------------" 342 | self.Label_titulo = Label(self.Label_informacion,text="> CONTROL DE PRODUCTOS ",fg="black",font=("Comic Sans", 16,"bold")) 343 | self.Label_titulo.grid(row=2,column=0,sticky=W,padx=30,pady=10) 344 | 345 | self.Label_titulo = Label(self.Label_informacion,text="> BUSCADOR DE PRODUCTOS ",fg="black",font=("Comic Sans", 16,"bold")) 346 | self.Label_titulo.grid(row=3,column=0,sticky=W,padx=30,pady=10) 347 | 348 | self.Label_titulo = Label(self.Label_informacion,text="> REGISTRO VENTAS ",fg="black",font=("Comic Sans", 16,"bold")) 349 | self.Label_titulo.grid(row=4,column=0,sticky=W,padx=30,pady=10) 350 | 351 | self.Label_titulo = Label(self.Label_informacion,text="> GENERACION DE REPORTE ",fg="black",font=("Comic Sans", 16,"bold")) 352 | self.Label_titulo.grid(row=5,column=0,sticky=W,padx=30,pady=10) 353 | 354 | self.Label_titulo = Label(self.Label_informacion,text="Creado por Emiliano Diaz - 2023",fg="black",font=("Comic Sans",12,"bold")) 355 | self.Label_titulo.grid(row=6,column=0,pady=85) 356 | 357 | #Remove 358 | self.widgets_buscador_remove() 359 | self.widgets_crud_remove() 360 | self.widgets_cliente_remove() 361 | self.widgets_codigos_remove() 362 | self.widgets_ventas_remove() 363 | self.widgets_nueva_venta_remove() 364 | 365 | def widgets_nueva_venta(self): 366 | "--------------- Frame marco dni_ventas --------------------" 367 | self.frame_dni_venta.config(bd=1) 368 | self.frame_dni_venta.grid(row=1,column=0,padx=5,pady=5) 369 | 370 | label_dni_venta=Label(self.frame_dni_venta,text="DNI: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=5) 371 | self.dni_venta=Entry(self.frame_dni_venta,width=25) 372 | self.dni_venta.focus() 373 | self.dni_venta.grid(row=0, column=1, padx=10, pady=5) 374 | 375 | label_medio_pago=Label(self.frame_dni_venta,text="Medio de pago: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=5) 376 | self.combo_medio_pago=ttk.Combobox(self.frame_dni_venta,values=["Efectivo","Tarjeta","Transferencia"], width=22,state="readonly") 377 | self.combo_medio_pago.current(0) 378 | self.combo_medio_pago.grid(row=0,column=3,padx=5,pady=5) 379 | 380 | "--------------- Frame marco nueva venta --------------------" 381 | self.frame_nueva_venta.config(bd=2) 382 | self.frame_nueva_venta.grid(row=2,column=0,padx=5,pady=5) 383 | 384 | label_codigo_producto_venta=Label(self.frame_nueva_venta,text="Codigo: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=5) 385 | self.codigo_producto_venta=Entry(self.frame_nueva_venta,width=25) 386 | self.codigo_producto_venta.focus() 387 | self.codigo_producto_venta.grid(row=0, column=1, padx=10, pady=5) 388 | 389 | label_cantidad_producto_venta=Label(self.frame_nueva_venta,text="Cantidad: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=5,pady=5) 390 | self.cantidad_producto_venta=Entry(self.frame_nueva_venta,width=25) 391 | self.cantidad_producto_venta.grid(row=1, column=1, padx=10, pady=5) 392 | 393 | self.boton_agregar_producto_venta=Button(self.frame_nueva_venta,text="AGREGAR",command=self.Agregar_producto_venta,height=1,width=15,bg="green",fg="white",font=("Comic Sans", 10,"bold")) 394 | self.boton_agregar_producto_venta.grid(row=0,column=2,padx=5,pady=5) 395 | 396 | self.boton_eliminar_producto_venta=Button(self.frame_nueva_venta,text="ELIMINAR",command=self.Eliminar_producto_venta,height=1,width=15,bg="red",fg="white",font=("Comic Sans", 10,"bold")) 397 | self.boton_eliminar_producto_venta.grid(row=1,column=2,padx=5,pady=5) 398 | 399 | "--------------- Tabla --------------------" 400 | self.frame_tabla_nueva_venta.config(bd=2) 401 | self.frame_tabla_nueva_venta.grid(row=3,column=0,padx=5,pady=5) 402 | 403 | self.tree_nueva_venta=ttk.Treeview(self.frame_tabla_nueva_venta,height=11, columns=("columna1","columna2","columna3","columna4","columna5")) 404 | self.tree_nueva_venta.heading("#0",text='Codigo', anchor=CENTER) 405 | self.tree_nueva_venta.column("#0", width=90, minwidth=75, stretch=NO) 406 | 407 | self.tree_nueva_venta.heading("columna1",text='Producto', anchor=CENTER) 408 | self.tree_nueva_venta.column("columna1", width=150, minwidth=75, stretch=NO) 409 | 410 | self.tree_nueva_venta.heading("columna2",text='Descripcion', anchor=CENTER) 411 | self.tree_nueva_venta.column("columna2", width=150, minwidth=75, stretch=NO) 412 | 413 | self.tree_nueva_venta.heading("columna3",text='Precio', anchor=CENTER) 414 | self.tree_nueva_venta.column("columna3", width=70, minwidth=60, stretch=NO) 415 | 416 | self.tree_nueva_venta.heading("columna4",text='Cantidad', anchor=CENTER) 417 | self.tree_nueva_venta.column("columna4", width=70, minwidth=60, stretch=NO) 418 | 419 | self.tree_nueva_venta.heading("columna5",text='Subtotal', anchor=CENTER) 420 | 421 | self.tree_nueva_venta.grid(row=0,column=0,sticky=E) 422 | 423 | "--------------- Finalizar venta --------------------" 424 | self.frame_finalizar_venta.config(bd=1) 425 | self.frame_finalizar_venta.grid(row=4,column=0,padx=5,pady=5,sticky=E) 426 | 427 | self.boton_finalizar_venta=Button(self.frame_finalizar_venta,text="Finalizar venta",command=self.Finalizar_venta,height=2,width=15,bg="black",fg="white",font=("Comic Sans", 12,"bold")) 428 | self.boton_finalizar_venta.grid(row=0,column=0,padx=5,pady=5) 429 | 430 | label_venta_total=Label(self.frame_finalizar_venta,text="Venta total ($): ",font=("Comic Sans", 12,"bold")).grid(row=0,column=1,padx=5,pady=5) 431 | self.venta_total=Label(self.frame_finalizar_venta,text="0.00",font=("Comic Sans", 12,"bold"),height=1,width=10,bg="blue",fg="white") 432 | self.venta_total.grid(row=0, column=2, padx=10, pady=5) 433 | 434 | self.widgets_crud_remove() 435 | self.widgets_codigos_remove() 436 | self.widgets_buscador_remove() 437 | self.widgets_informacion_remove() 438 | self.widgets_cliente_remove() 439 | self.widgets_ventas_remove() 440 | 441 | def widgets_ventas(self): 442 | "--------------- Frame marco ventas --------------------" 443 | self.frame_buscar_ventas.config(bd=2) 444 | self.frame_buscar_ventas.grid(row=1,column=0,padx=5,pady=5) 445 | 446 | "--------------- Formulario Buscar ventas--------------------" 447 | self.label_buscar_venta=Label(self.frame_buscar_ventas,text="Buscar Por: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=5) 448 | self.combo_buscar_venta=ttk.Combobox(self.frame_buscar_ventas,values=["DNI","Fecha"], width=22,state="readonly") 449 | self.combo_buscar_venta.current(0) 450 | self.combo_buscar_venta.grid(row=0,column=1,padx=5,pady=5) 451 | 452 | label_dni_fecha=Label(self.frame_buscar_ventas,text="DNI / Fecha: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=5) 453 | self.dni_fecha=Entry(self.frame_buscar_ventas,width=25) 454 | self.dni_fecha.focus() 455 | self.dni_fecha.grid(row=0, column=3, padx=10, pady=5) 456 | 457 | "--------------- Frame marco ventas--------------------" 458 | self.frame_boton_buscar_ventas.config(bd=0) 459 | self.frame_boton_buscar_ventas.grid(row=2,column=0,padx=5,pady=5) 460 | "--------------- Boton --------------------" 461 | self.boton_buscar_ventas=Button(self.frame_boton_buscar_ventas,text="BUSCAR",command=self.Buscar_venta,height=2,width=20,bg="black",fg="white",font=("Comic Sans", 10,"bold")) 462 | self.boton_buscar_ventas.grid(row=0,column=0,padx=5,pady=5) 463 | 464 | "--------------- Tabla --------------------" 465 | self.frame_tabla_ventas.config(bd=2) 466 | self.frame_tabla_ventas.grid(row=3,column=0,padx=5,pady=5) 467 | 468 | self.tree_buscar_ventas=ttk.Treeview(self.frame_tabla_ventas,height=11, columns=("columna1","columna2","columna3","columna4","columna5")) 469 | self.tree_buscar_ventas.heading("#0",text='Fecha', anchor=CENTER) 470 | self.tree_buscar_ventas.column("#0", width=150, minwidth=75, stretch=NO) 471 | 472 | self.tree_buscar_ventas.heading("columna1",text='DNI', anchor=CENTER) 473 | self.tree_buscar_ventas.column("columna1", width=90, minwidth=60, stretch=NO) 474 | 475 | self.tree_buscar_ventas.heading("columna2",text='Nombres', anchor=CENTER) 476 | self.tree_buscar_ventas.column("columna2", width=90, minwidth=60, stretch=NO) 477 | 478 | self.tree_buscar_ventas.heading("columna3",text='Apellidos', anchor=CENTER) 479 | self.tree_buscar_ventas.column("columna3", width=90, minwidth=60, stretch=NO) 480 | 481 | self.tree_buscar_ventas.heading("columna4",text='Medio de pago', anchor=CENTER) 482 | self.tree_buscar_ventas.column("columna4", width=110, minwidth=75, stretch=NO) 483 | 484 | self.tree_buscar_ventas.heading("columna5",text='Venta total', anchor=CENTER) 485 | 486 | self.tree_buscar_ventas.grid(row=0,column=0,sticky=E) 487 | 488 | self.widgets_crud_remove() 489 | self.widgets_codigos_remove() 490 | self.widgets_buscador_remove() 491 | self.widgets_informacion_remove() 492 | self.widgets_cliente_remove() 493 | self.widgets_nueva_venta_remove() 494 | 495 | "--------------- WIDGETS REMOVE --------------------" 496 | def widgets_crud_remove(self): 497 | self.frame_registro.grid_remove() 498 | self.frame_botones_registro.grid_remove() 499 | self.frame_tabla_crud.grid_remove() 500 | 501 | def widgets_buscador_remove(self): 502 | self.frame_buscar_producto.grid_remove() 503 | self.frame_boton_buscar.grid_remove() 504 | self.frame_tabla_buscador.grid_remove() 505 | 506 | def widgets_informacion_remove(self): 507 | self.Label_informacion.grid_remove() 508 | 509 | def widgets_cliente_remove(self): 510 | self.frame_nuevo_cliente.grid_remove() 511 | self.frame_buscar_cliente.grid_remove() 512 | self.frame_tabla_clientes.grid_remove() 513 | 514 | def widgets_codigos_remove(self): 515 | self.frame_codigo.grid_remove() 516 | 517 | def widgets_ventas_remove(self): 518 | self.frame_buscar_ventas.grid_remove() 519 | self.frame_boton_buscar_ventas.grid_remove() 520 | self.frame_tabla_ventas.grid_remove() 521 | 522 | def widgets_nueva_venta_remove(self): 523 | self.frame_dni_venta.grid_remove() 524 | self.frame_nueva_venta.grid_remove() 525 | self.frame_tabla_nueva_venta.grid_remove() 526 | self.frame_finalizar_venta.grid_remove() 527 | "--------------- CRUD --------------------" 528 | def Obtener_productos(self): 529 | records=self.tree.get_children() 530 | for element in records: 531 | self.tree.delete(element) 532 | query='SELECT * FROM Productos ORDER BY id_producto asc' 533 | db_rows=self.Ejecutar_consulta(query) 534 | for row in db_rows: 535 | self.tree.insert("",0, text=row[1],values=(row[2],row[3],row[4],row[5],row[6])) 536 | 537 | def Agregar_producto(self): 538 | if self.Validar_formulario_completo() and self.Validar_registrar(): 539 | query='INSERT INTO Productos VALUES(NULL, ?, ?, ?, ?, ?, ?)' 540 | parameters = (self.codigo.get(),self.nombre.get(),self.combo_categoria.get(),self.cantidad.get(),self.precio.get(),self.descripcion.get()) 541 | self.Ejecutar_consulta(query, parameters) 542 | messagebox.showinfo("REGISTRO EXITOSO", f'Producto registrado: {self.nombre.get()}') 543 | print('REGISTRADO') 544 | self.Limpiar_formulario() 545 | self.Obtener_productos() 546 | 547 | def Eliminar_producto(self): 548 | try: 549 | self.tree.item(self.tree.selection())['text'][0] 550 | except IndexError as e: 551 | messagebox.showerror("ERROR","Porfavor selecciona un elemento") 552 | return 553 | dato=self.tree.item(self.tree.selection())['text'] 554 | nombre=self.tree.item(self.tree.selection())['values'][0] 555 | query="DELETE FROM Productos WHERE Codigo = ?" 556 | respuesta=messagebox.askquestion("ADVERTENCIA",f"¿Seguro que desea eliminar el producto: {nombre}?") 557 | if respuesta == 'yes': 558 | self.Ejecutar_consulta(query,(dato,)) 559 | self.Obtener_productos() 560 | messagebox.showinfo('EXITO',f'Producto eliminado: {nombre}') 561 | else: 562 | messagebox.showerror('ERROR',f'Error al eliminar el producto: {nombre}') 563 | 564 | def Editar_producto(self): 565 | try: 566 | self.tree.item(self.tree.selection())['text'][0] 567 | except IndexError as e: 568 | messagebox.showerror("ERROR","Porfavor selecciona un elemento") 569 | return 570 | codigo=self.tree.item(self.tree.selection())['text'] 571 | nombre=self.tree.item(self.tree.selection())['values'][0] 572 | categoria=self.tree.item(self.tree.selection())['values'][1] 573 | cantidad=self.tree.item(self.tree.selection())['values'][2] 574 | precio=self.tree.item(self.tree.selection())['values'][3] 575 | descripcion=self.tree.item(self.tree.selection())['values'][4] 576 | 577 | self.Ventana_editar = Toplevel() 578 | self.Ventana_editar.title('EDITAR PRODUCTO') 579 | self.Ventana_editar.resizable(0,0) 580 | 581 | #Valores ventana editar 582 | label_codigo=Label(self.Ventana_editar,text="Codigo del producto: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 583 | nuevo_codigo=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=codigo),width=25) 584 | nuevo_codigo.grid(row=0, column=1, padx=5, pady=8) 585 | 586 | label_nombre=Label(self.Ventana_editar,text="Nombre del producto: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=5,pady=8) 587 | nuevo_nombre=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=nombre),width=25) 588 | nuevo_nombre.grid(row=1, column=1, padx=5, pady=8) 589 | 590 | label_categoria=Label(self.Ventana_editar,text="Categoria: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=5,pady=9) 591 | nuevo_combo_categoria=ttk.Combobox(self.Ventana_editar,values=["Componentes","Perifericos"], width=22,state="readonly") 592 | nuevo_combo_categoria.set(categoria) 593 | nuevo_combo_categoria.grid(row=2,column=1,padx=5,pady=0) 594 | 595 | label_cantidad=Label(self.Ventana_editar,text="Cantidad: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=8) 596 | nueva_cantidad=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=cantidad),width=25) 597 | nueva_cantidad.grid(row=0, column=3, padx=5, pady=8) 598 | 599 | label_precio=Label(self.Ventana_editar,text="Precio ($): ",font=("Comic Sans", 10,"bold")).grid(row=1,column=2,sticky='s',padx=5,pady=8) 600 | nuevo_precio=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=precio),width=25) 601 | nuevo_precio.grid(row=1, column=3, padx=5, pady=8) 602 | 603 | label_descripcion=Label(self.Ventana_editar,text="Descripcion: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=2,sticky='s',padx=10,pady=8) 604 | nueva_descripcion=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=descripcion),width=25) 605 | nueva_descripcion.grid(row=2, column=3, padx=10, pady=8) 606 | 607 | boton_actualizar=Button(self.Ventana_editar,text="ACTUALIZAR",command= lambda: self.Actualizar(nuevo_codigo.get(),nuevo_nombre.get(),nuevo_combo_categoria.get(),nueva_cantidad.get(),nuevo_precio.get(),nueva_descripcion.get(),codigo,nombre),height=2,width=20,bg="black",fg="white",font=("Comic Sans", 10,"bold")) 608 | boton_actualizar.grid(row=3, column=1,columnspan=2, padx=10, pady=15) 609 | 610 | self.Ventana_editar.mainloop() 611 | 612 | def Actualizar(self,nuevo_codigo,nuevo_nombre,nuevo_combo_categoria,nueva_cantidad,nuevo_precio,nueva_descripcion,codigo,nombre): 613 | query='UPDATE Productos SET Codigo = ?, Nombre = ?, Categoria = ?, Cantidad =?, Precio=?, Descripcion =? WHERE Codigo = ? AND Nombre =?' 614 | parameters=(nuevo_codigo,nuevo_nombre,nuevo_combo_categoria,nueva_cantidad,nuevo_precio,nueva_descripcion,codigo,nombre) 615 | self.Ejecutar_consulta(query,parameters) 616 | messagebox.showinfo('EXITO',f'Producto actualizado:{nuevo_nombre}') 617 | self.Ventana_editar.destroy() 618 | self.Obtener_productos() 619 | 620 | def Buscar_productos(self): 621 | if(self.Validar_busqueda()): 622 | #Obtener todos los elementos con get_children(), que retorna una tupla de ID. 623 | records=self.tree_buscar.get_children() 624 | for element in records: 625 | self.tree_buscar.delete(element) 626 | if (self.combo_buscar.get()=='Codigo'): 627 | query=("SELECT * FROM Productos WHERE Codigo LIKE ? ") 628 | parameters=(self.codigo_nombre.get()+"%") 629 | db_rows=self.Ejecutar_consulta(query,(parameters,)) 630 | for row in db_rows: 631 | self.tree_buscar.insert("",0, text=row[1],values=(row[2],row[3],row[4],row[5],row[6])) 632 | if(list(self.tree.get_children())==[]): 633 | messagebox.showerror("ERROR","Producto no encontrado") 634 | else: 635 | query=("SELECT * FROM Productos WHERE Nombre LIKE ? ") 636 | parameters=("%"+self.codigo_nombre.get()+"%") 637 | db_rows=self.Ejecutar_consulta(query,(parameters,)) 638 | for row in db_rows: 639 | self.tree_buscar.insert("",0, text=row[1],values=(row[2],row[3],row[4],row[5],row[6])) 640 | if(list(self.tree.get_children())==[]): 641 | messagebox.showerror("ERROR","Producto no encontrado") 642 | 643 | "--------------- OTRAS FUNCIONES PRODUCTOS--------------------" 644 | def Ejecutar_consulta(self, query, parameters=()): 645 | with sqlite3.connect(self.db_name) as conexion: 646 | cursor=conexion.cursor() 647 | result=cursor.execute(query,parameters) 648 | conexion.commit() 649 | return result 650 | 651 | def Validar_formulario_completo(self): 652 | if len(self.codigo.get()) !=0 and len(self.nombre.get()) !=0 and len(self.combo_categoria.get()) !=0 and len(self.cantidad.get()) !=0 and len(self.precio.get()) !=0 and len(self.descripcion.get()) !=0: 653 | return True 654 | else: 655 | messagebox.showerror("ERROR", "Complete todos los campos del formulario") 656 | 657 | def Validar_busqueda(self): 658 | if len(self.codigo_nombre.get()) !=0: 659 | return True 660 | else: 661 | self.tree.delete(*self.tree.get_children()) 662 | messagebox.showerror("ERROR", "Complete todos los campos para la busqueda") 663 | 664 | def Limpiar_formulario(self): 665 | self.codigo.delete(0, END) 666 | self.nombre.delete(0, END) 667 | self.cantidad.delete(0, END) 668 | self.precio.delete(0, END) 669 | self.descripcion.delete(0, END) 670 | 671 | def Validar_registrar(self): 672 | parameters= self.codigo.get() 673 | query="SELECT * FROM Productos WHERE Codigo = ?" 674 | dato = self.Ejecutar_consulta(query,(parameters,)) 675 | if (dato.fetchall() == []): 676 | return True 677 | else: 678 | messagebox.showerror("ERROR EN REGISTRO", "Codigo registrado anteriormente") 679 | 680 | "--------------- CLIENTES--------------------" 681 | def Obtener_clientes(self): 682 | records=self.tree_cliente.get_children() 683 | for element in records: 684 | self.tree_cliente.delete(element) 685 | query='SELECT * FROM Clientes' 686 | db_rows=self.Ejecutar_consulta(query) 687 | for row in db_rows: 688 | self.tree_cliente.insert("",0, text=row[0],values=(row[1],row[2],row[3],row[4],row[5])) 689 | 690 | def Agregar_cliente(self): 691 | if self.Validar_formulario_completo_cliente() and self.Validar_registrar_cliente(): 692 | query='INSERT INTO Clientes VALUES(?, ?, ?, ?, ?, ?)' 693 | parameters = (self.dni.get(),self.nombres.get(),self.apellidos.get(),self.telefono.get(),self.email.get(),self.direccion.get()) 694 | self.Ejecutar_consulta(query, parameters) 695 | messagebox.showinfo("REGISTRO EXITOSO", f'Cliente registrado: {self.dni.get()}') 696 | print('REGISTRADO') 697 | self.Limpiar_formulario_cliente() 698 | self.Obtener_clientes() 699 | 700 | def Eliminar_cliente(self): 701 | try: 702 | self.tree_cliente.item(self.tree_cliente.selection())['text'] 703 | except IndexError as e: 704 | messagebox.showerror("ERROR","Porfavor selecciona un elemento") 705 | return 706 | dato=self.tree_cliente.item(self.tree_cliente.selection())['text'] 707 | nombre=self.tree_cliente.item(self.tree_cliente.selection())['values'][1] 708 | query="DELETE FROM Clientes WHERE DNI = ?" 709 | respuesta=messagebox.askquestion("ADVERTENCIA",f"¿Seguro que desea eliminar el cliente: {dato} - {nombre}?") 710 | if respuesta == 'yes': 711 | self.Ejecutar_consulta(query,(dato,)) 712 | self.Obtener_clientes() 713 | messagebox.showinfo('EXITO',f'Cliente eliminado: {dato} - {nombre}') 714 | else: 715 | messagebox.showerror('ERROR',f'Error al eliminar el producto: {dato} - {nombre}') 716 | 717 | def Editar_cliente(self): 718 | try: 719 | self.tree_cliente.item(self.tree_cliente.selection())['text'] 720 | except IndexError as e: 721 | messagebox.showerror("ERROR","Porfavor selecciona un elemento") 722 | return 723 | dni=self.tree_cliente.item(self.tree_cliente.selection())['text'] 724 | nombres=self.tree_cliente.item(self.tree_cliente.selection())['values'][0] 725 | apellidos=self.tree_cliente.item(self.tree_cliente.selection())['values'][1] 726 | telefono=self.tree_cliente.item(self.tree_cliente.selection())['values'][2] 727 | email=self.tree_cliente.item(self.tree_cliente.selection())['values'][3] 728 | direccion=self.tree_cliente.item(self.tree_cliente.selection())['values'][4] 729 | 730 | self.Ventana_editar_cliente = Toplevel() 731 | self.Ventana_editar_cliente.title('EDITAR CLIENTE') 732 | self.Ventana_editar_cliente.resizable(0,0) 733 | 734 | #Valores ventana editar 735 | label_dni=Label(self.Ventana_editar_cliente,text="DNI: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 736 | nuevo_dni=Entry(self.Ventana_editar_cliente,textvariable=StringVar(self.Ventana_editar_cliente,value=dni),width=25) 737 | nuevo_dni.grid(row=0, column=1, padx=5, pady=8) 738 | 739 | label_nombres=Label(self.Ventana_editar_cliente,text="Nombres: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=5,pady=8) 740 | nuevo_nombres=Entry(self.Ventana_editar_cliente,textvariable=StringVar(self.Ventana_editar_cliente,value=nombres),width=25) 741 | nuevo_nombres.grid(row=1, column=1, padx=5, pady=8) 742 | 743 | label_apellidos=Label(self.Ventana_editar_cliente,text="Apellidos: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=5,pady=9) 744 | nuevo_apellidos=Entry(self.Ventana_editar_cliente,textvariable=StringVar(self.Ventana_editar_cliente,value=apellidos),width=25) 745 | nuevo_apellidos.grid(row=2,column=1,padx=5,pady=0) 746 | 747 | label_telefono=Label(self.Ventana_editar_cliente,text="Telefono: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=8) 748 | nueva_telefono=Entry(self.Ventana_editar_cliente,textvariable=StringVar(self.Ventana_editar_cliente,value=telefono),width=25) 749 | nueva_telefono.grid(row=0, column=3, padx=5, pady=8) 750 | 751 | label_email=Label(self.Ventana_editar_cliente,text="E-mail: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=2,sticky='s',padx=5,pady=8) 752 | nuevo_email=Entry(self.Ventana_editar_cliente,textvariable=StringVar(self.Ventana_editar_cliente,value=email),width=25) 753 | nuevo_email.grid(row=1, column=3, padx=5, pady=8) 754 | 755 | label_direccion=Label(self.Ventana_editar_cliente,text="Direccion: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=2,sticky='s',padx=10,pady=8) 756 | nueva_direccion=Entry(self.Ventana_editar_cliente,textvariable=StringVar(self.Ventana_editar_cliente,value=direccion),width=25) 757 | nueva_direccion.grid(row=2, column=3, padx=10, pady=8) 758 | 759 | boton_actualizar_cliente=Button(self.Ventana_editar_cliente,text="ACTUALIZAR",command= lambda: self.Actualizar_cliente(nuevo_dni.get(),nuevo_nombres.get(),nuevo_apellidos.get(),nueva_telefono.get(),nuevo_email.get(),nueva_direccion.get(),dni,nombres),height=2,width=20,bg="black",fg="white",font=("Comic Sans", 10,"bold")) 760 | boton_actualizar_cliente.grid(row=3, column=1,columnspan=2, padx=10, pady=15) 761 | 762 | self.Ventana_editar_cliente.mainloop() 763 | 764 | def Actualizar_cliente(self,nuevo_dni,nuevo_nombres,nuevo_apelllidos,nueva_telefono,nuevo_email,nueva_direccion,dni,nombres): 765 | query='UPDATE Clientes SET DNI = ?, Nombres = ?, Apellidos = ?, Telefono =?, Email=?, Direccion =? WHERE DNI = ? AND Nombres =?' 766 | parameters=(nuevo_dni,nuevo_nombres,nuevo_apelllidos,nueva_telefono,nuevo_email,nueva_direccion,dni,nombres) 767 | self.Ejecutar_consulta(query,parameters) 768 | messagebox.showinfo('EXITO',f'Cliente actualizado:{nuevo_dni}') 769 | self.Ventana_editar_cliente.destroy() 770 | self.Obtener_clientes() 771 | 772 | def Buscar_cliente(self): 773 | if(self.Validar_busqueda_cliente()): 774 | #Obtener todos los elementos con get_children(), que retorna una tupla de ID. 775 | records=self.tree_cliente.get_children() 776 | for element in records: 777 | #self.tree_cliente.delete(element) 778 | query=("SELECT * FROM Clientes WHERE DNI LIKE ? ") 779 | parameters=(self.buscar_dni.get()+"%") 780 | db_rows=self.Ejecutar_consulta(query,(parameters,)) 781 | for row in db_rows: 782 | self.tree_cliente.delete(*self.tree_cliente.get_children()) 783 | self.tree_cliente.insert("",0, text=row[0],values=(row[1],row[2],row[3],row[4],row[5])) 784 | if(list(self.tree_cliente.get_children())==[]): 785 | messagebox.showerror("ERROR","Cliente no encontrado") 786 | 787 | "--------------- OTRAS FUNCIONES CLIENTES--------------------" 788 | def Validar_formulario_completo_cliente(self): 789 | if len(self.dni.get()) !=0 and len(self.nombres.get()) !=0 and len(self.apellidos.get()) !=0 and len(self.telefono.get()) !=0 and len(self.email.get()) !=0 and len(self.direccion.get()) !=0: 790 | return True 791 | else: 792 | messagebox.showerror("ERROR", "Complete todos los campos del formulario") 793 | 794 | def Validar_registrar_cliente(self): 795 | parameters= self.dni.get() 796 | query="SELECT * FROM Clientes WHERE DNI = ?" 797 | dato = self.Ejecutar_consulta(query,(parameters,)) 798 | if (dato.fetchall() == []): 799 | return True 800 | else: 801 | messagebox.showerror("ERROR EN REGISTRO", "DNI registrado anteriormente") 802 | 803 | def Limpiar_formulario_cliente(self): 804 | self.dni.delete(0, END) 805 | self.nombres.delete(0, END) 806 | self.apellidos.delete(0, END) 807 | self.telefono.delete(0, END) 808 | self.email.delete(0, END) 809 | self.direccion.delete(0, END) 810 | 811 | def Validar_busqueda_cliente(self): 812 | if len(self.buscar_dni.get()) !=0: 813 | return True 814 | else: 815 | self.tree_cliente.delete(*self.tree_cliente.get_children()) 816 | messagebox.showerror("ERROR", "Complete todos los campos para la busqueda") 817 | 818 | "--------------- VENTAS--------------------" 819 | def Agregar_producto_venta(self): 820 | codigo_busqueda=self.codigo_producto_venta.get() 821 | cantidad=self.cantidad_producto_venta.get() 822 | if(self.Validar_busqueda_producto_venta()): 823 | query=("SELECT Codigo,Nombre,Descripcion,Precio FROM Productos WHERE Codigo LIKE ?") 824 | parameters=(codigo_busqueda) 825 | db_rows=self.Ejecutar_consulta(query,(parameters,)) 826 | rows=db_rows.fetchall() 827 | subtotal=(float(rows[0][3])*float(cantidad)) 828 | rows.extend([cantidad,subtotal]) 829 | print(rows[2]) 830 | self.tree_nueva_venta.insert("",0, text=rows[0][0],values=(rows[0][1],rows[0][2],rows[0][3],rows[1],rows[2])) 831 | self.Limpiar_nueva_venta() 832 | self.Suma_total_venta() 833 | 834 | def Finalizar_venta(self): 835 | fecha=datetime.now() 836 | formato_fecha=fecha.strftime('%d/%m/%Y %H:%M:%S') 837 | print(self.monto_total) 838 | 839 | query='INSERT INTO Ventas VALUES(NULL, ?, ?, ?,?)' 840 | parameters = (self.dni_venta.get(),formato_fecha,self.combo_medio_pago.get(),self.monto_total) 841 | print('REGISTRADO') 842 | respuesta=messagebox.askquestion("ADVERTENCIA",f"¿Seguro que desea terminar la venta?") 843 | if respuesta == 'yes': 844 | self.Ejecutar_consulta(query, parameters) 845 | messagebox.showinfo("VENTA FINALIZADA", f'Monto total de ven: {self.monto_total}') 846 | self.Limpiar_venta_finalizada() 847 | else: 848 | messagebox.showerror('ERROR',f'Error al eliminar el producto') 849 | 850 | def Buscar_venta(self): 851 | if(self.Validar_busqueda_ventas()): 852 | #Obtener todos los elementos con get_children(), que retorna una tupla de ID. 853 | records=self.tree_buscar_ventas.get_children() 854 | for element in records: 855 | self.tree_buscar_ventas.delete(element) 856 | if (self.combo_buscar_venta.get()=='DNI'): 857 | query=("SELECT Fecha,DNI,Clientes.Nombres,Clientes.Apellidos , Medio_pago, Total FROM Ventas INNER JOIN Clientes on Ventas.dni_cliente=Clientes.DNI WHERE DNI LIKE ? ") 858 | parameters=(self.dni_fecha.get()+"%") 859 | db_rows=self.Ejecutar_consulta(query,(parameters,)) 860 | for row in db_rows: 861 | self.tree_buscar_ventas.insert("",0, text=row[0],values=(row[1],row[2],row[3],row[4],row[5])) 862 | if(list(self.tree_buscar_ventas.get_children())==[]): 863 | messagebox.showerror("ERROR","Ventas no encontradas") 864 | else: 865 | query=("SELECT Fecha,DNI,Clientes.Nombres,Clientes.Apellidos , Medio_pago, Total FROM Ventas INNER JOIN Clientes on Ventas.dni_cliente=Clientes.DNI WHERE Fecha LIKE ? ") 866 | parameters=("%"+self.dni_fecha.get()+"%") 867 | db_rows=self.Ejecutar_consulta(query,(parameters,)) 868 | for row in db_rows: 869 | self.tree_buscar_ventas.insert("",0, text=row[0],values=(row[1],row[2],row[3],row[4],row[5])) 870 | if(list(self.tree_buscar_ventas.get_children())==[]): 871 | messagebox.showerror("ERROR","Ventas no encontradas") 872 | 873 | "--------------- OTRAS FUNCIONES CLIENTES--------------------" 874 | def Validar_busqueda_producto_venta(self): 875 | if len(self.codigo_producto_venta.get()) !=0 and len(self.cantidad_producto_venta.get()) !=0 : 876 | return True 877 | else: 878 | #self.tree_cliente.delete(*self.tree_cliente.get_children()) 879 | messagebox.showerror("ERROR", "Complete todos los campos") 880 | 881 | def Suma_total_venta(self): 882 | self.monto_total = 0.00 883 | for item in self.tree_nueva_venta.get_children(): 884 | celda = float(self.tree_nueva_venta.set(item, "columna5")) 885 | self.monto_total += celda 886 | self.venta_total.config(text=self.monto_total) 887 | 888 | def Eliminar_producto_venta(self): 889 | try: 890 | item=self.tree_nueva_venta.selection() 891 | except IndexError as e: 892 | messagebox.showerror("ERROR","Porfavor selecciona un elemento") 893 | return 894 | respuesta=messagebox.askquestion("ADVERTENCIA",f"¿Seguro que desea eliminar el producto?") 895 | if respuesta == 'yes': 896 | self.tree_nueva_venta.delete(item) 897 | messagebox.showinfo('EXITO',f'Producto eliminado') 898 | self.Suma_total_venta() 899 | else: 900 | messagebox.showerror('ERROR',f'Error al eliminar el producto') 901 | 902 | def Limpiar_nueva_venta(self): 903 | self.codigo_producto_venta.delete(0,END) 904 | self.cantidad_producto_venta.delete(0,END) 905 | 906 | def Limpiar_venta_finalizada(self): 907 | self.dni_venta.delete(0,END) 908 | records=self.tree_nueva_venta.get_children() 909 | for element in records: 910 | self.tree_nueva_venta.delete(element) 911 | 912 | def Validar_busqueda_ventas(self): 913 | if len(self.dni_fecha.get()) !=0: 914 | return True 915 | else: 916 | self.tree_buscar_ventas.delete(*self.tree_buscar_ventas.get_children()) 917 | messagebox.showerror("ERROR", "Complete todos los campos para la busqueda") 918 | 919 | if __name__ == '__main__': 920 | ventana_producto=Tk() 921 | label_crud=Label(ventana_producto) 922 | application=Tienda(ventana_producto) 923 | ventana_producto.mainloop() 924 | -------------------------------------------------------------------------------- /SISTEMA DESKTOP/1-Formulario_registro.py: -------------------------------------------------------------------------------- 1 | """ 2 | FORMULARIO DE REGISTRO DE USUARIO 3 | -Registro de usuario y contraseña 4 | -Guardar en bd SQlite 5 | 6 | """ 7 | from tkinter import * 8 | from tkinter import ttk 9 | from tkinter import messagebox 10 | #Python image Library 11 | from PIL import ImageTk, Image 12 | 13 | import sqlite3 14 | 15 | class Registro: 16 | db_name='database_proyecto.db' 17 | 18 | def __init__(self,vetana): 19 | self.window=ventana 20 | self.window.title("FORMULARIO DE REGISTRO") 21 | self.window.geometry("390x630") 22 | self.window.resizable(0,0) 23 | self.window.config(bd=10) 24 | 25 | "--------------- Titulo --------------------" 26 | titulo= Label(ventana, text="REGISTRO DE USUARIO",fg="black",font=("Comic Sans", 13,"bold"),pady=5).pack() 27 | 28 | "--------------- Nuevo usuario logo --------------------" 29 | imagen_registro=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/nuevo_usuario.png") 30 | nueva_imagen=imagen_registro.resize((40,40)) 31 | render=ImageTk.PhotoImage(nueva_imagen) 32 | label_imagen= Label(ventana, image= render) 33 | label_imagen.image=render 34 | label_imagen.pack(pady=5) 35 | 36 | 37 | "--------------- Marco --------------------" 38 | marco = LabelFrame(ventana, text="Datos personales",font=("Comic Sans", 10,"bold")) 39 | marco.config(bd=2,pady=5) 40 | marco.pack() 41 | 42 | "--------------- Formulario --------------------" 43 | label_dni=Label(marco,text="DNI: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 44 | self.dni=Entry(marco,width=25) 45 | self.dni.focus() 46 | self.dni.grid(row=0, column=1, padx=5, pady=8) 47 | 48 | label_nombres=Label(marco,text="Nombre: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=10,pady=8) 49 | self.nombres=Entry(marco,width=25) 50 | self.nombres.grid(row=1, column=1, padx=10, pady=8) 51 | 52 | label_apellidos=Label(marco,text="Apellidos: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=10,pady=8) 53 | self.apellidos=Entry(marco,width=25) 54 | self.apellidos.grid(row=2, column=1, padx=10, pady=8) 55 | 56 | label_sexo=Label(marco,text="Sexo: ",font=("Comic Sans", 10,"bold")).grid(row=3,column=0,sticky='s',padx=10,pady=8) 57 | self.combo_sexo=ttk.Combobox(marco,values=["Masculino", "Femenino"], width=22,state="readonly") 58 | self.combo_sexo.current(0) 59 | self.combo_sexo.grid(row=3,column=1,padx=10,pady=8) 60 | 61 | label_edad=Label(marco,text="Edad: ",font=("Comic Sans", 10,"bold")).grid(row=4,column=0,sticky='s',padx=10,pady=8) 62 | self.edad=Entry(marco,width=25) 63 | self.edad.grid(row=4, column=1, padx=10, pady=8) 64 | 65 | label_correo=Label(marco,text="Correo electronico: ",font=("Comic Sans", 10,"bold")).grid(row=5,column=0,sticky='s',padx=10,pady=8) 66 | self.correo=Entry(marco,width=25) 67 | self.correo.grid(row=5, column=1, padx=10, pady=8) 68 | 69 | label_password=Label(marco,text="Contraseña: ",font=("Comic Sans", 10,"bold")).grid(row=6,column=0,sticky='s',padx=10,pady=8) 70 | self.password=Entry(marco,width=25,show="*") 71 | self.password.grid(row=6, column=1, padx=10, pady=8) 72 | 73 | label_password=Label(marco,text="Repetir contraseña: ",font=("Comic Sans", 10,"bold")).grid(row=7,column=0,sticky='s',padx=10,pady=8) 74 | self.repetir_password=Entry(marco,width=25,show="*") 75 | self.repetir_password.grid(row=7, column=1, padx=10, pady=8) 76 | 77 | "--------------- Marco pregunta --------------------" 78 | marco_pregunta = LabelFrame(ventana, text="Si olvidas tu contraseña",font=("Comic Sans", 10,"bold"),pady=10) 79 | marco_pregunta.config(bd=2,pady=5) 80 | marco_pregunta.pack() 81 | "--------------- Pregunta --------------------" 82 | label_pregunta=Label(marco_pregunta,text="Pregunta: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=10,pady=8) 83 | self.combo_pregunta=ttk.Combobox(marco_pregunta,values=["¿Nombre de tu primera mascota?","¿Lugar dónde fuiste al colegio?","¿En que ciudad naciste?","¿Cómo se llama tu equipo favorito?"], width=30,state="readonly") 84 | self.combo_pregunta.current(0) 85 | self.combo_pregunta.grid(row=0,column=1,padx=10,pady=8) 86 | 87 | label_respuesta=Label(marco_pregunta,text="Respuesta: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=10,pady=8) 88 | self.respuesta=Entry(marco_pregunta,width=33) 89 | self.respuesta.grid(row=1, column=1, padx=10, pady=8) 90 | 91 | label_nota=Label(marco_pregunta,text="*Esta respuesta te permitira recuperar tu contraseña.",font=("Comic Sans", 9,"bold"),foreground="blue").grid(row=2,column=0,columnspan=2,sticky='s',padx=10) 92 | 93 | "--------------- Frame botones --------------------" 94 | frame_botones=Frame(ventana) 95 | frame_botones.pack() 96 | 97 | "--------------- Botones --------------------" 98 | boton_registrar=Button(frame_botones,text="REGISTRAR",command=self.Registrar_usuario ,height=2,width=10,bg="green",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=1, padx=10, pady=15) 99 | boton_limpiar=Button(frame_botones,text="LIMPIAR",command=self.Limpiar_formulario ,height=2,width=10,bg="gray",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=2, padx=10, pady=15) 100 | boton_cancelar=Button(frame_botones,text="CERRAR",command=ventana.quit ,height=2,width=10,bg="red",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=3, padx=10, pady=15) 101 | 102 | def Ejecutar_consulta(self, query, parameters=()): 103 | with sqlite3.connect(self.db_name) as conexion: 104 | cursor=conexion.cursor() 105 | result=cursor.execute(query,parameters) 106 | conexion.commit() 107 | return result 108 | 109 | def Limpiar_formulario(self): 110 | self.dni.delete(0, END) 111 | self.nombres.delete(0, END) 112 | self.apellidos.delete(0, END) 113 | self.combo_sexo.delete(0, END) 114 | self.edad.delete(0, END) 115 | self.correo.delete(0, END) 116 | self.password.delete(0, END) 117 | self.repetir_password.delete(0, END) 118 | self.combo_pregunta.delete(0, END) 119 | self.respuesta.delete(0, END) 120 | 121 | 122 | def Validar_formulario_completo(self): 123 | if len(self.dni.get()) !=0 and len(self.nombres.get()) !=0 and len(self.apellidos.get()) !=0 and len(self.combo_sexo.get()) !=0 and len(self.edad.get()) !=0 and len(self.password.get()) !=0 and len(self.repetir_password.get()) !=0 and len(self.correo.get()) !=0 and len(self.respuesta.get()) !=0: 124 | return True 125 | else: 126 | messagebox.showerror("ERROR EN REGISTRO", "Complete todos los campos del formulario") 127 | def Validar_contraseña(self): 128 | if(str(self.password.get()) == str(self.repetir_password.get())): 129 | return True 130 | else: 131 | messagebox.showerror("ERROR EN REGISTRO", "Contraseñas no coinciden") 132 | 133 | def Buscar_dni(self, dni): 134 | with sqlite3.connect(self.db_name) as conexion: 135 | cursor=conexion.cursor() 136 | sql="SELECT * FROM Usuarios WHERE DNI = {}".format(dni) 137 | cursor.execute(sql) 138 | dnix= cursor.fetchall() # obtener respuesta como lista 139 | cursor.close() 140 | return dnix 141 | 142 | def Validar_dni(self): 143 | dni= self.dni.get() 144 | dato = self.Buscar_dni(dni) 145 | if (dato == []): 146 | return True 147 | else: 148 | messagebox.showerror("ERROR EN REGISTRO", "DNI registrado anteriormente") 149 | 150 | def Registrar_usuario(self): 151 | if self.Validar_formulario_completo() and self.Validar_contraseña() and self.Validar_dni(): 152 | query='INSERT INTO Usuarios VALUES(NULL, ?, ?, ?, ?, ?, ?, ?, ?)' 153 | parameters = (self.dni.get(),self.nombres.get(),self.apellidos.get(),self.combo_sexo.get(),self.edad.get(),self.correo.get(),self.password.get(),self.respuesta.get()) 154 | self.Ejecutar_consulta(query, parameters) 155 | messagebox.showinfo("REGISTRO EXITOSO", f'Bienvenido {self.nombres.get()} {self.apellidos.get()}') 156 | print('USUARIO CREADO') 157 | self.Limpiar_formulario() 158 | 159 | if __name__ == '__main__': 160 | ventana=Tk() 161 | application=Registro(ventana) 162 | ventana.mainloop() 163 | -------------------------------------------------------------------------------- /SISTEMA DESKTOP/2-Login.py: -------------------------------------------------------------------------------- 1 | """ 2 | FORMULARIO DE LOGIN 3 | Ingresar al sistema con su dni y contraseña 4 | Mostrar messagebox 5 | """ 6 | from tkinter import * 7 | from tkinter import ttk 8 | from tkinter import messagebox 9 | #Python image Library 10 | from PIL import ImageTk, Image 11 | import sqlite3 12 | 13 | class Login: 14 | db_name='database_proyecto.db' 15 | 16 | def __init__(self,ventana_login): 17 | self.window=ventana_login 18 | self.window.title("INGRESAR AL SISTEMA") 19 | self.window.geometry("330x370") 20 | self.window.resizable(0,0) 21 | self.window.config(bd=10) 22 | 23 | "--------------- Titulo --------------------" 24 | titulo= Label(ventana_login, text="INICIAR SESION",fg="black",font=("Comic Sans", 13,"bold"),pady=10).pack() 25 | 26 | "--------------- Loginlogo --------------------" 27 | imagen_login=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/login.png") 28 | nueva_imagen=imagen_login.resize((40,40)) 29 | render=ImageTk.PhotoImage(nueva_imagen) 30 | label_imagen= Label(ventana_login, image= render) 31 | label_imagen.image=render 32 | label_imagen.pack(pady=5) 33 | 34 | 35 | "--------------- Marco --------------------" 36 | marco = LabelFrame(ventana_login, text="Ingrese sus datos",font=("Comic Sans", 10,"bold")) 37 | marco.config(bd=2) 38 | marco.pack() 39 | 40 | "--------------- Formulario --------------------" 41 | label_dni=Label(marco,text="DNI: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=10) 42 | self.dni=Entry(marco,width=25) 43 | self.dni.focus() 44 | self.dni.grid(row=0, column=1, padx=5, pady=10) 45 | 46 | label_nombres=Label(marco,text="Contraseña: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=10,pady=10) 47 | self.password=Entry(marco,width=25,show="*") 48 | self.password.grid(row=1, column=1, padx=10, pady=10) 49 | 50 | "--------------- Frame botones --------------------" 51 | frame_botones=Frame(ventana_login) 52 | frame_botones.pack() 53 | 54 | "--------------- Botones --------------------" 55 | boton_ingresar=Button(frame_botones,text="INGRESAR",command=self.Login,height=2,width=12,bg="green",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=1, padx=10, pady=15) 56 | boton_registrar=Button(frame_botones,text="REGISTRAR",command=self.LLamar_registro,height=2,width=12,bg="blue",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=2, padx=10, pady=15) 57 | label_=Label(frame_botones,text="⬇ ¿Olvido su contraseña? ⬇",font=("Comic Sans", 10,"bold")).grid(row=1,column=1,columnspan=2,sticky='s') 58 | boton_olvido=Button(frame_botones,text="RECUPERAR CONTRASEÑA",command=self.LLamar_recuperar ,height=2,width=24,bg="gray",fg="white",font=("Comic Sans", 10,"bold")).grid(row=2, column=1, columnspan=2, padx=10, pady=8) 59 | 60 | def Validar_login(self, dni, password): 61 | with sqlite3.connect(self.db_name) as conexion: 62 | cursor=conexion.cursor() 63 | sql= f"SELECT * FROM Usuarios WHERE DNI = {dni} AND Contraseña = '{password}'" 64 | cursor.execute(sql) 65 | validacion= cursor.fetchall() # obtener respuesta como lista 66 | cursor.close() 67 | return validacion 68 | 69 | def Validar_formulario_completo(self): 70 | if len(self.dni.get()) !=0 and len(self.password.get()) !=0: 71 | return True 72 | else: 73 | messagebox.showerror("ERROR DE INGRESO", "Ingrese su DNI y contraseña!!!") 74 | 75 | def Login(self): 76 | if(self.Validar_formulario_completo()): 77 | dni= self.dni.get() 78 | password= self.password.get() 79 | dato = self.Validar_login(dni, password) 80 | if (dato != []): 81 | messagebox.showinfo("BIENVENIDO", "Datos ingresados correctamente") 82 | else: 83 | messagebox.showerror("ERROR DE INGRESO", "DNI o contraseña incorrecto") 84 | #call registro 85 | def LLamar_registro(self): 86 | ventana_login.destroy() 87 | call([sys.executable, 'D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/1-Formulario_registro.py', 'htmlfilename.htm']) 88 | 89 | #call recuperar 90 | def LLamar_recuperar(self): 91 | ventana_login.destroy() 92 | call([sys.executable, 'D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/3-Recuperar_password.py', 'htmlfilename.htm']) 93 | 94 | #verificar si el modulo ha sido ejecutado correctamente 95 | if __name__ == '__main__': 96 | ventana_login=Tk() 97 | application=Login(ventana_login) 98 | ventana_login.mainloop() 99 | 100 | -------------------------------------------------------------------------------- /SISTEMA DESKTOP/3-Recuperar_password.py: -------------------------------------------------------------------------------- 1 | """ 2 | FORMULARIO DE RECUPERACION DE CONTRASEÑA 3 | -Registro de usuario y contraseña 4 | -Guardar en bd SQlite 5 | 6 | """ 7 | from tkinter import * 8 | from tkinter import ttk 9 | from tkinter import messagebox 10 | #Python image Library 11 | from PIL import ImageTk, Image 12 | from subprocess import call 13 | import sys 14 | import sqlite3 15 | 16 | class Recuperar_contraseña: 17 | db_name='database_proyecto.db' 18 | 19 | def __init__(self, ventana_recuperar): 20 | self.window=ventana_recuperar 21 | self.window.title("RECUPERAR CONTASEÑA") 22 | self.window.geometry("410x420") 23 | self.window.resizable(0,0) 24 | self.window.config(bd=10) 25 | 26 | "--------------- Titulo --------------------" 27 | titulo= Label(ventana_recuperar, text="RECUPERAR CONTRASEÑA",fg="black",font=("Comic Sans", 13,"bold"),pady=8).pack() 28 | 29 | "--------------- Recuperar password logo --------------------" 30 | imagen_password=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/recuperar_contraseña.png") 31 | nueva_imagen=imagen_password.resize((60,60)) 32 | render=ImageTk.PhotoImage(nueva_imagen) 33 | label_imagen= Label(ventana_recuperar, image= render) 34 | label_imagen.image=render 35 | label_imagen.pack(pady=5) 36 | 37 | "--------------- Marco --------------------" 38 | marco = LabelFrame(ventana_recuperar, text="Datos de recuperacion",font=("Comic Sans", 10,"bold")) 39 | marco.config(bd=2) 40 | marco.pack() 41 | 42 | "--------------- Formulario --------------------" 43 | label_dni=Label(marco,text="DNI: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 44 | self.dni=Entry(marco,width=25) 45 | self.dni.focus() 46 | self.dni.grid(row=0, column=1, padx=5, pady=8) 47 | 48 | label_nota=Label(marco,text="*Seleccione una pregunta y brinde la respuesta correcta.",font=("Comic Sans", 9,"bold"),foreground="blue").grid(row=1,column=0,columnspan=2,sticky='s',padx=8) 49 | 50 | label_pregunta=Label(marco,text="Pregunta: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=5,pady=8) 51 | self.combo_pregunta=ttk.Combobox(marco,values=["¿Nombre de tu primera mascota?","¿Lugar dónde fuiste al colegio?","¿En que ciudad naciste?","¿Cómo se llama tu equipo favorito?"], width=30,state="readonly") 52 | self.combo_pregunta.current(0) 53 | self.combo_pregunta.grid(row=2,column=1,padx=5,pady=8) 54 | 55 | label_respuesta=Label(marco,text="Respuesta: ",font=("Comic Sans", 10,"bold")).grid(row=3,column=0,sticky='s',padx=5,pady=8) 56 | self.respuesta=Entry(marco,width=33) 57 | self.respuesta.grid(row=3, column=1, padx=5, pady=8) 58 | 59 | label_password=Label(marco,text="Nueva Contraseña: ",font=("Comic Sans", 10,"bold")).grid(row=4,column=0,sticky='s',padx=5,pady=8) 60 | self.nuevo_password=Entry(marco,width=25,show="*") 61 | self.nuevo_password.grid(row=4, column=1, padx=5, pady=8) 62 | 63 | label_password=Label(marco,text="Repetir contraseña: ",font=("Comic Sans", 10,"bold")).grid(row=5,column=0,sticky='s',padx=10,pady=8) 64 | self.repetir_password=Entry(marco,width=25,show="*") 65 | self.repetir_password.grid(row=5, column=1, padx=5, pady=8) 66 | 67 | "--------------- Frame botones --------------------" 68 | frame_botones=Frame(ventana_recuperar) 69 | frame_botones.pack() 70 | 71 | "--------------- Botones --------------------" 72 | boton_recuperar=Button(frame_botones,text="RECUPERAR",command=self.Restablecer_contraseña ,height=2,width=10,bg="green",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=1, padx=10, pady=10) 73 | boton_cancelar=Button(frame_botones,text="CANCELAR",command=self.LLamar_login ,height=2,width=10,bg="red",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=3, padx=10, pady=10) 74 | 75 | def Ejecutar_consulta(self, query, parameters=()): 76 | with sqlite3.connect(self.db_name) as conexion: 77 | cursor=conexion.cursor() 78 | result=cursor.execute(query,parameters) 79 | conexion.commit() 80 | return result 81 | 82 | def Limpiar_formulario(self): 83 | self.dni.delete(0, END) 84 | self.respuesta.delete(0, END) 85 | self.nuevo_password.delete(0, END) 86 | self.repetir_password.delete(0, END) 87 | 88 | def Validar_formulario_completo(self): 89 | if len(self.dni.get()) !=0 and len(self.nuevo_password.get()) !=0 and len(self.repetir_password.get()) !=0 and len(self.respuesta.get()) !=0: 90 | return True 91 | else: 92 | messagebox.showerror("ERROR", "Complete todos los campos del formulario") 93 | 94 | def Validar_contraseña(self): 95 | if(str(self.nuevo_password.get()) == str(self.repetir_password.get())): 96 | return True 97 | else: 98 | messagebox.showerror("ERROR DE RECUPERACION", "Contraseñas no coinciden") 99 | 100 | def Buscar_usuario(self, dni, respuesta): 101 | with sqlite3.connect(self.db_name) as conexion: 102 | cursor=conexion.cursor() 103 | sql=f"SELECT * FROM Usuarios WHERE DNI = {dni} AND Respuesta = '{respuesta}'" 104 | cursor.execute(sql) 105 | busqueda= cursor.fetchall() # obtener respuesta como lista 106 | cursor.close() 107 | return busqueda 108 | 109 | def Validar_datos_usuario(self): 110 | dni= self.dni.get() 111 | respuesta=self.respuesta.get() 112 | busqueda = self.Buscar_usuario(dni, respuesta) 113 | if (busqueda != []): 114 | return True 115 | else: 116 | messagebox.showerror("ERROR DE RECUPERACION", "Datos de recuperacion no son correctos") 117 | 118 | def Restablecer_contraseña(self): 119 | if self.Validar_formulario_completo() and self.Validar_datos_usuario() and self.Validar_contraseña(): 120 | query='UPDATE Usuarios SET Contraseña = (?) WHERE DNI= (?)' 121 | parameters = (self.nuevo_password.get(), self.dni.get()) 122 | self.Ejecutar_consulta(query, parameters) 123 | messagebox.showinfo("CONTRASEÑA RECUPERADA", f'Contraseña actualizada correctamente: {self.nuevo_password.get()}') 124 | print('DATOS ACTUALIZADO') 125 | self.Limpiar_formulario() 126 | 127 | def LLamar_login(self): 128 | ventana_recuperar.destroy() 129 | call([sys.executable, 'D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/2-Login.py', 'htmlfilename.htm']) 130 | 131 | 132 | if __name__ == '__main__': 133 | ventana_recuperar=Tk() 134 | application=Recuperar_contraseña(ventana_recuperar) 135 | ventana_recuperar.mainloop() 136 | -------------------------------------------------------------------------------- /SISTEMA DESKTOP/4-CRUD.py: -------------------------------------------------------------------------------- 1 | """ 2 | CRUD-PRODUCTOS 3 | -Registro de Prouctos 4 | -Guardar en bd SQlite 5 | 6 | """ 7 | from tkinter import * 8 | from tkinter import ttk 9 | from tkinter import messagebox 10 | #Python image Library 11 | from PIL import ImageTk, Image 12 | import sqlite3 13 | 14 | class Producto: 15 | db_name='database_proyecto.db' 16 | 17 | def __init__(self, ventana_producto): 18 | self.window=ventana_producto 19 | self.window.title("APLICACION") 20 | self.window.geometry("800x670") 21 | self.window.resizable(0,0) 22 | self.window.config(bd=10) 23 | 24 | "--------------- Titulo --------------------" 25 | titulo= Label(ventana_producto, text="REGISTRO DE PRODUCTOS ELECTRONICOS",fg="black",font=("Comic Sans", 17,"bold"),pady=10).pack() 26 | 27 | "--------------- Logos productos --------------------" 28 | frame_logo_productos = LabelFrame(ventana_producto) 29 | frame_logo_productos.config(bd=0) 30 | frame_logo_productos.pack() 31 | 32 | #Logo arduino 33 | imagen_arduino=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/arduino-logo.png") 34 | nueva_imagen=imagen_arduino.resize((60,60)) 35 | render=ImageTk.PhotoImage(nueva_imagen) 36 | label_imagen= Label(frame_logo_productos, image= render) 37 | label_imagen.image=render 38 | label_imagen.grid(row=0, column=0,padx=15,pady=5) 39 | 40 | #Logo nodemcu 41 | imagen_nodemcu=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/nodemcu-logo.png") 42 | nueva_imagen=imagen_nodemcu.resize((60,60)) 43 | render=ImageTk.PhotoImage(nueva_imagen) 44 | label_imagen= Label(frame_logo_productos, image= render) 45 | label_imagen.image=render 46 | label_imagen.grid(row=0, column=1,padx=15,pady=5) 47 | 48 | #Logo raspberry 49 | imagen_raspberry=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/raspberry-logo.png") 50 | nueva_imagen=imagen_raspberry.resize((60,60)) 51 | render=ImageTk.PhotoImage(nueva_imagen) 52 | label_imagen= Label(frame_logo_productos, image= render) 53 | label_imagen.image=render 54 | label_imagen.grid(row=0, column=2,padx=15,pady=5) 55 | 56 | "--------------- Frame marco --------------------" 57 | marco = LabelFrame(ventana_producto, text="Informacion del producto",font=("Comic Sans", 10,"bold"),pady=5) 58 | marco.config(bd=2) 59 | marco.pack() 60 | 61 | "--------------- Formulario --------------------" 62 | label_codigo=Label(marco,text="Codigo del producto: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 63 | self.codigo=Entry(marco,width=25) 64 | self.codigo.focus() 65 | self.codigo.grid(row=0, column=1, padx=5, pady=8) 66 | 67 | label_nombre=Label(marco,text="Nombre del producto: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=5,pady=8) 68 | self.nombre=Entry(marco,width=25) 69 | self.nombre.grid(row=1, column=1, padx=5, pady=8) 70 | 71 | label_categoria=Label(marco,text="Categoria: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=5,pady=9) 72 | self.combo_categoria=ttk.Combobox(marco,values=["Microcontrolador","Microordenador","Sensores","Accesorios"], width=22,state="readonly") 73 | self.combo_categoria.current(0) 74 | self.combo_categoria.grid(row=2,column=1,padx=5,pady=0) 75 | 76 | 77 | label_cantidad=Label(marco,text="Cantidad: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=8) 78 | self.cantidad=Entry(marco,width=25) 79 | self.cantidad.grid(row=0, column=3, padx=5, pady=8) 80 | 81 | label_precio=Label(marco,text="Precio (S/.): ",font=("Comic Sans", 10,"bold")).grid(row=1,column=2,sticky='s',padx=5,pady=8) 82 | self.precio=Entry(marco,width=25) 83 | self.precio.grid(row=1, column=3, padx=5, pady=8) 84 | 85 | label_descripcion=Label(marco,text="Descripcion: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=2,sticky='s',padx=10,pady=8) 86 | self.descripcion=Entry(marco,width=25) 87 | self.descripcion.grid(row=2, column=3, padx=10, pady=8) 88 | 89 | "--------------- Frame botones --------------------" 90 | frame_botones=Frame(ventana_producto) 91 | frame_botones.pack() 92 | 93 | "--------------- Botones --------------------" 94 | boton_registrar=Button(frame_botones,text="REGISTRAR",command=self.Agregar_producto,height=2,width=10,bg="green",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=1, padx=10, pady=15) 95 | boton_editar=Button(frame_botones,text="EDITAR",command=self.Editar_producto ,height=2,width=10,bg="gray",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=2, padx=10, pady=15) 96 | boton_eliminar=Button(frame_botones,text="ELIMINAR",command=self.Eliminar_producto,height=2,width=10,bg="red",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=3, padx=10, pady=15) 97 | 98 | "--------------- Tabla --------------------" 99 | self.tree=ttk.Treeview(height=13, columns=("columna1","columna2","columna3","columna4","columna5")) 100 | self.tree.heading("#0",text='Codigo', anchor=CENTER) 101 | self.tree.column("#0", width=90, minwidth=75, stretch=NO) 102 | 103 | self.tree.heading("columna1",text='Nombre', anchor=CENTER) 104 | self.tree.column("columna1", width=150, minwidth=75, stretch=NO) 105 | 106 | self.tree.heading("columna2",text='Categoria', anchor=CENTER) 107 | self.tree.column("columna2", width=150, minwidth=75, stretch=NO) 108 | 109 | self.tree.heading("columna3",text='Cantidad', anchor=CENTER) 110 | self.tree.column("columna3", width=70, minwidth=60, stretch=NO) 111 | 112 | self.tree.heading("columna4",text='Precio', anchor=CENTER) 113 | self.tree.column("columna4", width=70, minwidth=60, stretch=NO) 114 | 115 | self.tree.heading("columna5",text='Descripcion', anchor=CENTER) 116 | 117 | self.tree.pack() 118 | 119 | self.Obtener_productos() 120 | 121 | "--------------- CRUD --------------------" 122 | def Obtener_productos(self): 123 | records=self.tree.get_children() 124 | for element in records: 125 | self.tree.delete(element) 126 | query='SELECT * FROM Productos ORDER BY Nombre desc' 127 | db_rows=self.Ejecutar_consulta(query) 128 | for row in db_rows: 129 | self.tree.insert("",0, text=row[1],values=(row[2],row[3],row[4],row[5],row[6])) 130 | 131 | def Agregar_producto(self): 132 | if self.Validar_formulario_completo(): 133 | query='INSERT INTO Productos VALUES(NULL, ?, ?, ?, ?, ?, ?)' 134 | parameters = (self.codigo.get(),self.nombre.get(),self.combo_categoria.get(),self.cantidad.get(),self.precio.get(),self.descripcion.get()) 135 | self.Ejecutar_consulta(query, parameters) 136 | messagebox.showinfo("REGISTRO EXITOSO", f'Producto registrado: {self.nombre.get()}') 137 | print('REGISTRADO') 138 | self.Limpiar_formulario() 139 | self.Obtener_productos() 140 | 141 | def Eliminar_producto(self): 142 | try: 143 | self.tree.item(self.tree.selection())['text'][0] 144 | except IndexError as e: 145 | messagebox.showerror("ERROR","Porfavor selecciona un elemento") 146 | return 147 | dato=self.tree.item(self.tree.selection())['text'] 148 | nombre=self.tree.item(self.tree.selection())['values'][0] 149 | query="DELETE FROM Productos WHERE Codigo = ?" 150 | respuesta=messagebox.askquestion("ADVERTENCIA",f"¿Seguro que desea eliminar el producto: {nombre}?") 151 | if respuesta == 'yes': 152 | self.Ejecutar_consulta(query,(dato,)) 153 | self.Obtener_productos() 154 | messagebox.showinfo('EXITO',f'Producto eliminado: {nombre}') 155 | else: 156 | messagebox.showerror('ERROR',f'Error al eliminar el producto: {nombre}') 157 | 158 | def Editar_producto(self): 159 | try: 160 | self.tree.item(self.tree.selection())['text'][0] 161 | except IndexError as e: 162 | messagebox.showerror("ERROR","Porfavor selecciona un elemento") 163 | return 164 | codigo=self.tree.item(self.tree.selection())['text'] 165 | nombre=self.tree.item(self.tree.selection())['values'][0] 166 | categoria=self.tree.item(self.tree.selection())['values'][1] 167 | cantidad=self.tree.item(self.tree.selection())['values'][2] 168 | precio=self.tree.item(self.tree.selection())['values'][3] 169 | descripcion=self.tree.item(self.tree.selection())['values'][4] 170 | 171 | self.Ventana_editar = Toplevel() 172 | self.Ventana_editar.title('EDITAR PRODUCTO') 173 | self.Ventana_editar.resizable(0,0) 174 | 175 | 176 | #Valores ventana editar 177 | label_codigo=Label(self.Ventana_editar,text="Codigo del producto: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 178 | nuevo_codigo=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=codigo),width=25) 179 | nuevo_codigo.grid(row=0, column=1, padx=5, pady=8) 180 | 181 | label_nombre=Label(self.Ventana_editar,text="Nombre del producto: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=5,pady=8) 182 | nuevo_nombre=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=nombre),width=25) 183 | nuevo_nombre.grid(row=1, column=1, padx=5, pady=8) 184 | 185 | label_categoria=Label(self.Ventana_editar,text="Categoria: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=5,pady=9) 186 | nuevo_combo_categoria=ttk.Combobox(self.Ventana_editar,values=["Microcontrolador","Microordenador","Sensores","Accesorios"], width=22,state="readonly") 187 | nuevo_combo_categoria.set(categoria) 188 | nuevo_combo_categoria.grid(row=2,column=1,padx=5,pady=0) 189 | 190 | label_cantidad=Label(self.Ventana_editar,text="Cantidad: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=8) 191 | nueva_cantidad=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=cantidad),width=25) 192 | nueva_cantidad.grid(row=0, column=3, padx=5, pady=8) 193 | 194 | label_precio=Label(self.Ventana_editar,text="Precio (S/.): ",font=("Comic Sans", 10,"bold")).grid(row=1,column=2,sticky='s',padx=5,pady=8) 195 | nuevo_precio=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=precio),width=25) 196 | nuevo_precio.grid(row=1, column=3, padx=5, pady=8) 197 | 198 | label_descripcion=Label(self.Ventana_editar,text="Descripcion: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=2,sticky='s',padx=10,pady=8) 199 | nueva_descripcion=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=descripcion),width=25) 200 | nueva_descripcion.grid(row=2, column=3, padx=10, pady=8) 201 | 202 | boton_actualizar=Button(self.Ventana_editar,text="ACTUALIZAR",command= lambda: self.Actualizar(nuevo_codigo.get(),nuevo_nombre.get(),nuevo_combo_categoria.get(),nueva_cantidad.get(),nuevo_precio.get(),nueva_descripcion.get(),codigo,nombre),height=2,width=20,bg="black",fg="white",font=("Comic Sans", 10,"bold")) 203 | boton_actualizar.grid(row=3, column=1,columnspan=2, padx=10, pady=15) 204 | 205 | self.Ventana_editar.mainloop() 206 | 207 | def Actualizar(self,nuevo_codigo,nuevo_nombre,nuevo_combo_categoria,nueva_cantidad,nuevo_precio,nueva_descripcion,codigo,nombre): 208 | query='UPDATE Productos SET Codigo = ?, Nombre = ?, Categoria = ?, Cantidad =?, Precio=?, Descripcion =? WHERE Codigo = ? AND Nombre =?' 209 | parameters=(nuevo_codigo,nuevo_nombre,nuevo_combo_categoria,nueva_cantidad,nuevo_precio,nueva_descripcion,codigo,nombre) 210 | self.Ejecutar_consulta(query,parameters) 211 | messagebox.showinfo('EXITO',f'Producto actualizado:{nuevo_nombre}') 212 | self.Ventana_editar.destroy() 213 | self.Obtener_productos() 214 | 215 | "--------------- OTRAS FUNCIONES --------------------" 216 | def Ejecutar_consulta(self, query, parameters=()): 217 | with sqlite3.connect(self.db_name) as conexion: 218 | cursor=conexion.cursor() 219 | result=cursor.execute(query,parameters) 220 | conexion.commit() 221 | return result 222 | 223 | def Validar_formulario_completo(self): 224 | if len(self.codigo.get()) !=0 and len(self.nombre.get()) !=0 and len(self.combo_categoria.get()) !=0 and len(self.cantidad.get()) !=0 and len(self.precio.get()) !=0 and len(self.descripcion.get()) !=0: 225 | return True 226 | else: 227 | messagebox.showerror("ERROR", "Complete todos los campos del formulario") 228 | 229 | def Limpiar_formulario(self): 230 | self.codigo.delete(0, END) 231 | self.nombre.delete(0, END) 232 | self.cantidad.delete(0, END) 233 | self.precio.delete(0, END) 234 | self.descripcion.delete(0, END) 235 | 236 | if __name__ == '__main__': 237 | ventana_producto=Tk() 238 | application=Producto(ventana_producto) 239 | ventana_producto.mainloop() -------------------------------------------------------------------------------- /SISTEMA DESKTOP/5-Buscador.py: -------------------------------------------------------------------------------- 1 | """ 2 | BUSCADOR-PRODUCTOS 3 | -Buscar Prouctos 4 | -Buscar en bd SQlite 5 | """ 6 | from tkinter import * 7 | from tkinter import ttk 8 | from tkinter import messagebox 9 | #Python image Library 10 | from PIL import ImageTk, Image 11 | import sqlite3 12 | 13 | 14 | class Producto(): 15 | db_name='database_proyecto.db' 16 | def __init__(self, ventana_producto): 17 | menubar=Menu(ventana_producto) 18 | ventana_producto.title("APLICACION") 19 | ventana_producto.geometry("769x660") 20 | ventana_producto.resizable(0,0) 21 | ventana_producto.config(bd=10,menu=menubar) 22 | 23 | "---------------------Menu---------------------------" 24 | Productos=Menu(menubar,tearoff=0) 25 | Ventas=Menu(menubar,tearoff=0) 26 | Reportes=Menu(menubar,tearoff=0) 27 | Informacion=Menu(menubar,tearoff=0) 28 | menubar.add_cascade(label="Productos",menu=Productos) 29 | menubar.add_cascade(label="Ventas",menu=Ventas) 30 | menubar.add_cascade(label="Reportes",menu=Reportes) 31 | menubar.add_cascade(label="Ayuda",menu=Informacion) 32 | #Iconos 33 | self.img_registrar=PhotoImage(file="D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/registrar.png") 34 | self.img_buscar=PhotoImage(file="D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/buscar.png") 35 | self.img_informacion=PhotoImage(file="D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/informacion.png") 36 | #Acciones de menu 37 | self.boton_registrar=Productos.add_command(label="Registrar",command= self.widgets_crud,image=self.img_registrar,compound=LEFT) 38 | self.boton_buscar=Productos.add_command(label="Buscar",command=self.widgets_buscador,image=self.img_buscar,compound=LEFT) 39 | self.boton_informacion=Informacion.add_command(label="Informacion del sistema",command=self.widgets_informacion,image=self.img_informacion,compound=LEFT) 40 | 41 | "---------------------Widgets---------------------------" 42 | #widgets crud 43 | self.Label_titulo_crud=LabelFrame(ventana_producto) 44 | self.frame_logo_productos = LabelFrame(ventana_producto) 45 | self.frame_registro = LabelFrame(ventana_producto, text="Informacion del producto",font=("Comic Sans", 10,"bold"),pady=5) 46 | self.frame_botones_registro=LabelFrame(ventana_producto) 47 | self.frame_tabla_crud=LabelFrame(ventana_producto) 48 | #widgets buscador 49 | self.Label_titulo_buscador=LabelFrame(ventana_producto) 50 | self.frame_buscar_producto = LabelFrame(ventana_producto, text="Buscar producto",font=("Comic Sans", 10,"bold"),pady=10) 51 | self.frame_boton_buscar=LabelFrame(ventana_producto) 52 | #widgets informacion 53 | self.Label_informacion = LabelFrame(ventana_producto) 54 | 55 | #Pantalla inicial 56 | self.widgets_crud() 57 | 58 | def widgets_crud(self): 59 | self.Label_titulo_crud.config(bd=0) 60 | self.Label_titulo_crud.grid(row=0,column=0,padx=5,pady=5) 61 | "--------------- Titulo --------------------" 62 | self.titulo_crud= Label(self.Label_titulo_crud, text="REGISTRO DE PRODUCTOS ELECTRONICOS",fg="black",font=("Comic Sans", 17,"bold")) 63 | self.titulo_crud.grid(row=0,column=0) 64 | 65 | "--------------- Logos productos --------------------" 66 | self.frame_logo_productos.config(bd=0) 67 | self.frame_logo_productos.grid(row=1,column=0,padx=5,pady=5) 68 | 69 | #Logo arduino 70 | imagen_arduino=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/arduino-logo.png") 71 | nueva_imagen=imagen_arduino.resize((60,60)) 72 | render=ImageTk.PhotoImage(nueva_imagen) 73 | label_imagen= Label(self.frame_logo_productos, image= render) 74 | label_imagen.image=render 75 | label_imagen.grid(row=0, column=0,padx=15,pady=5) 76 | 77 | #Logo nodemcu 78 | imagen_nodemcu=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/nodemcu-logo.png") 79 | nueva_imagen=imagen_nodemcu.resize((60,60)) 80 | render=ImageTk.PhotoImage(nueva_imagen) 81 | label_imagen= Label(self.frame_logo_productos, image= render) 82 | label_imagen.image=render 83 | label_imagen.grid(row=0, column=1,padx=15,pady=5) 84 | 85 | #Logo raspberry 86 | imagen_raspberry=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/raspberry-logo.png") 87 | nueva_imagen=imagen_raspberry.resize((60,60)) 88 | render=ImageTk.PhotoImage(nueva_imagen) 89 | label_imagen= Label(self.frame_logo_productos, image= render) 90 | label_imagen.image=render 91 | label_imagen.grid(row=0, column=2,padx=15,pady=5) 92 | 93 | "--------------- Frame marco --------------------" 94 | self.frame_registro.config(bd=2) 95 | self.frame_registro.grid(row=2,column=0,padx=5,pady=5) 96 | 97 | "--------------- Formulario --------------------" 98 | label_codigo=Label(self.frame_registro,text="Codigo del producto: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 99 | self.codigo=Entry(self.frame_registro,width=25) 100 | self.codigo.focus() 101 | self.codigo.grid(row=0, column=1, padx=5, pady=8) 102 | 103 | label_nombre=Label(self.frame_registro,text="Nombre del producto: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=5,pady=8) 104 | self.nombre=Entry(self.frame_registro,width=25) 105 | self.nombre.grid(row=1, column=1, padx=5, pady=8) 106 | 107 | label_categoria=Label(self.frame_registro,text="Categoria: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=5,pady=9) 108 | self.combo_categoria=ttk.Combobox(self.frame_registro,values=["Microcontrolador","Microordenador","Sensores","Accesorios"], width=22,state="readonly") 109 | self.combo_categoria.current(0) 110 | self.combo_categoria.grid(row=2,column=1,padx=5,pady=0) 111 | 112 | label_cantidad=Label(self.frame_registro,text="Cantidad: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=8) 113 | self.cantidad=Entry(self.frame_registro,width=25) 114 | self.cantidad.grid(row=0, column=3, padx=5, pady=8) 115 | 116 | label_precio=Label(self.frame_registro,text="Precio (S/.): ",font=("Comic Sans", 10,"bold")).grid(row=1,column=2,sticky='s',padx=5,pady=8) 117 | self.precio=Entry(self.frame_registro,width=25) 118 | self.precio.grid(row=1, column=3, padx=5, pady=8) 119 | 120 | label_descripcion=Label(self.frame_registro,text="Descripcion: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=2,sticky='s',padx=10,pady=8) 121 | self.descripcion=Entry(self.frame_registro,width=25) 122 | self.descripcion.grid(row=2, column=3, padx=10, pady=8) 123 | 124 | "--------------- Frame botones --------------------" 125 | self.frame_botones_registro.config(bd=0) 126 | self.frame_botones_registro.grid(row=3,column=0,padx=5,pady=5) 127 | 128 | "--------------- Botones --------------------" 129 | boton_registrar=Button(self.frame_botones_registro,text="REGISTRAR",command=self.Agregar_producto,height=2,width=12,bg="green",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=1, padx=10, pady=15) 130 | boton_editar=Button(self.frame_botones_registro,text="EDITAR",command=self.Editar_producto ,height=2,width=12,bg="gray",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=2, padx=10, pady=15) 131 | boton_eliminar=Button(self.frame_botones_registro,text="ELIMINAR",command=self.Eliminar_producto,height=2,width=12,bg="red",fg="white",font=("Comic Sans", 10,"bold")).grid(row=0, column=3, padx=10, pady=15) 132 | 133 | "--------------- Tabla --------------------" 134 | self.frame_tabla_crud.config(bd=2) 135 | self.frame_tabla_crud.grid(row=4,column=0,padx=5,pady=5) 136 | 137 | self.tree=ttk.Treeview(self.frame_tabla_crud,height=11, columns=("columna1","columna2","columna3","columna4","columna5")) 138 | self.tree.heading("#0",text='Codigo', anchor=CENTER) 139 | self.tree.column("#0", width=90, minwidth=75, stretch=NO) 140 | 141 | self.tree.heading("columna1",text='Nombre', anchor=CENTER) 142 | self.tree.column("columna1", width=150, minwidth=75, stretch=NO) 143 | 144 | self.tree.heading("columna2",text='Categoria', anchor=CENTER) 145 | self.tree.column("columna2", width=150, minwidth=75, stretch=NO) 146 | 147 | self.tree.heading("columna3",text='Cantidad', anchor=CENTER) 148 | self.tree.column("columna3", width=70, minwidth=60, stretch=NO) 149 | 150 | self.tree.heading("columna4",text='Precio', anchor=CENTER) 151 | self.tree.column("columna4", width=70, minwidth=60, stretch=NO) 152 | 153 | self.tree.heading("columna5",text='Descripcion', anchor=CENTER) 154 | 155 | self.tree.grid(row=0,column=0,sticky=E) 156 | 157 | self.Obtener_productos() 158 | 159 | #REMOVER OTROS WIDGETS 160 | self.widgets_buscador_remove() 161 | self.Label_informacion.grid_remove() 162 | 163 | def widgets_buscador(self): 164 | self.Label_titulo_buscador.config(bd=0) 165 | self.Label_titulo_buscador.grid(row=0,column=0,padx=5,pady=5) 166 | 167 | "--------------- Titulo --------------------" 168 | self.titulo_buscador= Label(self.Label_titulo_buscador, text="BUSCADOR DE PRODUCTOS ELECTRONICOS",fg="black",font=("Comic Sans", 17,"bold")) 169 | self.titulo_buscador.grid(row=0,column=0) 170 | 171 | "--------------- Frame buscar --------------------" 172 | self.frame_buscar_producto.config(bd=2) 173 | self.frame_buscar_producto.grid(row=2,column=0,padx=5,pady=5) 174 | 175 | "--------------- Formulario Buscar--------------------" 176 | self.label_buscar=Label(self.frame_buscar_producto,text="Buscar Por: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=5) 177 | self.combo_buscar=ttk.Combobox(self.frame_buscar_producto,values=["Codigo","Nombre"], width=22,state="readonly") 178 | self.combo_buscar.current(0) 179 | self.combo_buscar.grid(row=0,column=1,padx=5,pady=5) 180 | 181 | label_codigo_codigo=Label(self.frame_buscar_producto,text="Codigo / Nombre del producto: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=5) 182 | self.codigo_nombre=Entry(self.frame_buscar_producto,width=25) 183 | self.codigo_nombre.focus() 184 | self.codigo_nombre.grid(row=0, column=3, padx=10, pady=5) 185 | 186 | "--------------- Frame marco --------------------" 187 | self.frame_boton_buscar.config(bd=0) 188 | self.frame_boton_buscar.grid(row=3,column=0,padx=5,pady=5) 189 | "--------------- Boton --------------------" 190 | self.boton_buscar=Button(self.frame_boton_buscar,text="BUSCAR",command=self.Buscar_productos,height=2,width=20,bg="black",fg="white",font=("Comic Sans", 10,"bold")) 191 | self.boton_buscar.grid(row=0,column=0,padx=5,pady=5) 192 | 193 | self.tree.delete(*self.tree.get_children()) 194 | 195 | #REMOVER OTROS WIDGETS 196 | self.widgets_crud_remove() 197 | self.Label_informacion.grid_remove() 198 | 199 | def widgets_crud_remove(self): 200 | self.Label_titulo_crud.grid_remove() 201 | self.frame_registro.grid_remove() 202 | self.frame_botones_registro.grid_remove() 203 | 204 | def widgets_buscador_remove(self): 205 | self.Label_titulo_buscador.grid_remove() 206 | self.frame_buscar_producto.grid_remove() 207 | self.frame_boton_buscar.grid_remove() 208 | 209 | def widgets_informacion(self): 210 | 211 | self.Label_informacion.config(bd=0) 212 | self.Label_informacion.grid(row=0,column=0) 213 | "--------------- Titulo --------------------" 214 | self.Label_titulo = Label(self.Label_informacion,text="APLICACION DE ESCRITORIO",fg="white",bg="black",font=("Comic Sans", 25,"bold"),padx=137,pady=20) 215 | self.Label_titulo.grid(row=0,column=0) 216 | 217 | "--------------- Logos imagenes--------------------" 218 | #Logo 219 | imagen_arduino=Image.open("D:/EIGHTA/PYTHON-TKINTER/SISTEMA DESKTOP/Imagenes/app_logo_2.png") 220 | nueva_imagen=imagen_arduino.resize((170,170)) 221 | render=ImageTk.PhotoImage(nueva_imagen) 222 | label_imagen= Label(self.Label_informacion, image= render) 223 | label_imagen.image=render 224 | label_imagen.grid(row=1,column=0,padx=10,pady=15) 225 | 226 | "--------------- opciones--------------------" 227 | self.Label_titulo = Label(self.Label_informacion,text="> CONTROL DE PRODUCTOS ",fg="black",font=("Comic Sans", 18,"bold")) 228 | self.Label_titulo.grid(row=2,column=0,sticky=W,padx=30,pady=10) 229 | 230 | self.Label_titulo = Label(self.Label_informacion,text="> BUSCADOR DE PRODUCTOS ",fg="black",font=("Comic Sans", 18,"bold")) 231 | self.Label_titulo.grid(row=3,column=0,sticky=W,padx=30,pady=10) 232 | 233 | self.Label_titulo = Label(self.Label_informacion,text="> REGISTRO VENTAS ",fg="black",font=("Comic Sans", 18,"bold")) 234 | self.Label_titulo.grid(row=4,column=0,sticky=W,padx=30,pady=10) 235 | 236 | self.Label_titulo = Label(self.Label_informacion,text="> GENERACION DE REPORTE ",fg="black",font=("Comic Sans", 18,"bold")) 237 | self.Label_titulo.grid(row=5,column=0,sticky=W,padx=30,pady=10) 238 | 239 | self.Label_titulo = Label(self.Label_informacion,text="Creado por Luis Ochoa - 2023",fg="black",font=("Comic Sans",10,"bold")) 240 | self.Label_titulo.grid(row=6,column=0,pady=60) 241 | 242 | #Remove 243 | self.widgets_buscador_remove() 244 | self.widgets_crud_remove() 245 | 246 | "--------------- CRUD --------------------" 247 | def Obtener_productos(self): 248 | records=self.tree.get_children() 249 | for element in records: 250 | self.tree.delete(element) 251 | query='SELECT * FROM Productos ORDER BY Nombre desc' 252 | db_rows=self.Ejecutar_consulta(query) 253 | for row in db_rows: 254 | self.tree.insert("",0, text=row[1],values=(row[2],row[3],row[4],row[5],row[6])) 255 | 256 | def Agregar_producto(self): 257 | if self.Validar_formulario_completo() and self.Validar_registrar(): 258 | query='INSERT INTO Productos VALUES(NULL, ?, ?, ?, ?, ?, ?)' 259 | parameters = (self.codigo.get(),self.nombre.get(),self.combo_categoria.get(),self.cantidad.get(),self.precio.get(),self.descripcion.get()) 260 | self.Ejecutar_consulta(query, parameters) 261 | messagebox.showinfo("REGISTRO EXITOSO", f'Producto registrado: {self.nombre.get()}') 262 | print('REGISTRADO') 263 | self.Limpiar_formulario() 264 | self.Obtener_productos() 265 | 266 | def Eliminar_producto(self): 267 | try: 268 | self.tree.item(self.tree.selection())['text'][0] 269 | except IndexError as e: 270 | messagebox.showerror("ERROR","Porfavor selecciona un elemento") 271 | return 272 | dato=self.tree.item(self.tree.selection())['text'] 273 | nombre=self.tree.item(self.tree.selection())['values'][0] 274 | query="DELETE FROM Productos WHERE Codigo = ?" 275 | respuesta=messagebox.askquestion("ADVERTENCIA",f"¿Seguro que desea eliminar el producto: {nombre}?") 276 | if respuesta == 'yes': 277 | self.Ejecutar_consulta(query,(dato,)) 278 | self.Obtener_productos() 279 | messagebox.showinfo('EXITO',f'Producto eliminado: {nombre}') 280 | else: 281 | messagebox.showerror('ERROR',f'Error al eliminar el producto: {nombre}') 282 | 283 | def Editar_producto(self): 284 | try: 285 | self.tree.item(self.tree.selection())['text'][0] 286 | except IndexError as e: 287 | messagebox.showerror("ERROR","Porfavor selecciona un elemento") 288 | return 289 | codigo=self.tree.item(self.tree.selection())['text'] 290 | nombre=self.tree.item(self.tree.selection())['values'][0] 291 | categoria=self.tree.item(self.tree.selection())['values'][1] 292 | cantidad=self.tree.item(self.tree.selection())['values'][2] 293 | precio=self.tree.item(self.tree.selection())['values'][3] 294 | descripcion=self.tree.item(self.tree.selection())['values'][4] 295 | 296 | self.Ventana_editar = Toplevel() 297 | self.Ventana_editar.title('EDITAR PRODUCTO') 298 | self.Ventana_editar.resizable(0,0) 299 | 300 | 301 | #Valores ventana editar 302 | label_codigo=Label(self.Ventana_editar,text="Codigo del producto: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=0,sticky='s',padx=5,pady=8) 303 | nuevo_codigo=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=codigo),width=25) 304 | nuevo_codigo.grid(row=0, column=1, padx=5, pady=8) 305 | 306 | label_nombre=Label(self.Ventana_editar,text="Nombre del producto: ",font=("Comic Sans", 10,"bold")).grid(row=1,column=0,sticky='s',padx=5,pady=8) 307 | nuevo_nombre=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=nombre),width=25) 308 | nuevo_nombre.grid(row=1, column=1, padx=5, pady=8) 309 | 310 | label_categoria=Label(self.Ventana_editar,text="Categoria: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=0,sticky='s',padx=5,pady=9) 311 | nuevo_combo_categoria=ttk.Combobox(self.Ventana_editar,values=["Microcontrolador","Microordenador","Sensores","Accesorios"], width=22,state="readonly") 312 | nuevo_combo_categoria.set(categoria) 313 | nuevo_combo_categoria.grid(row=2,column=1,padx=5,pady=0) 314 | 315 | label_cantidad=Label(self.Ventana_editar,text="Cantidad: ",font=("Comic Sans", 10,"bold")).grid(row=0,column=2,sticky='s',padx=5,pady=8) 316 | nueva_cantidad=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=cantidad),width=25) 317 | nueva_cantidad.grid(row=0, column=3, padx=5, pady=8) 318 | 319 | label_precio=Label(self.Ventana_editar,text="Precio (S/.): ",font=("Comic Sans", 10,"bold")).grid(row=1,column=2,sticky='s',padx=5,pady=8) 320 | nuevo_precio=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=precio),width=25) 321 | nuevo_precio.grid(row=1, column=3, padx=5, pady=8) 322 | 323 | label_descripcion=Label(self.Ventana_editar,text="Descripcion: ",font=("Comic Sans", 10,"bold")).grid(row=2,column=2,sticky='s',padx=10,pady=8) 324 | nueva_descripcion=Entry(self.Ventana_editar,textvariable=StringVar(self.Ventana_editar,value=descripcion),width=25) 325 | nueva_descripcion.grid(row=2, column=3, padx=10, pady=8) 326 | 327 | boton_actualizar=Button(self.Ventana_editar,text="ACTUALIZAR",command= lambda: self.Actualizar(nuevo_codigo.get(),nuevo_nombre.get(),nuevo_combo_categoria.get(),nueva_cantidad.get(),nuevo_precio.get(),nueva_descripcion.get(),codigo,nombre),height=2,width=20,bg="black",fg="white",font=("Comic Sans", 10,"bold")) 328 | boton_actualizar.grid(row=3, column=1,columnspan=2, padx=10, pady=15) 329 | 330 | self.Ventana_editar.mainloop() 331 | 332 | def Actualizar(self,nuevo_codigo,nuevo_nombre,nuevo_combo_categoria,nueva_cantidad,nuevo_precio,nueva_descripcion,codigo,nombre): 333 | query='UPDATE Productos SET Codigo = ?, Nombre = ?, Categoria = ?, Cantidad =?, Precio=?, Descripcion =? WHERE Codigo = ? AND Nombre =?' 334 | parameters=(nuevo_codigo,nuevo_nombre,nuevo_combo_categoria,nueva_cantidad,nuevo_precio,nueva_descripcion,codigo,nombre) 335 | self.Ejecutar_consulta(query,parameters) 336 | messagebox.showinfo('EXITO',f'Producto actualizado:{nuevo_nombre}') 337 | self.Ventana_editar.destroy() 338 | self.Obtener_productos() 339 | 340 | def Buscar_productos(self): 341 | if(self.Validar_busqueda()): 342 | #Obtener todos los elementos con get_children(), que retorna una tupla de ID. 343 | records=self.tree.get_children() 344 | for element in records: 345 | self.tree.delete(element) 346 | 347 | if (self.combo_buscar.get()=='Codigo'): 348 | query=("SELECT * FROM Productos WHERE Codigo LIKE ? ") 349 | parameters=(self.codigo_nombre.get()+"%") 350 | db_rows=self.Ejecutar_consulta(query,(parameters,)) 351 | for row in db_rows: 352 | self.tree.insert("",0, text=row[1],values=(row[2],row[3],row[4],row[5],row[6])) 353 | if(list(self.tree.get_children())==[]): 354 | messagebox.showerror("ERROR","Producto no encontrado") 355 | else: 356 | query=("SELECT * FROM Productos WHERE Nombre LIKE ? ") 357 | parameters=("%"+self.codigo_nombre.get()+"%") 358 | db_rows=self.Ejecutar_consulta(query,(parameters,)) 359 | for row in db_rows: 360 | self.tree.insert("",0, text=row[1],values=(row[2],row[3],row[4],row[5],row[6])) 361 | if(list(self.tree.get_children())==[]): 362 | messagebox.showerror("ERROR","Producto no encontrado") 363 | 364 | "--------------- OTRAS FUNCIONES --------------------" 365 | def Ejecutar_consulta(self, query, parameters=()): 366 | with sqlite3.connect(self.db_name) as conexion: 367 | cursor=conexion.cursor() 368 | result=cursor.execute(query,parameters) 369 | conexion.commit() 370 | return result 371 | 372 | def Validar_formulario_completo(self): 373 | if len(self.codigo.get()) !=0 and len(self.nombre.get()) !=0 and len(self.combo_categoria.get()) !=0 and len(self.cantidad.get()) !=0 and len(self.precio.get()) !=0 and len(self.descripcion.get()) !=0: 374 | return True 375 | else: 376 | messagebox.showerror("ERROR", "Complete todos los campos del formulario") 377 | 378 | def Validar_busqueda(self): 379 | if len(self.codigo_nombre.get()) !=0: 380 | return True 381 | else: 382 | self.tree.delete(*self.tree.get_children()) 383 | messagebox.showerror("ERROR", "Complete todos los campos para la busqueda") 384 | 385 | def Limpiar_formulario(self): 386 | self.codigo.delete(0, END) 387 | self.nombre.delete(0, END) 388 | self.cantidad.delete(0, END) 389 | self.precio.delete(0, END) 390 | self.descripcion.delete(0, END) 391 | 392 | def Validar_registrar(self): 393 | parameters= self.codigo.get() 394 | query="SELECT * FROM Productos WHERE Codigo = ?" 395 | dato = self.Ejecutar_consulta(query,(parameters,)) 396 | if (dato.fetchall() == []): 397 | return True 398 | else: 399 | messagebox.showerror("ERROR EN REGISTRO", "Codigo registrado anteriormente") 400 | 401 | if __name__ == '__main__': 402 | ventana_producto=Tk() 403 | label_crud=Label(ventana_producto) 404 | application=Producto(ventana_producto) 405 | ventana_producto.mainloop() 406 | -------------------------------------------------------------------------------- /SISTEMA DESKTOP/Imagenes/app_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/SISTEMA DESKTOP/Imagenes/app_logo.png -------------------------------------------------------------------------------- /SISTEMA DESKTOP/Imagenes/app_logo_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/SISTEMA DESKTOP/Imagenes/app_logo_2.png -------------------------------------------------------------------------------- /SISTEMA DESKTOP/Imagenes/arduino-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/SISTEMA DESKTOP/Imagenes/arduino-logo.png -------------------------------------------------------------------------------- /SISTEMA DESKTOP/Imagenes/buscar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/SISTEMA DESKTOP/Imagenes/buscar.png -------------------------------------------------------------------------------- /SISTEMA DESKTOP/Imagenes/informacion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/SISTEMA DESKTOP/Imagenes/informacion.png -------------------------------------------------------------------------------- /SISTEMA DESKTOP/Imagenes/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/SISTEMA DESKTOP/Imagenes/login.png -------------------------------------------------------------------------------- /SISTEMA DESKTOP/Imagenes/nodemcu-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/SISTEMA DESKTOP/Imagenes/nodemcu-logo.png -------------------------------------------------------------------------------- /SISTEMA DESKTOP/Imagenes/nuevo_usuario.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/SISTEMA DESKTOP/Imagenes/nuevo_usuario.png -------------------------------------------------------------------------------- /SISTEMA DESKTOP/Imagenes/raspberry-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/SISTEMA DESKTOP/Imagenes/raspberry-logo.png -------------------------------------------------------------------------------- /SISTEMA DESKTOP/Imagenes/recuperar_contraseña.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/SISTEMA DESKTOP/Imagenes/recuperar_contraseña.png -------------------------------------------------------------------------------- /SISTEMA DESKTOP/Imagenes/registrar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/SISTEMA DESKTOP/Imagenes/registrar.png -------------------------------------------------------------------------------- /SISTEMA DESKTOP/__pycache__/Formulario_registro.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/SISTEMA DESKTOP/__pycache__/Formulario_registro.cpython-39.pyc -------------------------------------------------------------------------------- /construcciónes rojas/construcciónes rojas/bolseado.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/construcciónes rojas/construcciónes rojas/bolseado.png -------------------------------------------------------------------------------- /construcciónes rojas/construcciónes rojas/casa.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/construcciónes rojas/construcciónes rojas/casa.ico -------------------------------------------------------------------------------- /construcciónes rojas/construcciónes rojas/casa2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/construcciónes rojas/construcciónes rojas/casa2.png -------------------------------------------------------------------------------- /construcciónes rojas/construcciónes rojas/ceramica.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/construcciónes rojas/construcciónes rojas/ceramica.png -------------------------------------------------------------------------------- /construcciónes rojas/construcciónes rojas/enlucido.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/construcciónes rojas/construcciónes rojas/enlucido.png -------------------------------------------------------------------------------- /construcciónes rojas/construcciónes rojas/pared.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/construcciónes rojas/construcciónes rojas/pared.png -------------------------------------------------------------------------------- /construcciónes rojas/construcciónes rojas/piso.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/construcciónes rojas/construcciónes rojas/piso.png -------------------------------------------------------------------------------- /construcciónes rojas/construcciónes rojas/proyrcto final rojas version2.py: -------------------------------------------------------------------------------- 1 | # Importar librería 2 | import tkinter as tk 3 | from tkinter import * 4 | from tkinter import ttk 5 | from tkinter import colorchooser 6 | ### Importar librería para los menús 7 | from tkinter import Menu 8 | # Importa librería para las cajas de mensajes 9 | from tkinter import messagebox 10 | from tkinter import messagebox as mBox 11 | 12 | def cerrar_aplicacion(): 13 | if messagebox.askokcancel("Cerrar la aplicación", "¿Seguro que deseas cerrar la Aplicación?\n\n*Optar por favor*"): 14 | ventana.destroy() 15 | 16 | #ventana pared 17 | def pared(): 18 | pared = Toplevel(ventana) 19 | pared.title("Pared") 20 | pared.geometry("1300x650+10+10") 21 | pared.resizable(0, 0) # Para evitar modificar el tamaño de una ventana 22 | pared.iconbitmap("casa.ico") 23 | pared.config(bg="blue") 24 | 25 | ### imagenes Formulario 26 | imagen2 = PhotoImage(file="pared.png") 27 | fondo2 = Label(pared, width=120,height=120, image=imagen2).place(x=1130,y=100) 28 | 29 | def pared1(): 30 | alturaP1=float(alturaP.get()) 31 | largoP1=float(largoP.get()) 32 | resultado=(alturaP1*1)*(largoP1*1) 33 | presupuesto=(resultado*800) 34 | agua=30*resultado 35 | arena=0.125*resultado 36 | ladrillos=46*resultado 37 | corceplas=2*resultado 38 | cemento=1*resultado 39 | etiqueta4 = Label(pared, text=(resultado), font=("Courier",15),bg="black",fg="white").place(x=780, y=180) 40 | etiqueta6 = Label(pared, text=(presupuesto), font=("Courier",15),bg="black",fg="white").place(x=780, y=230) 41 | etiqueta18 = Label(pared, text=("litros de agua:",agua), font=("Courier",12),bg="black",fg="white").place(x=780, y=370) 42 | etiqueta13 = Label(pared, text=("arena colorada:",arena), font=("Courier",12),bg="black",fg="white").place(x=780, y=410) 43 | etiqueta14 = Label(pared, text=("ladrillos:",ladrillos), font=("Courier",12),bg="black",fg="white").place(x=780, y=450) 44 | etiqueta15 = Label(pared, text=("corceplas:",corceplas), font=("Courier",12),bg="black",fg="white").place(x=780, y=490) 45 | etiqueta16 = Label(pared, text=("cemento:",cemento), font=("Courier",12),bg="black",fg="white").place(x=780, y=530) 46 | #etiquetas y botones 47 | etiqueta = Label(pared, text="Pared", font=("Courier",32), bg="white").place(x=580, y=30) 48 | etiqueta1 = Label(pared, text="Ingrese la altura de pared: ").place(x=410, y=120) 49 | alturaP=tk.DoubleVar() 50 | combo=Entry(pared,textvariable=alturaP).place(x=780, y=120) 51 | etiqueta2 = Label(pared, text="Ingrese largo de pared: ").place(x=410, y=150) 52 | largoP=tk.DoubleVar() 53 | combo2=Entry(pared,textvariable=largoP).place(x=780, y=150) 54 | etiqueta3 = Label(pared, text="Resultado: ").place(x=410, y=180) 55 | etiqueta5 = Label(pared, text="Precio del Presupuesto: ").place(x=410, y=230) 56 | Button(pared, text="Calcular", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=pared1 , width=12, font=("Arial",12)).place(x=1130,y=250) 57 | etiqueta17 = Label(pared, text="Materiales para M2", font=("Courier",16), bg="white").place(x=220, y=330) 58 | etiqueta7 = Label(pared, text="30 litros de agua", font=("Courier",12), bg="white").place(x=220, y=370) 59 | etiqueta8 = Label(pared, text="1/8 M3 de arena colorada", font=("Courier",12), bg="white").place(x=220, y=410) 60 | etiqueta9 = Label(pared, text="46 ladrillos", font=("Courier",12), bg="white").place(x=220, y=450) 61 | etiqueta10 = Label(pared, text="2 baldes de corceplas", font=("Courier",12), bg="white").place(x=220, y=490) 62 | etiqueta11 = Label(pared, text="1 balde de cemento", font=("Courier",12), bg="white").place(x=220, y=530) 63 | etiqueta12 = Label(pared, text="Cantidad de Materiales", font=("Courier",16),bg="black",fg="white").place(x=780, y=330) 64 | 65 | pared.transient(ventana) 66 | ventana.mainloop() 67 | #65 ladrillos, 2 baldes de corceplas, 1 balde de cemento y un octavo de m2 de arena colorada para 1 metro cuadrado de pared 68 | 69 | #ventana bolseado 70 | def bolseado(): 71 | bolseado = Toplevel(ventana) 72 | bolseado.title("Bolseado") 73 | bolseado.geometry("1300x650+10+10") 74 | bolseado.resizable(0, 0) # Para evitar modificar el tamaño de una ventana 75 | bolseado.iconbitmap("casa.ico") 76 | bolseado.config(bg="blue") 77 | 78 | ## 79 | imagen3 = PhotoImage(file="bolseado.png") 80 | fondo3 = Label(bolseado, width=120,height=120, image=imagen3).place(x=1130,y=100) 81 | 82 | def bolseado1(): 83 | alturaP1=float(alturaP.get()) 84 | largoP1=float(largoP.get()) 85 | resultado=(alturaP1*1)*(largoP1*1) 86 | presupuesto=(resultado*700) 87 | agua=8*resultado 88 | arena=0.03125*resultado 89 | cemento=1*resultado 90 | etiqueta4 = Label(bolseado, text=(resultado), font=("Courier",14),bg="black",fg="white").place(x=800, y=180) 91 | etiqueta6 = Label(bolseado, text=(presupuesto), font=("Courier",14),bg="black",fg="white").place(x=800, y=230) 92 | etiqueta12 = Label(bolseado, text=("litros de agua:",agua), font=("Courier",12), bg="black",fg="white").place(x=800, y=370) 93 | etiqueta13 = Label(bolseado, text=("arena negra:",arena), font=("Courier",12), bg="black",fg="white").place(x=800, y=410) 94 | etiqueta14 = Label(bolseado, text=("cemento:",cemento), font=("Courier",12),bg="black",fg="white").place(x=800, y=450) 95 | 96 | #etiquetas y botones 97 | etiqueta = Label(bolseado, text="Bolseado", font=("Courier",30), bg="white").place(x=580, y=30) 98 | etiqueta1 = Label(bolseado, text="Ingrese la altura de pared a bolsear: ").place(x=410, y=120) 99 | alturaP=tk.DoubleVar() 100 | combo=Entry(bolseado,textvariable=alturaP).place(x=800, y=120) 101 | etiqueta2 = Label(bolseado, text="Ingrese largo de pared a bolsear: ").place(x=410, y=150) 102 | largoP=tk.DoubleVar() 103 | combo2=Entry(bolseado,textvariable=largoP).place(x=800, y=150) 104 | etiqueta3 = Label(bolseado, text="Resultado: ").place(x=410, y=180) 105 | etiqueta5 = Label(bolseado, text="Precio del Presupuesto: ").place(x=410, y=230) 106 | Button(bolseado, text="Calcular", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=bolseado1, width=12, font=("Arial",12)).place(x=1130,y=250) 107 | 108 | etiqueta7 = Label(bolseado, text="Materiales para M2", font=("Courier",16), bg="white").place(x=220, y=330) 109 | etiqueta8 = Label(bolseado, text="8 litros de agua", font=("Courier",12), bg="white").place(x=220, y=370) 110 | etiqueta9 = Label(bolseado, text="1/32 M3 de arena negra", font=("Courier",12), bg="white").place(x=220, y=410) 111 | etiqueta10 = Label(bolseado, text="1 balde de cemento", font=("Courier",12), bg="white").place(x=220, y=450) 112 | etiqueta11 = Label(bolseado, text="Cantidad de Materiales", font=("Courier",16), bg="black",fg="white").place(x=800, y=330) 113 | 114 | #1 baldes cemento, 8 litros de agua, 1/32 de arena negra. 115 | 116 | bolseado.transient(ventana) 117 | ventana.mainloop() 118 | 119 | #ventana reboque 120 | def reboque(): 121 | reboque = Toplevel(ventana) 122 | reboque.title("Revoque") 123 | reboque.geometry("1300x650+10+10") 124 | reboque.resizable(0, 0) # Para evitar modificar el tamaño de una ventana 125 | reboque.iconbitmap("casa.ico") 126 | reboque.config(bg="blue") 127 | 128 | ## 129 | imagen4 = PhotoImage(file="revoque.png") 130 | fondo4 = Label(reboque, width=120,height=120, image=imagen4).place(x=1130,y=100) 131 | def reboque1(): 132 | alturaP1=float(alturaP.get()) 133 | largoP1=float(largoP.get()) 134 | resultado=(alturaP1*1)*(largoP1*1) 135 | presupuesto=(resultado*850) 136 | agua=30*resultado 137 | arena=0.125*resultado 138 | corceplas=2*resultado 139 | cemento=1*resultado 140 | etiqueta4 = Label(reboque, text=(resultado), font=("Courier",14), bg="black",fg="white").place(x=800, y=180) 141 | etiqueta6 = Label(reboque, text=(presupuesto), font=("Courier",14), bg="black",fg="white").place(x=800, y=230) 142 | etiqueta11 = Label(reboque, text=("litros de agua:",agua), font=("Courier",12), bg="black",fg="white").place(x=800, y=370) 143 | etiqueta13 = Label(reboque, text=("arena colorada:",arena), font=("Courier",12), bg="black",fg="white").place(x=800, y=410) 144 | etiqueta14 = Label(reboque, text=("corceplas:",corceplas), font=("Courier",12), bg="black",fg="white").place(x=800, y=450) 145 | etiqueta15 = Label(reboque, text=("cemento:",cemento), font=("Courier",12), bg="black",fg="white").place(x=800, y=490) 146 | 147 | #etiquetas y botones 148 | etiqueta = Label(reboque, text="Revoque", font=("Courier",30), bg="white").place(x=580, y=30) 149 | etiqueta1 = Label(reboque, text="Ingrese la altura de pared a revocar: ").place(x=400, y=120) 150 | alturaP=tk.DoubleVar() 151 | combo=Entry(reboque,textvariable=alturaP).place(x=800, y=120) 152 | etiqueta2 = Label(reboque, text="Ingrese largo de pared a revocar: ").place(x=400, y=150) 153 | largoP=tk.DoubleVar() 154 | combo2=Entry(reboque,textvariable=largoP).place(x=800, y=150) 155 | etiqueta3 = Label(reboque, text="Resultado: ").place(x=400, y=180) 156 | etiqueta5 = Label(reboque, text="Precio del Presupuesto: ").place(x=400, y=230) 157 | Button(reboque, text="Calcular", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=reboque1 , width=12, font=("Arial",12)).place(x=1130,y=250) 158 | 159 | etiqueta = Label(reboque, text="Materiales para M2", font=("Courier",16), bg="white").place(x=220, y=330) 160 | etiqueta7 = Label(reboque, text="30 litros de agua", font=("Courier",12), bg="white").place(x=220, y=370) 161 | etiqueta8 = Label(reboque, text="1/8 M3 de arena colorada", font=("Courier",12), bg="white").place(x=220, y=410) 162 | etiqueta9 = Label(reboque, text="2 balde de corceplas", font=("Courier",12), bg="white").place(x=220, y=450) 163 | etiqueta10 = Label(reboque, text="1 balde de cemento", font=("Courier",12), bg="white").place(x=220, y=490) 164 | 165 | etiqueta12 = Label(reboque, text="Cantidad de Materiales", font=("Courier",16), bg="black",fg="white").place(x=800, y=330) 166 | 167 | reboque.transient(ventana) 168 | ventana.mainloop() 169 | 170 | 171 | #ventana enlucido 172 | def enlucido(): 173 | enlucido = Toplevel(ventana) 174 | enlucido.title("Enlucido y Reboque") 175 | enlucido.geometry("1300x650+10+10") 176 | enlucido.resizable(0, 0) # Para evitar modificar el tamaño de una ventana 177 | enlucido.iconbitmap("casa.ico") 178 | enlucido.config(bg="blue") 179 | 180 | ## 181 | imagen7 = PhotoImage(file="enlucido.png") 182 | fondo7 = Label(enlucido, width=120,height=120, image=imagen7).place(x=1130,y=100) 183 | 184 | def enlucido1(): 185 | alturaP1=float(alturaP.get()) 186 | largoP1=float(largoP.get()) 187 | resultado=(alturaP1*1)*(largoP1*1) 188 | presupuesto=(resultado*650) 189 | agua=8*resultado 190 | arena=0.03125*resultado 191 | cal=1*resultado 192 | cemento=0.03125*resultado 193 | etiqueta4 = Label(enlucido, text=(resultado), font=("Courier",14), bg="black",fg="white").place(x=800, y=180) 194 | etiqueta6 = Label(enlucido, text=(presupuesto), font=("Courier",14),bg="black",fg="white").place(x=800, y=230) 195 | etiqueta11 = Label(enlucido, text=("litros de agua:",agua), font=("Courier",12), bg="black",fg="white").place(x=800, y=370) 196 | etiqueta13 = Label(enlucido, text=("arena colorada:",arena), font=("Courier",12), bg="black",fg="white").place(x=800, y=410) 197 | etiqueta14 = Label(enlucido, text=("cal:",cal), font=("Courier",12), bg="black",fg="white").place(x=800, y=450) 198 | etiqueta15 = Label(enlucido, text=("cemento:",cemento), font=("Courier",12),bg="black",fg="white").place(x=800, y=490) 199 | 200 | #etiquetas y botones 201 | etiqueta = Label(enlucido, text="Enlucido", font=("Courier",30), bg="white").place(x=600, y=30) 202 | etiqueta1 = Label(enlucido, text="Ingrese la altura de pared a enlucir: ").place(x=400, y=120) 203 | alturaP=tk.DoubleVar() 204 | combo=Entry(enlucido,textvariable=alturaP).place(x=800, y=120) 205 | etiqueta2 = Label(enlucido, text="Ingrese largo de pared a enlucir: ").place(x=400, y=150) 206 | largoP=tk.DoubleVar() 207 | combo2=Entry(enlucido,textvariable=largoP).place(x=800, y=150) 208 | etiqueta3 = Label(enlucido, text="Resultado: ").place(x=400, y=180) 209 | etiqueta5 = Label(enlucido, text="Precio del Presupuesto: ").place(x=400, y=230) 210 | Button(enlucido, text="Calcular", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=enlucido1 , width=12, font=("Arial",12)).place(x=1130,y=250) 211 | 212 | etiqueta = Label(enlucido, text="Materiales para M2", font=("Courier",16), bg="white").place(x=220, y=330) 213 | etiqueta7 = Label(enlucido, text="8 litros de agua", font=("Courier",12), bg="white").place(x=220, y=370) 214 | etiqueta8 = Label(enlucido, text="1/32 M3 de arena negra", font=("Courier",12), bg="white").place(x=220, y=410) 215 | etiqueta9 = Label(enlucido, text="1 balde de cal", font=("Courier",12), bg="white").place(x=220, y=450) 216 | etiqueta10 = Label(enlucido, text="1/32 balde de cemento", font=("Courier",12), bg="white").place(x=220, y=490) 217 | 218 | etiqueta12 = Label(enlucido, text="Cantidad de Materiales", font=("Courier",16),bg="black",fg="white").place(x=800, y=330) 219 | 220 | enlucido.transient(ventana) 221 | ventana.mainloop() 222 | 223 | #ventana piso 224 | def piso(): 225 | piso = Toplevel(ventana) 226 | piso.title("Piso") 227 | piso.geometry("1300x650+10+10") 228 | piso.resizable(0, 0) # Para evitar modificar el tamaño de una ventana 229 | piso.iconbitmap("casa.ico") 230 | piso.config(bg="blue") 231 | 232 | ## 233 | imagen5 = PhotoImage(file="piso.png") 234 | fondo5 = Label(piso, width=120,height=120, image=imagen5).place(x=1130,y=100) 235 | 236 | def piso1(): 237 | anchoP1=float(anchoP.get()) 238 | largoP1=float(largoP.get()) 239 | resultado=(anchoP1*1)*(largoP1*1) 240 | presupuesto=(resultado*900) 241 | agua=15*resultado 242 | cemento=2*resultado 243 | ripio=0.125*resultado 244 | etiqueta4 = Label(piso, text=(resultado), font=("Courier",14), bg="black",fg="white").place(x=800, y=180) 245 | etiqueta6 = Label(piso, text=(presupuesto), font=("Courier",14),bg="black",fg="white").place(x=800, y=230) 246 | etiqueta11 = Label(piso, text=("litros de agua:",agua), font=("Courier",12),bg="black",fg="white").place(x=800, y=370) 247 | etiqueta13 = Label(piso, text=("ripio:",ripio), font=("Courier",12),bg="black",fg="white").place(x=800, y=410) 248 | etiqueta14 = Label(piso, text=("cemento:",cemento), font=("Courier",12),bg="black",fg="white").place(x=800, y=450) 249 | 250 | #etiquetas y botones 251 | etiqueta = Label(piso, text="Piso", font=("Courier",30), bg="white").place(x=600, y=30) 252 | etiqueta1 = Label(piso, text="Ingrese el ancho del piso: ").place(x=400, y=120) 253 | anchoP=tk.DoubleVar() 254 | combo=Entry(piso,textvariable=anchoP).place(x=800, y=120) 255 | etiqueta2 = Label(piso, text="Ingrese largo del piso: ").place(x=400, y=150) 256 | largoP=tk.DoubleVar() 257 | combo2=Entry(piso,textvariable=largoP).place(x=800, y=150) 258 | etiqueta3 = Label(piso, text="Resultado: ").place(x=400, y=180) 259 | etiqueta5 = Label(piso, text="Precio del Presupuesto: ").place(x=400, y=230) 260 | Button(piso, text="Calcular", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=piso1 , width=12, font=("Arial",12)).place(x=1130,y=250) 261 | 262 | etiqueta = Label(piso, text="Materiales para M2", font=("Courier",16), bg="white").place(x=220, y=330) 263 | etiqueta7 = Label(piso, text="15 litros de agua", font=("Courier",12), bg="white").place(x=220, y=370) 264 | etiqueta8 = Label(piso, text="1/32 M3 de ripio", font=("Courier",12), bg="white").place(x=220, y=410) 265 | etiqueta9 = Label(piso, text="2 baldes de cemento", font=("Courier",12), bg="white").place(x=220, y=450) 266 | 267 | etiqueta12 = Label(piso, text="Cantidad de Materiales", font=("Courier",16),bg="black",fg="white").place(x=800, y=330) 268 | 269 | piso.transient(ventana) 270 | ventana.mainloop() 271 | 272 | #ventana ceramica 273 | def ceramica(): 274 | ceramica = Toplevel(ventana) 275 | ceramica.title("Ceramicas") 276 | ceramica.geometry("1300x650+10+10") 277 | ceramica.resizable(0, 0) # Para evitar modificar el tamaño de una ventana 278 | ceramica.iconbitmap("casa.ico") 279 | ceramica.config(bg="blue") 280 | 281 | ## 282 | imagen6 = PhotoImage(file="ceramica.png") 283 | fondo6 = Label(ceramica, width=120,height=120, image=imagen6).place(x=1130,y=100) 284 | 285 | def ceramica1(): 286 | anchoP1=float(anchoP.get()) 287 | largoP1=float(largoP.get()) 288 | resultado=(anchoP1*1)*(largoP1*1) 289 | presupuesto=(resultado*700) 290 | agua=4*resultado 291 | pegamento=2*resultado 292 | ceramicas=3*resultado 293 | etiqueta4 = Label(ceramica, text=(resultado), font=("Courier",14),bg="black",fg="white").place(x=800, y=180) 294 | etiqueta6 = Label(ceramica, text=(presupuesto), font=("Courier",14),bg="black",fg="white").place(x=800, y=230) 295 | etiqueta11 = Label(ceramica, text=("litros de agua:",agua), font=("Courier",12), bg="black",fg="white").place(x=800, y=370) 296 | etiqueta13 = Label(ceramica, text=("pegamento:",pegamento), font=("Courier",12), bg="black",fg="white").place(x=800, y=410) 297 | etiqueta14 = Label(ceramica, text=("ceramica:",ceramicas), font=("Courier",12),bg="black",fg="white").place(x=800, y=450) 298 | 299 | #etiquetas y botones 300 | etiqueta = Label(ceramica, text="Ceramica", font=("Courier",30), bg="white").place(x=600, y=30) 301 | etiqueta1 = Label(ceramica, text="Ingrese el ancho del piso ah colocar ceramica: ").place(x=400, y=120) 302 | anchoP=tk.DoubleVar() 303 | combo=Entry(ceramica,textvariable=anchoP).place(x=800, y=120) 304 | etiqueta2 = Label(ceramica, text="Ingrese largo del piso ah colocar ceramica: ").place(x=400, y=150) 305 | largoP=tk.DoubleVar() 306 | combo2=Entry(ceramica,textvariable=largoP).place(x=800, y=150) 307 | etiqueta3 = Label(ceramica, text="Resultado: ").place(x=400, y=180) 308 | etiqueta5 = Label(ceramica, text="Precio del Presupuesto: ").place(x=400, y=230) 309 | Button(ceramica, text="Calcular", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=ceramica1, width=12, font=("Arial",12)).place(x=1130,y=250) 310 | 311 | 312 | etiqueta = Label(ceramica, text="Materiales para M2", font=("Courier",16), bg="white").place(x=220, y=330) 313 | etiqueta7 = Label(ceramica, text="4 litros de agua", font=("Courier",12), bg="white").place(x=220, y=370) 314 | etiqueta8 = Label(ceramica, text="2 baldes de pegamento", font=("Courier",12), bg="white").place(x=220, y=410) 315 | etiqueta9 = Label(ceramica, text="3 ceramica de 40x40 para m2", font=("Courier",12), bg="white").place(x=220, y=450) 316 | 317 | 318 | etiqueta12 = Label(ceramica, text="Cantidad de Materiales", font=("Courier",16), bg="black",fg="white").place(x=800, y=330) 319 | 320 | ceramica.transient(ventana) 321 | ventana.mainloop() 322 | 323 | 324 | #ventana techado 325 | def techado(): 326 | techado = Toplevel(ventana) 327 | techado.title("Techado") 328 | techado.geometry("1300x650+10+10") 329 | techado.resizable(0, 0) # Para evitar modificar el tamaño de una ventana 330 | techado.iconbitmap("casa.ico") 331 | techado.config(bg="blue") 332 | 333 | ## 334 | imagen8 = PhotoImage(file="techado.png") 335 | fondo8 = Label(techado, width=120,height=120, image=imagen8).place(x=1130,y=100) 336 | 337 | def techado1(): 338 | anchot1=float(anchot.get()) 339 | largot1=float(largot.get()) 340 | resultado=(anchot1*1)*(largot1*1) 341 | presupuesto=(resultado*5500) 342 | chapa=1*resultado 343 | tornillo=12*resultado 344 | alfajia=4*resultado 345 | palo=2*resultado 346 | madera=10*resultado 347 | etiqueta4 = Label(techado, text=(resultado), font=("Courier",14), bg="black",fg="white").place(x=800, y=180) 348 | etiqueta6 = Label(techado, text=(presupuesto), font=("Courier",14), bg="black",fg="white").place(x=800, y=230) 349 | etiqueta14 = Label(techado, text=("chapa:",chapa), font=("Courier",12),bg="black",fg="white").place(x=800, y=370) 350 | etiqueta15 = Label(techado, text=("tornillos:",tornillo), font=("Courier",12), bg="black",fg="white").place(x=800, y=410) 351 | etiqueta16 = Label(techado, text=("alfajias:",alfajia), font=("Courier",12),bg="black",fg="white").place(x=800, y=450) 352 | etiqueta17 = Label(techado, text=("palos:",palo), font=("Courier",12), bg="black",fg="white").place(x=800, y=490) 353 | etiqueta18 = Label(techado, text=("tablas:",madera), font=("Courier",12), bg="black",fg="white").place(x=800, y=530) 354 | 355 | #etiquetas y botones 356 | etiqueta = Label(techado, text="Techado", font=("Courier",30), bg="white").place(x=600, y=30) 357 | etiqueta1 = Label(techado, text="Ingrese el ancho del techo ah colocar: ").place(x=400, y=120) 358 | anchot=tk.DoubleVar() 359 | combo=Entry(techado,textvariable=anchot).place(x=800, y=120) 360 | etiqueta2 = Label(techado, text="Ingrese largo del techo ah colocar: ").place(x=400, y=150) 361 | largot=tk.DoubleVar() 362 | combo2=Entry(techado,textvariable=largot).place(x=800, y=150) 363 | etiqueta3 = Label(techado, text="Resultado: ").place(x=400, y=180) 364 | etiqueta5 = Label(techado, text="Precio del Presupuesto: ").place(x=400, y=230) 365 | Button(techado, text="Calcular", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=techado1, width=12, font=("Arial",12)).place(x=1130,y=250) 366 | 367 | etiqueta7 = Label(techado, text="Materiales para M3", font=("Courier",16), bg="white").place(x=220, y=330) 368 | etiqueta8 = Label(techado, text="1 chapa de m2", font=("Courier",12), bg="white").place(x=220, y=370) 369 | etiqueta9 = Label(techado, text="12 tornillos con arandelas", font=("Courier",12), bg="white").place(x=220, y=410) 370 | etiqueta10 = Label(techado, text="4 alfajias de 1m", font=("Courier",12), bg="white").place(x=220, y=450) 371 | etiqueta11 = Label(techado, text="2 palos de 1m", font=("Courier",12), bg="white").place(x=220, y=490) 372 | etiqueta12 = Label(techado, text="10 tablas de 1m y de 10cm", font=("Courier",12), bg="white").place(x=220, y=530) 373 | etiqueta13 = Label(techado, text="Cantidad de Materiales", font=("Courier",16), bg="black",fg="white").place(x=800, y=330) 374 | 375 | techado.transient(ventana) 376 | ventana.mainloop() 377 | 378 | 379 | #ventana hija 380 | def accion1(): 381 | hija = Toplevel(ventana) 382 | hija.title("Constructora Rojas") 383 | hija.geometry("1300x650+10+10") 384 | hija.resizable(0, 0) # Para evitar modificar el tamaño de una ventana 385 | hija.iconbitmap("casa.ico") 386 | hija.config(bg="blue") 387 | 388 | ### imagenes Formulario 389 | imagen2 = PhotoImage(file="pared.png") 390 | fondo2 = Label(hija, width=120,height=120, image=imagen2).place(x=50,y=300) 391 | ## 392 | imagen3 = PhotoImage(file="bolseado.png") 393 | fondo3 = Label(hija, width=120,height=120, image=imagen3).place(x=230,y=300) 394 | ## 395 | imagen4 = PhotoImage(file="revoque.png") 396 | fondo4 = Label(hija, width=120,height=120, image=imagen4).place(x=410,y=300) 397 | ## 398 | imagen5 = PhotoImage(file="piso.png") 399 | fondo5 = Label(hija, width=120,height=120, image=imagen5).place(x=590,y=300) 400 | ## 401 | imagen6 = PhotoImage(file="ceramica.png") 402 | fondo6 = Label(hija, width=120,height=120, image=imagen6).place(x=770,y=300) 403 | ## 404 | imagen7 = PhotoImage(file="enlucido.png") 405 | fondo7 = Label(hija, width=120,height=120, image=imagen7).place(x=950,y=300) 406 | ## 407 | imagen8 = PhotoImage(file="techado.png") 408 | fondo8 = Label(hija, width=120,height=120, image=imagen8).place(x=1130,y=300) 409 | 410 | 411 | #botones 412 | Cerrar = Button(hija, text="Pared", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=pared, width=12, font=("Arial",12)).place(x=50,y=470) 413 | Cerrar = Button(hija, text="Bolseado", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=bolseado, width=12, font=("Arial",12)).place(x=230,y=470) 414 | Cerrar = Button(hija, text="Revoque", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=reboque, width=12, font=("Arial",12)).place(x=410,y=470) 415 | Cerrar = Button(hija, text="Piso", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=piso, width=12, font=("Arial",12)).place(x=590,y=470) 416 | Cerrar = Button(hija, text="Ceramica", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=ceramica, width=12, font=("Arial",12)).place(x=770,y=470) 417 | Cerrar = Button(hija, text="Enlucido", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=enlucido, width=12, font=("Arial",12)).place(x=950,y=470) 418 | Cerrar = Button(hija, text="Techado", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=5, command=techado, width=12, font=("Arial",12)).place(x=1130,y=470) 419 | 420 | etiqueta = Label(hija, text="Trabajos", font=("Courier",32), bg="blue",fg="white").place(x=500, y=30) 421 | 422 | hija.transient(ventana) 423 | ventana.mainloop() 424 | 425 | #ventana madre 426 | ventana = tk.Tk() 427 | ventana.protocol("WM_DELETE_WINDOW", cerrar_aplicacion) 428 | ventana.title("Constructora Rojas") 429 | ventana.geometry("1300x650+10+10") 430 | ventana.resizable(0, 0) # Para evitar modificar el tamaño de una ventana 431 | ventana.iconbitmap("casa.ico") 432 | ventana.config(bg="blue") 433 | imagen = PhotoImage(file="casa2.png") 434 | fondo1 = Label(ventana, image=imagen).place(x=500,y=200) 435 | 436 | # creamos una barra de menus y la añadimos a la ventana principal 437 | menubar = Menu(ventana) 438 | ventana.config(menu=menubar) 439 | 440 | # Agregar opciones al menú 441 | filemenu = Menu(menubar, tearoff=0) 442 | filemenu.add_command(label="Ir al programa",font=("Calibri",10), command=accion1) 443 | #Separador de Ventana 444 | filemenu.add_separator() 445 | #fin Separador de Ventana 446 | filemenu.add_command(label="Salir del Programa", command=cerrar_aplicacion) 447 | 448 | helpmenu = Menu(menubar, tearoff=0) 449 | helpmenu.add_command(label="Ayuda") 450 | 451 | menubar.add_cascade(label="Archivo", menu=filemenu) 452 | menubar.add_cascade(label="Ayuda", menu=helpmenu) 453 | 454 | # Crear Boton Salir de Sistema 455 | Cerrar = Button(ventana, text="Ir al programa", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=8, command=accion1 , font=("Arial",12), width=15).place(x=450,y=520) 456 | Cerrar = Button(ventana, text="Salir del Sistema", fg="#17202A", bg="#FF8000", relief="ridge", borderwidth=8, command=cerrar_aplicacion ,font=("Arial",12), width=15).place(x=680,y=520) 457 | etiqueta = Label(ventana, text="Constructora Rojas", font=("Courier",32), bg="blue",fg="white").place(x=400, y=30) 458 | etiqueta1 = Label(ventana, text="Presupuestos de Mamposteria", font=("Courier",18), bg="blue",fg="white").place(x=450, y=100) 459 | 460 | # Activar ventana 461 | ventana.mainloop() -------------------------------------------------------------------------------- /construcciónes rojas/construcciónes rojas/revoque.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/construcciónes rojas/construcciónes rojas/revoque.png -------------------------------------------------------------------------------- /construcciónes rojas/construcciónes rojas/techado.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/construcciónes rojas/construcciónes rojas/techado.png -------------------------------------------------------------------------------- /database_proyecto.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/database_proyecto.db -------------------------------------------------------------------------------- /tienda.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/tienda.db -------------------------------------------------------------------------------- /tienda_diaz.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuisOchoa1495/Python-Tkinter/cae4916329cfaa7ed397e0fd6c81e93d9a207c4e/tienda_diaz.db --------------------------------------------------------------------------------