Sem resumo de edição
Sem resumo de edição
Linha 1: Linha 1:
<syntaxhighlight lang="py">
<syntaxhighlight lang="py">
26/06/2017 - 22:10 - Fase 1 concluída
from tkinter import *
from functools import partial
from tkinter import ttk
#JANELA
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
janela = Tk()
janela.geometry("400x400+200+200")
janela.title("Think About Eat!")
janela["bg"] = "#eeddff"
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#FRAME DE FAZER O LOGIN
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def tenho_rest():
home.destroy()
login = Frame()
login["bg"] = "#eeddff"
usuario = Label(login, text = "Usuário: ", bg = "#eeddff")
usuario.pack(fill = BOTH)
us = Entry(login)
us.pack()
senha = Label(login, text = "Senha: ", bg = "#eeddff")
senha.pack()
se = Entry(login, show = '*')
se.pack()
#-------------Valida a senha
def valido():
user = us.get()
password = se.get()
arquivo = open('senhas.txt', 'r')
texto = arquivo.readlines()
arquivo.close()
k = 0
for linha in texto:
lista = linha.split()
if lista[0] == user:
k = 1;
if lista[1] == password:
login.destroy()
us.destroy()
se.destroy()
meu_rest(lista[2])
else:
errou = Label(login, text = "Ahh, não! Algo está errado!", bg = "#d1fce1")
errou.pack()
if k == 0:
errou = Label(login, text = "Ahh, não! Algo está errado!", bg = "#d1fce1")
errou.pack()
#---------------Botão confirmar
finish = Button(login, text = "Pronto!", font = "Calibri 10 bold", bg = "#4f8c56", fg = "white", relief = "flat",  command = valido)
finish.pack()
login.pack()
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#FRAME DO DONO DO RESTAURANTE
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def meu_rest(nome_rest):
rest = Frame()
rest["bg"] = "#eeddff"
nome = Label(rest, text = nome_rest, font = ("Helvetica Neue 95 Black", 16), bg = "#eeddff")
nome.pack()
tabela = ttk.Treeview(rest, selectmode = 'browse', show = 'headings' , height = 7)
arquivo = open('dado.txt', 'r')
texto = arquivo.readlines()
arquivo.close()
g = -1
for linha in texto:
lista = linha.split()
if len(lista) and lista[0] == nome_rest:
g+=1
if g != -1:
g+=1
if g == 2:
i = 0
lista = linha.split()
while i < len(lista):
tabela.insert("", 'end', text = "L1", values = (lista[i], lista[i+1]))
i+=2
elif g == 3:
i = 0
lista = linha.split()
while i < len(lista):
tabela.insert("", 'end', text = "L1", values = (lista[i], lista[i+1]))
i+=2
elif g == 4:
i = 0
lista = linha.split()
while i < len(lista):
tabela.insert("", 'end', text = "L1", values = (lista[i], lista[i+1]))
i+=2
elif g == 5:
i = 0
lista = linha.split()
while i < len(lista):
tabela.insert("", 'end', text = "L1", values = (lista[i], lista[i+1]))
i+=2
g = -1
break
#------------------------ Tabela de produtos
tabela.pack()
tabela["columns"] = ("1", "2")
tabela['show'] = 'headings'
tabela.column("1", width=150, anchor='c')
tabela.column("2", width=150, anchor='c')
tabela.heading("1", text="Nome")
tabela.heading("2", text="Preço")
#-------------------------------------
#------------------------Função para deletar o restaurante
def delete_rest():
j1 = Tk()
j1.geometry("250x250+300+150")
j1.title("Validação")
tit = Label(j1, text="Digite sua senha:")
tit.pack()
sen = Entry(j1, show = '*')
sen.pack()
#Valido a senha
def valido():
senha = sen.get()
arquivo = open('senhas.txt', 'r')
texto = arquivo.readlines()
arquivo.close()
for linha in texto:
lista = linha.split()
if len(lista) and lista[2] == nome_rest:
if lista[1] == senha:
deleta()
else:
errou = Label(j1, text = "Ahh, não! Algo está errado!")
errou.pack()
def deleta():
#Deleto do arquivo de restaurantes
arquivo = open('dado.txt', 'r')
texto = arquivo.readlines()
arquivo.close()
arquivo = open('dado.txt', 'w')
k = -2;
for linha in texto:
lista = linha.split()
if len(lista) and lista[0] == nome_rest:
k = -1
if k != -2:
k+=1
if k == -1:
arquivo.writelines(linha)
if k == 4:
k = -1
arquivo.close()
#Deleto do arquivo de logins
arquivo = open('senhas.txt', 'r')
texto = arquivo.readlines()
arquivo.close()
arquivo = open('senhas.txt', 'w')
k = -2;
for linha in texto:
lista = linha.split()
if lista[2] != nome_rest:
arquivo.writelines(linha)
arquivo.close()
j1.destroy()
janela.destroy()
#-----------------Botão confirmar
ok = Button(j1, compound = "left", bg = "#54d863", text = "Ok", font = "Calibri 11", relief = "flat", command = valido)
ok.pack()
#-------------------------------------------------------
#------------------------Função para adicionar algo no cardápio
def add_card():
add = Tk()
add.geometry("250x250+300+150")
add.title("Adicionar produto")
nome = nome_rest
tip = Label(add, text="Tipo do produto:")
tip.pack()
ex = Label(add, text="(entrada, principal, sobremesa ou bebida)", font = ("Calibri 11", 6))
ex.pack()
t = Entry(add)
t.pack()
nom = Label(add, text="Nome:")
nom.pack()
n = Entry(add)
n.pack()
prec = Label(add, text="Preço:")
prec.pack()
ex1 = Label(add, text="Ex: R$2,00", font = ("Calibri 11", 6))
ex1.pack()
p = Entry(add)
p.pack()
# Adiciona
def valide():
tipo = t.get()
novo = n.get()
preco = p.get()
arquivo = open('dado.txt', 'r')
texto = arquivo.readlines()
arquivo.close()
#--------------------- Verifico se já existe
h = 0
g = -1
y = -1
b = 0
x = 0
for linha in texto:
lista = linha.split()
if len(lista) and lista[0] == nome:
y += 1
if tipo == 'entrada':
b = 1
elif tipo == 'principal':
b = 2
elif tipo == 'sobremesa':
b = 3
elif tipo == 'bebida':
b = 4
else:
break
elif y != -1:
y += 1
if b == y:
for i in lista:
if i == novo:
x = 1
nao = Label(add, text = "Produto já existente.", font = ("Calibri 11", 8))
nao.pack()
break
#----------------------- Se nao existir, crio
if x == 0:
arquivo = open('dado.txt', 'w')
for linha in texto:
lista = linha.split()
if len(lista) and lista[0] == nome:
g = 0
if tipo == 'entrada':
h = 1
elif tipo == 'principal':
h = 2
elif tipo == 'sobremesa':
h = 3
elif tipo == 'bebida':
h = 4
else:
nao = Label(add, text = "Tipo de produto inválido.", font = ("Calibri 11", 8))
nao.pack()
if g != -1 and h != 0:
g+=1
if g == h:
k = len(linha)
linha += novo
linha += ' '
linha += preco
linha += ' '
arquivo.writelines(linha)
arquivo.close()
if h != 0:
add.destroy()
rest.destroy()
meu_rest(nome_rest)
#-------------------Botão confirmar
finish = Button(add, text = "Pronto!", compound = "left", bg = "#54d863", font = "Calibri 11", relief = "flat", command = valide)
finish.place(x = 100, y = 300)
finish.pack()
add.mainloop()
#--------------------------------------------------
#----------------- Função para deletar algo do cardápio
def del_card():
delete = Tk()
delete.geometry("250x250+300+150")
delete.title("Deletar produto")
tip = Label(delete, text="Tipo do produto:")
tip.pack()
ex = Label(delete, text="(entrada, principal, sobremesa ou bebida)", font = ("Calibri 11", 6))
ex.pack()
t = Entry(delete)
t.pack()
nom = Label(delete, text="Nome:")
nom.pack()
n = Entry(delete)
n.pack()
t.pack()
n.pack()
# Deleta
def valide():
tipo = t.get()
comida = n.get()
arquivo = open('dado.txt', 'r')
texto = arquivo.readlines()
arquivo.close()
arquivo = open('dado.txt', 'w')
h = 0
g = -2
c = 0
for linha in texto:
lista = linha.split()
if len(lista) and lista[0] == nome_rest:
g = -1
if tipo == 'entrada':
h = 1
elif tipo == 'principal':
h = 2
elif tipo == 'sobremesa':
h = 3
elif tipo == 'bebida':
h = 4
else:
nao = Label(delete, text = "Tipo de produto inválido.", font = ("Calibri 11", 8))
nao.pack()
u = 0
lista2 = []
if g != -2 and h != 0:
g+=1
if g == h:
s = ''
u = 1
v = 0
lista1 = linha.split()
for i in lista1:
if i == comida:
v = 1
c = 1
elif v == 1:
v = 0
else:
lista2.append(i+' ')
lista2.append('\n')
if u == 1:
arquivo.writelines(lista2)
else:
arquivo.writelines(linha)
if c == 0 and h != 0:
nao = Label(delete, text = "Esse produto não foi encontrado.", font = ("Calibri 11", 8))
nao.pack()
nao1 = Label(delete, text = "Tente Novamente!", font = ("Calibri 11", 8))
nao1.pack()
elif h != 0:
arquivo.close()
delete.destroy()
rest.destroy()
meu_rest(nome_rest)
#-------------Botão confirmar
finish = Button(delete, text = "Pronto!", compound = "left", bg = "#54d863", font = "Calibri 11", relief = "flat", command = valide)
finish.place(x = 100, y = 300)
finish.pack()
delete.mainloop()
#---------------------------------------------------------
#----------------------------------------------------------Função para atualizar produto
def att_card():
atualizar = Tk()
atualizar.geometry("250x250+300+150")
atualizar.title("Deletar produto")
tip = Label(atualizar, text="Tipo do produto:")
tip.pack()
ex = Label(atualizar, text="(entrada, principal, sobremesa ou bebida)", font = ("Calibri 11", 6))
ex.pack()
t = Entry(atualizar)
t.pack()
nom = Label(atualizar, text="Nome:")
nom.pack()
n = Entry(atualizar)
n.pack()
newnom = Label(atualizar, text="Novo nome:")
newnom.pack()
new = Entry(atualizar)
new.pack()
newp = Label(atualizar, text="Novo preço:")
newp.pack()
ex1 = Label(atualizar, text="Ex: R$2,00", font = ("Calibri 11", 6))
ex1.pack()
np = Entry(atualizar)
np.pack()
# Atualiza
def valide():
tipo = t.get()
comida = n.get()
novonome = new.get()
novopreco = np.get()
arquivo = open('dado.txt', 'r')
texto = arquivo.readlines()
arquivo.close()
arquivo = open('dado.txt', 'w')
h = 0
g = -2
c = 0
for linha in texto:
lista = linha.split()
if len(lista) and lista[0] == nome_rest:
g = -1
if tipo == 'entrada':
h = 1
elif tipo == 'principal':
h = 2
elif tipo == 'sobremesa':
h = 3
elif tipo == 'bebida':
h = 4
else:
nao = Label(atualizar, text = "Tipo de produto inválido.", font = ("Calibri 11", 8))
nao.pack()
u = 0
lista2 = []
if g != -2 and h != 0:
g+=1
if g == h:
s = ''
u = 1
v = 0
lista1 = linha.split()
for i in lista1:
if i == comida:
v = 1
c = 1
lista2.append(novonome+' ')
elif v == 1:
v = 0
lista2.append(novopreco+' ')
else:
lista2.append(i+' ')
lista2.append('\n')
if u == 1:
arquivo.writelines(lista2)
else:
arquivo.writelines(linha)
if c == 0 and h != 0:
nao = Label(atualizar, text = "Esse produto não foi encontrado.", font = ("Calibri 11", 8))
nao.pack()
nao1 = Label(atualizar, text = "Tente Novamente!", font = ("Calibri 11", 8))
nao1.pack()
elif h != 0:
arquivo.close()
atualizar.destroy()
rest.destroy()
meu_rest(nome_rest)
#-------------Botão confirmar
finish = Button(atualizar, text = "Pronto!", compound = "left", bg = "#54d863", font = "Calibri 11", relief = "flat", command = valide)
finish.place(x = 100, y = 300)
finish.pack()
atualizar.mainloop()
#---------------------------------------------------------------------------------
#------------------- Botoes de adicionar e deletar
b_add = Button(rest, compound = "left", bg = "#54d863", text = "Adicionar produto", font = "Calibri 11", relief = "flat", command = add_card)
b_add.pack()
b_del = Button(rest, compound = "left", bg = "#ff1616", text = "Deletar produto", font = "Calibri 11", relief = "flat", command=del_card)
b_del.pack()
b_att = Button(rest, compound = "left", bg = "#fcf811", text = "Atualizar produto", font = "Calibri 11", relief = "flat", command=att_card)
b_att.pack()
b_del_rest = Button(rest, compound = "left", bg = "#000000", fg = "white", text = "Deletar restaurante", font = "Calibri 11", relief = "flat", command=delete_rest)
b_del_rest.pack()
rest.pack()
#-------------------------------------------------------------------
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#FRAME PRINCIPAL
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
home = Frame(janela)
tenho = Button(home, compound = "left", bg = "white", text = "Já tenho um restaurante", font = "Calibri 11", relief = "flat", command = tenho_rest)
tenho.pack()
home.pack()
janela.mainloop()
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#*******************************************************************************************************************************************************************************************************************


