Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import*
- from tkinter import messagebox
- import sqlite3
- connP = sqlite3.connect('banco de dados/pessoas.db')
- connC = sqlite3.connect('banco de dados/codigos.db')
- pessoasDB = connP.cursor()
- codigosDB = connC.cursor()
- pessoasDB.execute("""
- CREATE TABLE IF NOT EXISTS pessoas (
- id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- usuario TEXT NOT NULL,
- senha TEXT NOT NULL
- );
- """)
- codigosDB.execute("""
- CREATE TABLE IF NOT EXISTS produtos (
- codigo INTEGER(12) NOT NULL PRIMARY KEY,
- nomeProduto TEXT NOT NULL,
- codigoProduto TEXT NOT NULL,
- precoProduto FLOAT(4) NOT NULL,
- categoria VARCHAR(7)
- );
- """)
- login = Tk()
- login.geometry("350x350+200+150")
- login.title("Tela login")
- def cadProdutoBind():
- pass
- def entrar():
- if ed_login.get() == "matheus" and ed_senha.get() == "balieiro":
- menu_principal = Tk()
- menu_principal.geometry("1000x650")
- login.destroy()
- def cad_produto():
- cadastro_produto = Tk()
- cadastro_produto.geometry("500x500+200+150")
- menu_principal.destroy()
- frame_cadastro_top = Frame(cadastro_produto, height=100, bd=8, width=480, relief='groove')
- frame_cadastro_top.pack(side=TOP)
- titulo_cadastro_top = Label(frame_cadastro_top, font="arial 15 bold", width=40, text="Cadastro do Produto", fg="black", relief="sunken", bg="gray")
- titulo_cadastro_top.grid(row=0, column=2)
- frame_cadastro_meio = Frame(cadastro_produto, height=330,bd=8, width=500, relief="groove", bg="gray")
- frame_cadastro_meio.place(x=0, y=50)
- bt_voltar = Button(frame_cadastro_meio, font="arial 15 bold", text="Nome do Produto", fg="black")
- bt_voltar.place(x=490, y=20)
- nome_cadastro_top = Label(frame_cadastro_meio, font="arial 15 bold", text="Nome do Produto", fg="black", relief="raised", bg="gray")
- nome_cadastro_top.place(x=20, y=20)
- nome_entry = Entry(frame_cadastro_meio, width=25)
- nome_entry.place(x=20, y=55)
- codigo_cadastro_top = Label(frame_cadastro_meio, font="arial 15 bold", text="Codigo do Produto", fg="black", relief="raised", bg="gray")
- codigo_cadastro_top.place(x=20, y=85)
- codigo_entry = Entry(frame_cadastro_meio, width=25)
- codigo_entry.place(x=20, y=120)
- nome_cadastro_top = Label(frame_cadastro_meio, font="arial 15 bold", text="Categoria", fg="black", relief="raised", bg="gray")
- nome_cadastro_top.place(x=20, y=145)
- bt_biscoito = Checkbutton(frame_cadastro_meio, font="arial 10 bold", text="Biscoitos, Bolos e Bolachas", fg="black", bg="gray")
- bt_biscoito.place(x=20, y=175)
- bt_frios = Checkbutton(frame_cadastro_meio, font="arial 10 bold", text="Frios e Embutidos", fg="black", bg="gray")
- bt_frios.place(x=20, y=195)
- bt_pao = Checkbutton(frame_cadastro_meio, font="arial 10 bold", text="Pães", fg="black", bg="gray")
- bt_pao.place(x=20, y=215)
- bt_ovos = Checkbutton(frame_cadastro_meio, font="arial 10 bold", text="Ovos, Queijos, Leite, Cia", fg="black", bg="gray")
- bt_ovos.place(x=20, y=235)
- bt_congelado = Checkbutton(frame_cadastro_meio, font="arial 10 bold", text="Congelado", fg="black", bg="gray")
- bt_congelado.place(x=20, y=255)
- bt_bar = Checkbutton(frame_cadastro_meio, font="arial 10 bold", text="Restaurante", fg="black", bg="gray")
- bt_bar.place(x=250, y=175)
- bt_congelado = Checkbutton(frame_cadastro_meio, font="arial 10 bold", text="Bebidas", fg="black", bg="gray")
- bt_congelado.place(x=250, y=195)
- bt_cadastrar = Button(frame_cadastro_meio, font="arial 10 bold", text="Cadastrar Produto", relief="groove", fg="black", command = cadProdutoBind)
- bt_cadastrar.place(x=140, y=285)
- frame_baixo = Frame(cadastro_produto, height=115, width=500, bg="gray", relief="groove", bd=8)
- frame_baixo.pack(side=BOTTOM)
- S = Scrollbar(frame_baixo)
- T = Text(frame_baixo, height=4, width=50)
- S.pack(side=RIGHT)
- T.pack(side=LEFT)
- S.config(command=T.yview)
- T.config(yscrollcommand=S.set)
- cadastro_produto.mainloop()
- def controle_estoque():
- estoque = Tk()
- estoque.geometry("500x500+200+150")
- menu_principal.destroy()
- estoque.mainloop()
- def controle_fornecedor():
- fornecedor = Tk()
- fornecedor.geometry("500x500+200+150")
- menu_principal.destroy()
- fornecedor.mainloop()
- topo_frame = Frame(menu_principal, width=900, height=100, bg="gray")
- topo_frame.pack(side=TOP)
- btn_vendas = Button(topo_frame, width=10, height=5, text="Cad Produto", font="Arial 10 bold", relief="sunken", bg="cyan", command=cad_produto)
- btn_vendas.place(x=50, y=5)
- btn_vendas = Button(topo_frame, width=10, height=5, text="Estoque", font="Arial 10 bold", relief="sunken", bg="white", command=controle_estoque)
- btn_vendas.place(x=400, y=5)
- btn_vendas = Button(topo_frame, width=10, height=5, text="Fornecedor", font="Arial 10 bold", relief="sunken", bg="magenta", command=controle_fornecedor)
- btn_vendas.place(x=765, y=5)
- menu_principal.mainloop()
- else:
- if ed_login.get() != "matheus" or ed_senha.get() != "balieiro":
- messagebox.showinfo ("Title", "Login ou Senha incorreto")
- lbl_login = Label(login, text="Login", font ="Arial 20 bold")
- lbl_login.place(x=70, y=100)
- ed_login = Entry(login, width=25)
- ed_login.place(x=160, y=110)
- lbl_senha = Label(login, text="Senha", font ="Arial 20 bold")
- lbl_senha.place(x=70, y=140)
- ed_senha = Entry(login, width=25, show="*")
- ed_senha.place(x=160, y=150)
- ed_login.bind("<KeyPress>", lambda e: ed_senha.focus() if e.char == '\r' else None)
- ed_senha.bind("<KeyPress>", lambda e: entrar() if e.char == '\r' else None)
- bt_conectar = Button(login, width=15, text="Conectar-se", font = "Arial 15 bold", command = entrar)
- bt_conectar.place(x=100, y=200)
- login.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment