martes, 10 de enero de 2023

Create free e-mail account

 

Go to outlook.com 

Tap create free acount 

Enter email user 

Enter password 

Enter birthdate 

Seguir los pasos 

Again outlook.com and enter with user and password 

Tap en el icono arriba a izquierda 

Escoger excel. 


martes, 1 de diciembre de 2020

Mantenimiento de Articulos con SQLite y Python

Buscar por Nombre con SQLite y Python




Formulario principal

import tkinter as tk
from tkinter import ttk
from tkinter import messagebox as mb
from tkinter import scrolledtext as st
import articulos2

class FormularioArticulos:
    def __init__(self):
        self.articulo1=articulos2.Articulos()
        self.ventana1=tk.Tk()
        self.ventana1.title("Mantenimiento de artículos")
        self.ventana1.geometry("500x500+400+200")
        self.cuaderno1 = ttk.Notebook(self.ventana1)        
        self.carga_articulos()
        self.consulta_por_codigo()
        self.listado_completo()
        self.Buscar()
        self.cuaderno1.grid(column=0row=0padx=10pady=10)
        self.ventana1.mainloop()

    def carga_articulos(self):
        self.pagina1 = ttk.Frame(self.cuaderno1)
        self.cuaderno1.add(self.pagina1, text="Carga de artículos")
        self.labelframe1=ttk.LabelFrame(self.pagina1, text="Artículo")        
        self.labelframe1.grid(column=0row=0padx=5pady=10)
        self.label1=ttk.Label(self.labelframe1, text="Descripción:")
        self.label1.grid(column=0row=0padx=4pady=4)
        self.descripcioncarga=tk.StringVar()
        self.entrydescripcion=ttk.Entry(self.labelframe1, textvariable=self.descripcioncarga)
        self.entrydescripcion.grid(column=1row=0padx=4pady=4)
        self.label2=ttk.Label(self.labelframe1, text="Precio:")        
        self.label2.grid(column=0row=1padx=4pady=4)
        self.preciocarga=tk.StringVar()
        self.entryprecio=ttk.Entry(self.labelframe1, textvariable=self.preciocarga)
        self.entryprecio.grid(column=1row=1padx=4pady=4)
        self.boton1=ttk.Button(self.labelframe1, text="Confirmar"command=self.agregar)
        self.boton1.grid(column=1row=2padx=4pady=4)

    def agregar(self):
        datos=(self.descripcioncarga.get(), self.preciocarga.get())
        self.articulo1.alta(datos)
        mb.showinfo("Información""Los datos fueron cargados")
        self.descripcioncarga.set("")
        self.preciocarga.set("")

    def consulta_por_codigo(self):
        self.pagina2 = ttk.Frame(self.cuaderno1)
        self.cuaderno1.add(self.pagina2, text="Consulta por código")
        self.labelframe2=ttk.LabelFrame(self.pagina2, text="Artículo")
        self.labelframe2.grid(column=0row=0padx=5pady=10)
        self.label1=ttk.Label(self.labelframe2, text="Código:")
        self.label1.grid(column=0row=0padx=4pady=4)
        self.codigo=tk.StringVar()
        self.entrycodigo=ttk.Entry(self.labelframe2, textvariable=self.codigo)
        self.entrycodigo.grid(column=1row=0padx=4pady=4)
        self.label2=ttk.Label(self.labelframe2, text="Descripción:")        
        self.label2.grid(column=0row=1padx=4pady=4)
        self.descripcion=tk.StringVar()
        self.entrydescripcion=ttk.Entry(self.labelframe2, textvariable=self.descripcion, state="readonly")
        self.entrydescripcion.grid(column=1row=1padx=4pady=4)
        self.label3=ttk.Label(self.labelframe2, text="Precio:")        
        self.label3.grid(column=0row=2padx=4pady=4)
        self.precio=tk.StringVar()
        self.entryprecio=ttk.Entry(self.labelframe2, textvariable=self.precio, state="readonly")
        self.entryprecio.grid(column=1row=2padx=4pady=4)
        self.boton1=ttk.Button(self.labelframe2, text="Consultar"command=self.consultar)
        self.boton1.grid(column=1row=3padx=4pady=4)

    def consultar(self):
        datos=(self.codigo.get(), )
        respuesta=self.articulo1.consulta(datos)
        if len(respuesta)>0:
            self.descripcion.set(respuesta[0][0])
            self.precio.set(respuesta[0][1])
        else:
            self.descripcion.set('')
            self.precio.set('')
            mb.showinfo("Información""No existe un artículo con dicho código")

    def Buscar(self):
        self.pagina4 = ttk.Frame(self.cuaderno1)
        self.cuaderno1.add(self.pagina4,text="Buscar por Nombre")
        self.labelFrame4=ttk.LabelFrame(self.pagina4,text="Articulo")
        self.labelFrame4.grid(column=0,row=0,padx=5,pady=10)
        self.label6=ttk.Label(self.labelFrame4, text="Nombre:")
        self.label6.grid(column=0row=0padx=4pady=4)
        self.nombre=tk.StringVar()
        self.entrynombre=ttk.Entry(self.labelFrame4, textvariable=self.nombre)
        self.entrynombre.grid(column=1row=0padx=4pady=4)
        self.boton6=ttk.Button(self.labelFrame4, text="Consultar"command=self.consultar2)
        self.boton6.grid(column=2row=0padx=4pady=4)
        self.listbox1=tk.Listbox(self.labelFrame4,width=35)
        self.listbox1.grid(column=1,row=4,padx=4,pady=4)
        self.boton8=ttk.Button(self.labelFrame4, text="Seleccionar"command=self.sele1)
        self.boton8.grid(column=2,row=4)

    def consultar2(self):
        datos2=self.nombre.get()
        respuesta2=self.articulo1.por_nombre(datos2)
        self.listbox1.delete(0,tk.END)
        for fila in respuesta2:
            self.listbox1.insert(tk.END,str(fila[0])+"  "+fila[1]+"   "+str(fila[2]))

    def sele1(self):
        if len(self.listbox1.curselection())!=0:
            self.listbox1.get(self.listbox1.curselection()[0])
        
    def listado_completo(self):
        self.pagina3 = ttk.Frame(self.cuaderno1)
        self.cuaderno1.add(self.pagina3, text="Listado completo")
        self.labelframe3=ttk.LabelFrame(self.pagina3, text="Artículo")
        self.labelframe3.grid(column=0row=0padx=5pady=10)
        self.boton1=ttk.Button(self.labelframe3, text="Listado completo"command=self.listar)
        self.boton1.grid(column=0row=0padx=4pady=4)
        self.label7=ttk.Label(self.labelframe3, text="Código\tDescripcion\t\t\tPrecio")
        self.label7.grid(column=0row=1padx=1pady=1)
        self.scrolledtext1=st.ScrolledText(self.labelframe3, width=40height=15)
        self.scrolledtext1.grid(column=0,row=2padx=10pady=10)
        # self.scrolltext2=st.ScrolledText(self.labelframe3, width=7, height=10)
        # self.scrolltext2.grid(column=1,row=1,padx=5,pady=5)

    def listar(self):
        respuesta=self.articulo1.recuperar_todos()
        self.scrolledtext1.delete("1.0", tk.END)        
        for fila in respuesta:
            self.scrolledtext1.insert(tk.END, str(fila[0])+"\t"+fila[1]+"\t\t\t"+str(fila[2])+"\n")
            # self.scrolltext2.insert(tk.END, str(fila[2])+"\n")


