TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

Programa Para Cadastro de Clientes em Python

Por:   •  30/7/2021  •  Trabalho acadêmico  •  2.012 Palavras (9 Páginas)  •  1.746 Visualizações

Página 1 de 9

CÓDIGO POR COMPLETO

#Declarando a biblioteca

from tkinter import *

import tkinter.messagebox as tkMessageBox

import sqlite3

import tkinter.ttk as ttk

#Criando o formulario principal

root = Tk()

#Criando o titulo do sistema

root.title("CADASTRO DE PRODUTO")

#Configurando o tamhanho do formulário principal

width=800

height = 500

screen_width = root.winfo_screenmmwidth()

screen_height = root.winfo_screenmmheight()

x=(screen_width/1) - (width/6)

y=(screen_height/1) - (height/6)

root.geometry("%dx%d+%d+%d" % (width, height, x, y))

root.resizable(0, 0)

root.configure(bg="lightSteelBlue3")

#Criando as variaveis do sistema de cadastro de produtos

USERNAME = StringVar()

PASSWORD = StringVar()

PRODUTO_NOME = StringVar()

PRODUTO_PRECO = IntVar()

PRODUTO_QTD = IntVar()

PESQUISA = StringVar()

#criando conexao com o BD Sqlite3

def Database():

global conn, cursor

conn = sqlite3.connect("pythontut.db")

cursor = conn.cursor()

cursor.execute("create table if not exists admin (admin_id integer primary key, username varchar, password varchar)")

cursor.execute("create table if not exists produto (produto_id integer primary key, produto_nome varchar, produto_qtd varchar, produto_preco varchar)")

cursor.execute("select * from admin where username = 'admin' and password='admin'")

if cursor.fetchone() is None:

cursor.execute("insert into admin (username, password) values('admin','admin')")

conn.commit()

#Criando metodo dos botões sair

def EXIT():

result=tkMessageBox.askquestion('CADASTRO DE PRODUTOS', 'TEM CERTEZA? ', icon="warning")

if result == "yes":

root.destroy()

exit()

def EXIT2():

result=tkMessageBox.askquestion('CADASTRO DE PRODUTOS', 'TEM CERTEZA? ', icon="warning")

if result == "yes":

root.destroy()

exit()

#Criando o formulário login

def ShowLoginForm():

global loginform

loginform = Toplevel()

loginform.title("SISTEMA DE LOGIN")

width = 700

height = 370

screen_width = root.winfo_screenmmwidth()

screen_height = root.winfo_screenmmheight()

x = (screen_width /1) - (width / 400)

y = (screen_height / 1) - (height / 400)

loginform.geometry("%dx%d+%d+%d" % (width, height, x, y))

LoginForm()

#Criando campos do formulário login

def LoginForm():

global lbl_result

TopLoginForm = Frame(loginform, width=50, height=50, bd=1, relief=SOLID)

TopLoginForm.pack(side=TOP, pady=2)

lbl_text = Label(TopLoginForm, text="SEJA BEM VINDO AO SISTEMA DE CADASTRO DE PRODUTO", fg="blue", font=('Arial', 10, 'bold'), width=100)

lbl_text.pack(fill=X)

MidLoginForm=Frame(loginform, width=600)

MidLoginForm.pack(side=TOP, pady=50)

ldl_username = Label(MidLoginForm, text="USUARIO", font=('Arial', 15, 'bold'), fg='blue', bd=18)

ldl_username.grid(row=0)

ldl_password = Label(MidLoginForm, text="SENHA", font=('Arial', 15, 'bold'), fg='blue', bd=18)

ldl_password.grid(row=1)

ldl_result = Label(MidLoginForm, text="", font=('Arial', 18))

ldl_result.grid(row=3, columnspan=2)

userNAME= Entry(MidLoginForm, textvariable=USERNAME, font=('Arial', 15),width=30)

userNAME.grid(row=0, column=1)

passWORD= Entry(MidLoginForm, textvariable=PASSWORD, font=('Arial', 15), width=30, show="*")

passWORD.grid(row=1, column=1)

btn_login = Button(MidLoginForm, text="LOGIN", font=('Arial', 18), width=30, command=Login)

btn_login.grid(row=2, columnspan=2, pady=20)

btn_login.bind('<Return>', Login)

#Criando

...

Baixar como (para membros premium)  txt (12.5 Kb)   pdf (57.9 Kb)   docx (16.1 Kb)  
Continuar por mais 8 páginas »
Disponível apenas no TrabalhosGratuitos.com