26/06/2017 - 13:55
26/06/2017 - 13:55

Edição das 01h10min de 27 de junho de 2017

<syntaxhighlight lang="py">

26/06/2017 - 22:10 - Fase 1 concluída

from tkinter import * from functools import partial from tkinter import ttk

#JANELA

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

janela = Tk() janela.geometry("400x400+200+200") janela.title("Think About Eat!") janela["bg"] = "#eeddff"

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$



#FRAME DE FAZER O LOGIN

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

def tenho_rest(): home.destroy() login = Frame() login["bg"] = "#eeddff"

usuario = Label(login, text = "Usuário: ", bg = "#eeddff") usuario.pack(fill = BOTH) us = Entry(login) us.pack()

senha = Label(login, text = "Senha: ", bg = "#eeddff") senha.pack() se = Entry(login, show = '*') se.pack()

#-------------Valida a senha def valido(): user = us.get() password = se.get()

arquivo = open('senhas.txt', 'r') texto = arquivo.readlines() arquivo.close()

k = 0 for linha in texto: lista = linha.split() if lista[0] == user: k = 1; if lista[1] == password: login.destroy() us.destroy() se.destroy() meu_rest(lista[2]) else: errou = Label(login, text = "Ahh, não! Algo está errado!", bg = "#d1fce1") errou.pack() if k == 0: errou = Label(login, text = "Ahh, não! Algo está errado!", bg = "#d1fce1") errou.pack()

#---------------Botão confirmar finish = Button(login, text = "Pronto!", font = "Calibri 10 bold", bg = "#4f8c56", fg = "white", relief = "flat", command = valido) finish.pack() login.pack()

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


#FRAME DO DONO DO RESTAURANTE

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

def meu_rest(nome_rest): rest = Frame() rest["bg"] = "#eeddff"

nome = Label(rest, text = nome_rest, font = ("Helvetica Neue 95 Black", 16), bg = "#eeddff") nome.pack()

tabela = ttk.Treeview(rest, selectmode = 'browse', show = 'headings' , height = 7)

arquivo = open('dado.txt', 'r') texto = arquivo.readlines() arquivo.close()

g = -1 for linha in texto: lista = linha.split() if len(lista) and lista[0] == nome_rest: g+=1 if g != -1: g+=1 if g == 2: i = 0 lista = linha.split() while i < len(lista): tabela.insert("", 'end', text = "L1", values = (lista[i], lista[i+1])) i+=2 elif g == 3: i = 0 lista = linha.split() while i < len(lista): tabela.insert("", 'end', text = "L1", values = (lista[i], lista[i+1])) i+=2 elif g == 4: i = 0 lista = linha.split() while i < len(lista): tabela.insert("", 'end', text = "L1", values = (lista[i], lista[i+1])) i+=2 elif g == 5: i = 0 lista = linha.split() while i < len(lista): tabela.insert("", 'end', text = "L1", values = (lista[i], lista[i+1])) i+=2 g = -1 break



#------------------------ Tabela de produtos

tabela.pack() tabela["columns"] = ("1", "2") tabela['show'] = 'headings'

tabela.column("1", width=150, anchor='c') tabela.column("2", width=150, anchor='c')

tabela.heading("1", text="Nome") tabela.heading("2", text="Preço")


#-------------------------------------



#------------------------Função para deletar o restaurante def delete_rest():

j1 = Tk() j1.geometry("250x250+300+150") j1.title("Validação") tit = Label(j1, text="Digite sua senha:") tit.pack() sen = Entry(j1, show = '*') sen.pack()

#Valido a senha def valido(): senha = sen.get() arquivo = open('senhas.txt', 'r') texto = arquivo.readlines() arquivo.close()

for linha in texto: lista = linha.split() if len(lista) and lista[2] == nome_rest: if lista[1] == senha: deleta() else: errou = Label(j1, text = "Ahh, não! Algo está errado!") errou.pack()

def deleta(): #Deleto do arquivo de restaurantes arquivo = open('dado.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dado.txt', 'w') k = -2; for linha in texto: lista = linha.split() if len(lista) and lista[0] == nome_rest: k = -1 if k != -2: k+=1 if k == -1: arquivo.writelines(linha) if k == 4: k = -1 arquivo.close()

#Deleto do arquivo de logins arquivo = open('senhas.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('senhas.txt', 'w') k = -2; for linha in texto: lista = linha.split() if lista[2] != nome_rest: arquivo.writelines(linha) arquivo.close() j1.destroy() janela.destroy()

#-----------------Botão confirmar ok = Button(j1, compound = "left", bg = "#54d863", text = "Ok", font = "Calibri 11", relief = "flat", command = valido) ok.pack()

#-------------------------------------------------------




#------------------------Função para adicionar algo no cardápio def add_card(): add = Tk() add.geometry("250x250+300+150") add.title("Adicionar produto")

nome = nome_rest tip = Label(add, text="Tipo do produto:") tip.pack() ex = Label(add, text="(entrada, principal, sobremesa ou bebida)", font = ("Calibri 11", 6)) ex.pack() t = Entry(add) t.pack() nom = Label(add, text="Nome:") nom.pack() n = Entry(add) n.pack() prec = Label(add, text="Preço:") prec.pack() ex1 = Label(add, text="Ex: R$2,00", font = ("Calibri 11", 6)) ex1.pack() p = Entry(add) p.pack()

# Adiciona def valide(): tipo = t.get() novo = n.get() preco = p.get()

arquivo = open('dado.txt', 'r') texto = arquivo.readlines() arquivo.close()

#--------------------- Verifico se já existe h = 0 g = -1 y = -1 b = 0 x = 0 for linha in texto: lista = linha.split() if len(lista) and lista[0] == nome: y += 1 if tipo == 'entrada': b = 1 elif tipo == 'principal': b = 2 elif tipo == 'sobremesa': b = 3 elif tipo == 'bebida': b = 4 else: break elif y != -1: y += 1 if b == y: for i in lista: if i == novo: x = 1 nao = Label(add, text = "Produto já existente.", font = ("Calibri 11", 8)) nao.pack() break

#----------------------- Se nao existir, crio if x == 0: arquivo = open('dado.txt', 'w') for linha in texto: lista = linha.split() if len(lista) and lista[0] == nome: g = 0 if tipo == 'entrada': h = 1 elif tipo == 'principal': h = 2 elif tipo == 'sobremesa': h = 3 elif tipo == 'bebida': h = 4 else: nao = Label(add, text = "Tipo de produto inválido.", font = ("Calibri 11", 8)) nao.pack() if g != -1 and h != 0: g+=1 if g == h: k = len(linha) linha += novo linha += ' ' linha += preco linha += ' ' arquivo.writelines(linha) arquivo.close() if h != 0: add.destroy() rest.destroy() meu_rest(nome_rest)

#-------------------Botão confirmar finish = Button(add, text = "Pronto!", compound = "left", bg = "#54d863", font = "Calibri 11", relief = "flat", command = valide) finish.place(x = 100, y = 300) finish.pack() add.mainloop()

#--------------------------------------------------




#----------------- Função para deletar algo do cardápio def del_card(): delete = Tk() delete.geometry("250x250+300+150") delete.title("Deletar produto")

tip = Label(delete, text="Tipo do produto:") tip.pack() ex = Label(delete, text="(entrada, principal, sobremesa ou bebida)", font = ("Calibri 11", 6)) ex.pack() t = Entry(delete) t.pack() nom = Label(delete, text="Nome:") nom.pack() n = Entry(delete) n.pack() t.pack() n.pack()

# Deleta def valide(): tipo = t.get() comida = n.get()

arquivo = open('dado.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dado.txt', 'w')

h = 0 g = -2 c = 0 for linha in texto: lista = linha.split() if len(lista) and lista[0] == nome_rest: g = -1 if tipo == 'entrada': h = 1 elif tipo == 'principal': h = 2 elif tipo == 'sobremesa': h = 3 elif tipo == 'bebida': h = 4 else: nao = Label(delete, text = "Tipo de produto inválido.", font = ("Calibri 11", 8)) nao.pack() u = 0 lista2 = [] if g != -2 and h != 0: g+=1 if g == h: s = u = 1 v = 0 lista1 = linha.split() for i in lista1: if i == comida: v = 1 c = 1 elif v == 1: v = 0 else: lista2.append(i+' ') lista2.append('\n') if u == 1: arquivo.writelines(lista2) else: arquivo.writelines(linha)

if c == 0 and h != 0: nao = Label(delete, text = "Esse produto não foi encontrado.", font = ("Calibri 11", 8)) nao.pack() nao1 = Label(delete, text = "Tente Novamente!", font = ("Calibri 11", 8)) nao1.pack() elif h != 0: arquivo.close() delete.destroy() rest.destroy() meu_rest(nome_rest)

#-------------Botão confirmar finish = Button(delete, text = "Pronto!", compound = "left", bg = "#54d863", font = "Calibri 11", relief = "flat", command = valide) finish.place(x = 100, y = 300) finish.pack() delete.mainloop()

#---------------------------------------------------------




#----------------------------------------------------------Função para atualizar produto

def att_card(): atualizar = Tk() atualizar.geometry("250x250+300+150") atualizar.title("Deletar produto")

tip = Label(atualizar, text="Tipo do produto:") tip.pack() ex = Label(atualizar, text="(entrada, principal, sobremesa ou bebida)", font = ("Calibri 11", 6)) ex.pack() t = Entry(atualizar) t.pack() nom = Label(atualizar, text="Nome:") nom.pack() n = Entry(atualizar) n.pack() newnom = Label(atualizar, text="Novo nome:") newnom.pack() new = Entry(atualizar) new.pack() newp = Label(atualizar, text="Novo preço:") newp.pack() ex1 = Label(atualizar, text="Ex: R$2,00", font = ("Calibri 11", 6)) ex1.pack() np = Entry(atualizar) np.pack()

# Atualiza def valide(): tipo = t.get() comida = n.get() novonome = new.get() novopreco = np.get()

arquivo = open('dado.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dado.txt', 'w')

h = 0 g = -2 c = 0 for linha in texto: lista = linha.split() if len(lista) and lista[0] == nome_rest: g = -1 if tipo == 'entrada': h = 1 elif tipo == 'principal': h = 2 elif tipo == 'sobremesa': h = 3 elif tipo == 'bebida': h = 4 else: nao = Label(atualizar, text = "Tipo de produto inválido.", font = ("Calibri 11", 8)) nao.pack() u = 0 lista2 = [] if g != -2 and h != 0: g+=1 if g == h: s = u = 1 v = 0 lista1 = linha.split() for i in lista1: if i == comida: v = 1 c = 1 lista2.append(novonome+' ') elif v == 1: v = 0 lista2.append(novopreco+' ') else: lista2.append(i+' ') lista2.append('\n') if u == 1: arquivo.writelines(lista2) else: arquivo.writelines(linha)

if c == 0 and h != 0: nao = Label(atualizar, text = "Esse produto não foi encontrado.", font = ("Calibri 11", 8)) nao.pack() nao1 = Label(atualizar, text = "Tente Novamente!", font = ("Calibri 11", 8)) nao1.pack() elif h != 0: arquivo.close() atualizar.destroy() rest.destroy() meu_rest(nome_rest)

#-------------Botão confirmar finish = Button(atualizar, text = "Pronto!", compound = "left", bg = "#54d863", font = "Calibri 11", relief = "flat", command = valide) finish.place(x = 100, y = 300) finish.pack() atualizar.mainloop()


#---------------------------------------------------------------------------------





#------------------- Botoes de adicionar e deletar b_add = Button(rest, compound = "left", bg = "#54d863", text = "Adicionar produto", font = "Calibri 11", relief = "flat", command = add_card) b_add.pack() b_del = Button(rest, compound = "left", bg = "#ff1616", text = "Deletar produto", font = "Calibri 11", relief = "flat", command=del_card) b_del.pack() b_att = Button(rest, compound = "left", bg = "#fcf811", text = "Atualizar produto", font = "Calibri 11", relief = "flat", command=att_card) b_att.pack() b_del_rest = Button(rest, compound = "left", bg = "#000000", fg = "white", text = "Deletar restaurante", font = "Calibri 11", relief = "flat", command=delete_rest) b_del_rest.pack() rest.pack() #-------------------------------------------------------------------

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$



#FRAME PRINCIPAL

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

home = Frame(janela) tenho = Button(home, compound = "left", bg = "white", text = "Já tenho um restaurante", font = "Calibri 11", relief = "flat", command = tenho_rest) tenho.pack() home.pack() janela.mainloop()

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


26/06/2017 - 13:55

from tkinter import * from functools import partial from tkinter import ttk

#JANELA

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

janela = Tk() janela.geometry("300x300+200+200") janela.title("Think About Eat!") janela["bg"] = "#eeddff"

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$



#FRAME DE FAZER O LOGIN

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

def tenho_rest(): home.destroy() login = Frame() login["bg"] = "#eeddff"

usuario = Label(login, text = "Usuário: ", bg = "#eeddff") usuario.pack(fill = BOTH) us = Entry(login) us.pack()

senha = Label(login, text = "Senha: ", bg = "#eeddff") senha.pack() se = Entry(login, show = '*') se.pack()

#-------------Valida a senha def valido(): user = us.get() password = se.get()

arquivo = open('senhas.txt', 'r') texto = arquivo.readlines() arquivo.close()

k = 0 for linha in texto: lista = linha.split() if lista[0] == user: k = 1; if lista[1] == password: login.destroy() us.destroy() se.destroy() meu_rest(lista[2]) else: errou = Label(login, text = "Ahh, não! Algo está errado!", bg = "#d1fce1") errou.pack() if k == 0: errou = Label(login, text = "Ahh, não! Algo está errado!", bg = "#d1fce1") errou.pack()

finish = Button(login, text = "Pronto!", font = "Calibri 10 bold", bg = "#4f8c56", fg = "white", relief = "flat", command = valido) finish.pack() login.pack()

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


#FRAME DO DONO DO RESTAURANTE

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

def meu_rest(nome_rest): rest = Frame() rest["bg"] = "#eeddff"

nome = Label(rest, text = nome_rest, font = ("Helvetica Neue 95 Black", 16), bg = "#eeddff") nome.pack()

tabela = ttk.Treeview(rest, selectmode = 'browse', show = 'headings' , height = 7)

arquivo = open('dado.txt', 'r') texto = arquivo.readlines() arquivo.close()

g = -1 for linha in texto: lista = linha.split() if len(lista) and lista[0] == nome_rest: g+=1 if g != -1: g+=1 if g == 2: i = 0 lista = linha.split() while i < len(lista): tabela.insert("", 'end', text = "L1", values = (lista[i], lista[i+1])) i+=2 elif g == 3: i = 0 lista = linha.split() while i < len(lista): tabela.insert("", 'end', text = "L1", values = (lista[i], lista[i+1])) i+=2 elif g == 4: i = 0 lista = linha.split() while i < len(lista): tabela.insert("", 'end', text = "L1", values = (lista[i], lista[i+1])) i+=2 elif g == 5: i = 0 lista = linha.split() while i < len(lista): tabela.insert("", 'end', text = "L1", values = (lista[i], lista[i+1])) i+=2 g = -1 break



#------------------------ Tabela de produtos

tabela.pack() tabela["columns"] = ("1", "2") tabela['show'] = 'headings'

tabela.column("1", width=150, anchor='c') tabela.column("2", width=150, anchor='c')

tabela.heading("1", text="Nome") tabela.heading("2", text="Preço")


#-------------------------------------



#------------------------Função para deletar o restaurante def delete_rest():

j1 = Tk() j1.geometry("250x250+300+150") j1.title("Validação") tit = Label(j1, text="Digite sua senha:") tit.pack() sen = Entry(j1, show = '*') sen.pack()

#Valido a senha def valido(): senha = sen.get() arquivo = open('senhas.txt', 'r') texto = arquivo.readlines() arquivo.close()

for linha in texto: lista = linha.split() if len(lista) and lista[2] == nome_rest: if lista[1] == senha: deleta() else: errou = Label(j1, text = "Ahh, não! Algo está errado!") errou.pack()

def deleta(): #Deleto do arquivo de restaurantes arquivo = open('dado.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dado.txt', 'w') k = -2; for linha in texto: lista = linha.split() if len(lista) and lista[0] == nome_rest: k = -1 if k != -2: k+=1 if k == -1: arquivo.writelines(linha) if k == 4: k = -1 arquivo.close()

#Deleto do arquivo de logins arquivo = open('senhas.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('senhas.txt', 'w') k = -2; for linha in texto: lista = linha.split() if lista[2] != nome_rest: arquivo.writelines(linha) arquivo.close() j1.destroy() janela.destroy()

ok = Button(j1, compound = "left", bg = "#54d863", text = "Ok", font = "Calibri 11", relief = "flat", command = valido) ok.pack()

#-------------------------------------------------------




#------------------------Função para adicionar algo no cardápio def add_card(): add = Tk() add.geometry("250x250+300+150") add.title("Adicionar produto")

nome = nome_rest tip = Label(add, text="Tipo do produto:") tip.pack() ex = Label(add, text="(entrada, principal, sobremesa ou bebida)", font = ("Calibri 11", 6)) ex.pack() t = Entry(add) t.pack() nom = Label(add, text="Nome:") nom.pack() n = Entry(add) n.pack() prec = Label(add, text="Preço:") prec.pack() ex1 = Label(add, text="Ex: R$2,00", font = ("Calibri 11", 6)) ex1.pack() p = Entry(add) p.pack()

# Adiciona def valide(): tipo = t.get() novo = n.get() preco = p.get()

arquivo = open('dado.txt', 'r') texto = arquivo.readlines() arquivo.close()

#--------------------- Verifico se já existe h = 0 g = -1 y = -1 b = 0 x = 0 for linha in texto: lista = linha.split() if len(lista) and lista[0] == nome: y += 1 if tipo == 'entrada': b = 1 elif tipo == 'principal': b = 2 elif tipo == 'sobremesa': b = 3 elif tipo == 'bebida': b = 4 else: break elif y != -1: y += 1 if b == y: for i in lista: if i == novo: x = 1 nao = Label(add, text = "Produto já existente.", font = ("Calibri 11", 8)) nao.pack() break

#----------------------- Se nao existir, crio if x == 0: arquivo = open('dado.txt', 'w') for linha in texto: lista = linha.split() if len(lista) and lista[0] == nome: g = 0 if tipo == 'entrada': h = 1 elif tipo == 'principal': h = 2 elif tipo == 'sobremesa': h = 3 elif tipo == 'bebida': h = 4 else: nao = Label(add, text = "Tipo de produto inválido.", font = ("Calibri 11", 8)) nao.pack() if g != -1 and h != 0: g+=1 if g == h: k = len(linha) linha += novo linha += ' ' linha += preco linha += ' ' arquivo.writelines(linha) arquivo.close() if h != 0: add.destroy() rest.destroy() meu_rest(nome_rest)

finish = Button(add, text = "Pronto!", compound = "left", bg = "#54d863", font = "Calibri 11", relief = "flat", command = valide) finish.place(x = 100, y = 300) finish.pack() add.mainloop()

#--------------------------------------------------




#----------------- Função para deletar algo do cardápio def del_card(): delete = Tk() delete.geometry("250x250+300+150") delete.title("Deletar produto")

tip = Label(delete, text="Tipo do produto:") tip.pack() ex = Label(delete, text="(entrada, principal, sobremesa ou bebida)", font = ("Calibri 11", 6)) ex.pack() t = Entry(delete) t.pack() nom = Label(delete, text="Nome:") nom.pack() n = Entry(delete) n.pack() t.pack() n.pack()

# Deleta def valide(): tipo = t.get() comida = n.get()

arquivo = open('dado.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dado.txt', 'w')

h = 0 g = -2 c = 0 for linha in texto: lista = linha.split() if len(lista) and lista[0] == nome_rest: g = -1 if tipo == 'entrada': h = 1 elif tipo == 'principal': h = 2 elif tipo == 'sobremesa': h = 3 elif tipo == 'bebida': h = 4 else: nao = Label(delete, text = "Tipo de produto inválido.", font = ("Calibri 11", 8)) nao.pack() u = 0 lista2 = [] if g != -2 and h != 0: g+=1 if g == h: s = u = 1 v = 0 lista1 = linha.split() for i in lista1: if i == comida: v = 1 c = 1 elif v == 1: v = 0 else: lista2.append(i+' ') lista2.append('\n') if u == 1: arquivo.writelines(lista2) else: arquivo.writelines(linha)

if c == 0 and h != 0: nao = Label(delete, text = "Esse produto não foi encontrado.", font = ("Calibri 11", 8)) nao.pack() nao1 = Label(delete, text = "Tente Novamente!", font = ("Calibri 11", 8)) nao1.pack() elif h != 0: arquivo.close() delete.destroy() rest.destroy() meu_rest(nome_rest)

finish = Button(delete, text = "Pronto!", compound = "left", bg = "#54d863", font = "Calibri 11", relief = "flat", command = valide) finish.place(x = 100, y = 300) finish.pack() delete.mainloop()

#---------------------------------------------------------



#------------------- Botoes de adicionar e deletar b_add = Button(rest, compound = "left", bg = "#54d863", text = "Adicionar produto", font = "Calibri 11", relief = "flat", command = add_card) b_add.pack() b_del = Button(rest, compound = "left", bg = "#ff1616", text = "Deletar produto", font = "Calibri 11", relief = "flat", command=del_card) b_del.pack() b_del_rest = Button(rest, compound = "left", bg = "#000000", fg = "white", text = "Deletar restaurante", font = "Calibri 11", relief = "flat", command=delete_rest) b_del_rest.pack() rest.pack() #-------------------------------------------------------------------

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$



#FRAME PRINCIPAL

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

home = Frame(janela) tenho = Button(home, compound = "left", bg = "white", text = "Já tenho um restaurante", font = "Calibri 11", relief = "flat", command = tenho_rest) tenho.pack() home.pack() janela.mainloop()

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$



19/06/2017 - 15:16

from tkinter import * from functools import partial

  1. ---------------------- JANELA *

janela = Tk() janela.geometry("300x300+200+200") janela.title("Think About Eat!")

  1. janela["bg"] = "#d1fce"
  1. --------------------------- fazer login *

def tenho_rest(): home.destroy() login = Frame() usuario = Label(login, text = "Usuário: ") us = Entry() us.pack() senha = Label(login, text = "Senha: ") se = Entry(show = '*') se.pack() def valido(): user = us.get() password = se.get() arquivo = open('senhas.txt', 'r') texto = arquivo.readlines() arquivo.close() for linha in texto: lista = linha.split() if lista[0] == user: if lista[1] == password: login.destroy() us.destroy() se.destroy() meu_rest(lista[2]) else: errou = Label(login, text = "Ahh, não! Algo está errado!", bg = "#d1fce1") errou.pack() else: errou = Label(login, text = "Ahh, não! Algo está errado!", bg = "#d1fce1") errou.pack() finish = Button(login, text = "Pronto!", bg = "white", relief = "flat", command = valido) finish.pack() login.pack()

  1. ---------------------- Tenho Restaurante *

def meu_rest(nome_rest): rest = Frame() rest["bg"] = "#d1fce1" nome = Label(rest, text = nome_rest, bg = "#d1fce1") nome.pack() listbox = Listbox(rest, selectmode=EXTENDED) listbox.pack() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() g = -1 for linha in texto: lista = linha.split() if lista[0] == nome_rest: g+=1 if g != -1: g+=1 if g == 2: listbox.insert(END, "ENTRADAS") listbox.insert(END, ) i = 0 lista = linha.split() while i < len(lista): listbox.insert(END, lista[i]+" "+lista[i+1])#*lista[i:i+2]) i+=2 elif g == 3: listbox.insert(END, ) listbox.insert(END, "PRATOS PRINCIPAIS") listbox.insert(END, ) i = 0 lista = linha.split() while i < len(lista): listbox.insert(END, lista[i]+" "+lista[i+1])#*lista[i:i+2]) i+=2 elif g == 4: listbox.insert(END, ) listbox.insert(END, "SOBREMESAS") listbox.insert(END, ) i = 0 lista = linha.split() while i < len(lista): listbox.insert(END, lista[i]+" "+lista[i+1])#*lista[i:i+2]) i+=2 elif g == 5: listbox.insert(END, ) listbox.insert(END, "BEBIDAS") listbox.insert(END, ) i = 0 lista = linha.split() while i < len(lista): listbox.insert(END, lista[i]+" "+lista[i+1])#*lista[i:i+2]) i+=2 g = -1 break # Função para adicionar algo no cardápio def add_card(): add = Tk() add.geometry("250x250+300+150") add.title("Adicionar cardápio") nome = nome_rest t = Entry(add) n = Entry(add) p = Entry(add) t.pack() n.pack() p.pack() # Adiciona def valide(): tipo = t.get() novo = n.get() preco = p.get() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') h = 0 g = -1 for linha in texto: lista = linha.split() if lista[0] == nome: g = 0 if tipo == 'entrada': h = 1 elif tipo == 'principal': h = 2 elif tipo == 'sobremesa': h = 3 else: h = 4 if g != -1: g+=1 if g == h: k = len(linha) linha += novo linha += ' ' linha += preco linha += ' ' arquivo.writelines(linha) arquivo.close() add.destroy() rest.destroy() meu_rest(nome_rest) finish = Button(add, text = "Pronto!", bg = "white", relief = "flat", command = valide) finish.place(x = 100, y = 300) finish.pack() add.mainloop()