aplicacion1=FormularioArticulos()

articulos2.py

import sqlite3

class Articulos:

    def abrir(self):
        conexion=sqlite3.connect("bd1.db")
        return conexion


    def alta(selfdatos):
        cone=self.abrir()
        cursor=cone.cursor()
        sql="insert into articulos(descripcion, precio) values (?,?)"
        cursor.execute(sql, datos)
        cone.commit()
        cone.close()

    def consulta(selfdatos):
        try:
            cone=self.abrir()
            cursor=cone.cursor()
            sql="select descripcion, precio from articulos where codigo=?"
            cursor.execute(sql, datos)
            return cursor.fetchall()
        finally:
            cone.close()
            
    def por_nombre(selfdatos2):
        try:
            cone=self.abrir()
            cursor=cone.cursor()
            sql="select * from articulos where descripcion like '"+str(datos2)+"%'"
            cursor.execute(sql)
            return cursor.fetchall()
        finally:
            cone.close()

    def recuperar_todos(self):
        try:
            cone=self.abrir()
            cursor=cone.cursor()
            sql="select codigo, descripcion, precio from articulos"
            cursor.execute(sql)
            return cursor.fetchall()
        finally:
            cone.close()


minuvasoft10@gmail.com
Miguel Nunez

Primero ejecutar el archivo crearTabla.py una vez
import sqlite3

