Sem resumo de edição
Sem resumo de edição
Linha 334: Linha 334:




% 17/06/2017 00:49  
% 16/06/2017 00:49  
def delete_rest():
def delete_rest():
nome = input()
nome = input()

Edição das 21h14min de 18 de junho de 2017

<syntaxhighlight lang="py">

17/06/2017 - 22:42

from tkinter import *

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()

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()

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()


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


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()

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 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()

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()

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()


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


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()

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()

  1. 16/06/2017 17:14

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

def att_inf_rest() rest = input() inf = input() nova = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') h = -1 while linha < len(texto) lista = linha.append() if lista[0] == rest if inf == cnpj h = 1 elif inf == endereco h = 2 els linha += 5

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++ if g == h k = len(linha) linha[k-1] = ' ' linha += novo linha += ' ' linha += preco arquivo.writelines(linha) arquivo.close()

def del_card() rest = input() tipo = input() comida = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() 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 v = 0; if g != -1 g++ if g == h for i in linha if i == comida i = v = 1 if v == 1 i = break arquivo.writelines(linha) arquivo.close()


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


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()

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

</syntaxhighlight>