b_add = Button(rest, compound = "left", bg = "white", text = "Adicionar cardápio", font = "Calibri 11", relief = "flat", command = add_card) b_add.pack() b_del = Button(rest, compound = "left", bg = "white", text = "Deletar cardápio", font = "Calibri 11", relief = "flat", command=del_card) b_del.pack() rest.pack()

  1. ------------------- home

home = Frame(janela)

  1. home["bg"] = "#d1fce1"

tenho = Button(home, compound = "left", bg = "white", text = "Já tenho um restaurante", font = "Calibri 11", relief = "flat", command = tenho_rest) tenho.pack() home.pack() janela.mainloop()


17/06/2017 - 22:42

from tkinter import *

  1. --------------------------------------- Deleta o restaurante

def delete_rest(): nome = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') k = -2; for linha in texto: lista = linha.split() if lista[0] == nome: k = -1 if k != -2: k+=1 if k == -1: arquivo.writelines(linha) if k == 4: k = -1 arquivo.close()

  1. --------------------------------------- Adicionar algo ao cardápio

def add_card(): nome = input() tipo = input() novo = input() preco = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') h = 0 g = -1 for linha in texto: lista = linha.split() if lista[0] == nome: g = 0 if tipo == 'entrada': h = 1 elif tipo == 'principal': h = 2 elif tipo == 'sobremesa': h = 3 else: h = 4 if g != -1: g+=1 if g == h: k = len(linha) linha += novo linha += ' ' linha += preco linha += ' ' arquivo.writelines(linha) arquivo.close()

  1. --------------------------------------- Deleta algo do cardápio

def del_card(): rest = input() tipo = input() comida = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') h = 0 g = -2 for linha in texto: lista = linha.split() if lista[0] == rest: g = -1 if tipo == 'entrada': h = 1 elif tipo == 'principal': h = 2 elif tipo == 'sobremesa': h = 3 else: h = 4 v = 0 u = 0 lista2 = [] if g != -2: g+=1 if g == h: s = u = 1 lista1 = linha.split() for i in lista1: if i == comida: v = 1 elif v == 1: v = 0 else: lista2.append(i+' ') lista2.append('\n') if u == 1: arquivo.writelines(lista2) else: arquivo.writelines(linha) arquivo.close()


  1. --------------------------------------------- Le as informações pra criar o restaurante

def read(): lista = [] nome = input() lista.append(nome+' ') cnpj = input() lista.append(cnpj+' ') endereco = input() lista.append(endereco+' ') telefone = input() lista.append(telefone+'\n') return lista

  1. ----------------------------------------------- Criar restaurante

def criar_rest(): restaurante = read() arquivo = open('dados.txt', 'a') arquivo.writelines(restaurante) entrada = input() precoe = input() principal = input() precop = input() sobremesa = input() precos = input() bebida = input() precob = input() en = [] en.append(entrada+' ') en.append(precoe+'\n') pri = [] pri.append(principal+' ') pri.append(precop+'\n') sob = [] sob.append(sobremesa+' ') sob.append(precos+'\n') be = [] be.append(bebida+' ') be.append(precob+'\n') arquivo.writelines(en) arquivo.writelines(pri) arquivo.writelines(sob) arquivo.writelines(be) arquivo.close()

  1. ---------------------- Procurar Restaurante

def procurar_rest(): nome = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() j = 0 for i in texto: lista = i.split() if lista[0] == nome: print(lista) j = 1 break if j == 0: print('Restaurante nao encontrado') arquivo.close()

  1. criar_rest()
  2. print("Procure: ")
  3. procurar_rest()
  4. print("Adicione cardapio: ")
  5. add_card()
  6. print("Delete cardapio: ")
  7. del_card()
  8. print("Delete rest: ")
  9. delete_rest()

class restaurante(): def __init__(self): nome = "-" cnpj = "-" telefone = "-" endereco = "-"

  1. ---------------------- JANELA *

janela = Tk() janela.geometry("500x500+200+200") janela.title("Think About Eat!") janela["bg"] = "#eeddff"

  1. --------------------------- fazer login *

login = Frame(janela) usuario = Label(login, text = "Usuário: ") us = Entry() senha = Label(login, text = "Senha: ") se = Entry(show = '*') user = us.get() password = se.get()


  1. -------------------------- criar login * (colocar função de criar cardápio no botão "pronto")

def criar_rest(): #temp = Frame() #temp = home home.destroy() create = Frame(janela) create["bg"] = "#eeddff" janela.title("Cadastro") dado_r = Label(create, text = "\n\nDados do restaurante ", bg = "#eeddff", font = "Calibri 8", fg = "#515151") dado_r.pack()

rest1 = Label(create, text = "Nome: ", bg = "#eeddff") rest1.pack() rest = Entry(create) rest.pack()

cnpj1 = Label(create, text = "CNPJ: ", bg = "#eeddff") cnpj1.pack() cnpj = Entry(create) cnpj.pack()

tel1 = Label(create, text = "Telefone: ", bg = "#eeddff") tel1.pack() tel = Entry(create) tel.pack()

end1 = Label(create, text = "Endereço: ", bg = "#eeddff") end1.pack() end = Entry(create) end.pack()

info1 = Label(create, text = "Informações adicionais: ", bg = "#eeddff") info1.pack() info = Entry(create) info.pack()

dado_u = Label(create, text = "\n\nDados do usuário ", bg = "#eeddff", font = "Calibri 8", fg = "#515151") dado_u.pack()

usuario1 = Label(create, text = "Nome do usuário: ", bg = "#eeddff") usuario1.pack() us1 = Entry(create) us1.pack()

senha1 = Label(create, text = "Senha: ", bg = "#eeddff") senha1.pack() se1 = Entry(create, show = '*') se1.pack()

nsenha1 = Label(create, text = "Redigite a senha: ", bg = "#eeddff") nsenha1.pack() nse1 = Entry(create, show = '*') nse1.pack()

restricao = Label(create, text = "*Mínimo de 8 caracteres; diferencia maiúsculas de minúsculas\n", font = "Calibri 8", fg = "#515151", bg = "#eeddff") restricao.pack()