conexion=sqlite3.connect("bd1.db")
try:
    conexion.execute("""create table articulos (
                              codigo integer primary key autoincrement,
                              descripcion text,
                              precio real
                        )""")
    print("se creo la tabla articulos")                        
except sqlite3.OperationalError:
    print("La tabla articulos ya existe")                    
conexion.close()


sábado, 14 de noviembre de 2020

Ventana de Dialogos con Python

 

import tkinter as tk
from tkinter import ttk

class Aplicacion:

    def __init__(self):
        self.ventana1=tk.Tk()
        self.ventana1.title("Dialogos")
        self.agregar_menu()
        self.ventana1.mainloop()

    def agregar_menu(self):
        self.menubar1 = tk.Menu(self.ventana1)
        self.ventana1.config(menu=self.menubar1)
        self.opciones1 = tk.Menu(self.menubar1, tearoff=0)
        self.opciones1.add_command(label="Configurar ventana"command=self.configurar)
        self.menubar1.add_cascade(label="Opciones"menu=self.opciones1)    

    def configurar(self):
        dialogo1 = DialogoTamano(self.ventana1)
        s=dialogo1.mostrar()
        self.ventana1.geometry(s[0]+"x"+s[1])
        

class DialogoTamano:

    def __init__(selfventanaprincipal):
        self.dialogo=tk.Toplevel(ventanaprincipal)
        self.label1=ttk.Label(self.dialogo, text="Ingrese ancho:")
        self.label1.grid(column=0row=0padx=5pady=5)
        self.dato1=tk.StringVar()
        self.entry1=ttk.Entry(self.dialogo, textvariable=self.dato1)
        self.entry1.grid(column=1row=0padx=5pady=5)
        self.entry1.focus()
        self.label2=ttk.Label(self.dialogo, text="Ingrese alto:")
        self.label2.grid(column=0row=1padx=5pady=5)
        self.dato2=tk.StringVar()
        self.entry2=ttk.Entry(self.dialogo, textvariable=self.dato2)
        self.entry2.grid(column=1row=1padx=5pady=5)
        self.boton1=ttk.Button(self.dialogo, text="Confirmar"command=self.confirmar)
        self.boton1.grid(column=1row=2padx=5pady=5)
        self.dialogo.protocol("WM_DELETE_WINDOW"self.confirmar)
        self.dialogo.resizable(0,0)
        self.dialogo.grab_set()

    def mostrar(self):
        self.dialogo.wait_window()
        return (self.dato1.get(), self.dato2.get())

    def confirmar(self):
        self.dialogo.destroy()


aplicacion1=Aplicacion() 

Conectar a MySql con Java Netbeans mediante un Formulario

 Tener agregado en libraries el conector mysql. clase coneBD.java package pktForm12; import java.sql.*; import javax.swing.JOptionPane; publ...