def valida() : user = us1.get() password = se1.get() npassword = nse1.get() if len(password) >= 8: if password == npassword: arquivo = open("login.txt", 'a') arquivo.write(user + ' ' + password + '\n') arquivo.close() ok = Label(create, text = "Bem vindo!", bg = "#eeddff") ok.pack() else: errou = Label(create, text = "Ahh, não! Algo está errado!", bg = "#eeddff") errou.pack() finish = Button(create, text = "Pronto", font = "Calibri 10 bold", bg = "#4f8c56", fg = "white", relief = "flat", command = valida) finish.pack() create.pack() #temp.pack()

  1. --------------------------- Tela categorias *

s = PhotoImage(file = "/root/Larissa/ThinkAboutEat/sushi.gif") sushi = s.subsample(2, 2) p = PhotoImage(file = "/root/Larissa/ThinkAboutEat/pizza.gif") pz = p.subsample(2, 2) san = PhotoImage(file = "/root/Larissa/ThinkAboutEat/sanduiche.gif") sanduba = san.subsample(2, 2) c = PhotoImage(file = "/root/Larissa/ThinkAboutEat/sopa.gif") caldo = c.subsample(2, 2) f = PhotoImage(file = "/root/Larissa/ThinkAboutEat/fastfood.gif") ff = f.subsample(2, 2) h = PhotoImage(file = "/root/Larissa/ThinkAboutEat/hotdog.gif") hot = h.subsample(2, 2) def categoria(): tela_c = Frame(janela) tela_c["bg"] = "#eeddff" home.destroy() comida_japonesa = Button(tela_c, text = "COMIDA JAPONESA", image = sushi, compound = "left", font = "Calibri 15 bold", bg = "#395061", fg = "white", width = 250) comida_japonesa.pack() pizza = Button(tela_c, text = "PIZZA", image = pz, compound = "right", font = "Calibri 15 bold", bg = "#2cb69d", fg = "white", width = 250) pizza.pack() sanduiche = Button(tela_c, text = "SANDUÍCHES", image = sanduba, compound = "left", font = "Calibri 15 bold", bg = "#6cbbe6", fg = "white", width = 250) sanduiche.pack() caldos = Button(tela_c, text = "CALDOS", image = caldo, compound = "right", font = "Calibri 15 bold", bg = "#fed87a", fg = "white", width = 250) caldos.pack() fastfood = Button(tela_c, text = "FAST FOOD", image = ff, compound = "left", font = "Calibri 15 bold", bg = "#2a4350", fg = "white", width = 250) fastfood.pack() hotdog = Button(tela_c, text = "CACHORRO-QUENTE", image = hot, compound = "right", font = "Calibri 15 bold", bg = "#23a487", fg = "white", width = 250) hotdog.pack() tela_c.pack()


  1. --------------------------- Home *

home = Frame(janela) home["bg"] = "#eeddff" c = PhotoImage(file = "/root/Larissa/ThinkAboutEat/pedido.gif") cestinha = c.subsample(2, 2) ch = PhotoImage(file = "/root/Larissa/ThinkAboutEat/tenho.gif") chef = ch.subsample(2, 2) novo_rest = Button(home, text = "Adicionar restaurante", bg = "white", font = "Calibri 11", relief = "flat", command = criar_rest) pedido = Button(home, image = cestinha, compound = "left", text = "Fazer pedido", font = "Calibri 11", bg = "white", relief = "flat", command = categoria) tenho = Button(home, image = chef, compound = "left", bg = "white", text = "Já tenho um restaurante", font = "Calibri 11", relief = "flat") pedido.pack() novo_rest.pack() tenho.pack() home.pack()

janela.mainloop()





% 16/06/2017 00:49

  1. ----------------------------- Deleta o restaurante

def delete_rest(): nome = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') k = -2; for linha in texto: lista = linha.split() if lista[0] == nome: k = -1 if k != -2: k+=1 if k == -1: arquivo.writelines(linha) if k == 4: k = -1 arquivo.close()

  1. ------------------------------------ Adiciona algo ao cardápio

def add_card(): nome = input() tipo = input() novo = input() preco = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') h = 0 g = -1 for linha in texto: lista = linha.split() if lista[0] == nome: g = 0 if tipo == 'entrada': h = 1 elif tipo == 'principal': h = 2 elif tipo == 'sobremesa': h = 3 else: h = 4 if g != -1: g+=1 if g == h: k = len(linha) linha += novo linha += ' ' linha += preco linha += ' ' arquivo.writelines(linha) arquivo.close()

  1. ---------------------- Deleta algo do cardápio

def del_card(): rest = input() tipo = input() comida = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') h = 0 g = -2 for linha in texto: lista = linha.split() if lista[0] == rest: g = -1 if tipo == 'entrada': h = 1 elif tipo == 'principal': h = 2 elif tipo == 'sobremesa': h = 3 else: h = 4 v = 0 u = 0 lista2 = [] if g != -2: g+=1 if g == h: s = u = 1 lista1 = linha.split() for i in lista1: if i == comida: v = 1 elif v == 1: v = 0 else: lista2.append(i+' ') lista2.append('\n') if u == 1: arquivo.writelines(lista2) else: arquivo.writelines(linha) arquivo.close()


  1. ------------------------ Le as informações para criar o restaurante

def read(): lista = [] nome = input() lista.append(nome+' ') cnpj = input() lista.append(cnpj+' ') endereco = input() lista.append(endereco+' ') telefone = input() lista.append(telefone+'\n') return lista

  1. --------------------------- Criar Restaurante

def criar_rest(): restaurante = read() arquivo = open('dados.txt', 'a') arquivo.writelines(restaurante) entrada = input() precoe = input() principal = input() precop = input() sobremesa = input() precos = input() bebida = input() precob = input() en = [] en.append(entrada+' ') en.append(precoe+'\n') pri = [] pri.append(principal+' ') pri.append(precop+'\n') sob = [] sob.append(sobremesa+' ') sob.append(precos+'\n') be = [] be.append(bebida+' ') be.append(precob+'\n') arquivo.writelines(en) arquivo.writelines(pri) arquivo.writelines(sob) arquivo.writelines(be) arquivo.close()

  1. ------------------- Procurar Restaurante

def procurar_rest(): nome = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() j = 0 for i in texto: lista = i.split() if lista[0] == nome: print(lista) j = 1 break if j == 0: print('Restaurante nao encontrado') arquivo.close()

criar_rest() print("Procure: ") procurar_rest() print("Adicione cardapio: ") add_card() print("Delete cardapio: ") del_card() print("Delete rest: ") delete_rest()

</syntaxhighlight>