Fase 1 - Concluida
<syntaxhighlight lang="py" line="1">
- 26/06/2017 - 16:26
from tkinter import ttk from tkinter import *
#FUNÇAO PARA CRIAR UM EVENTO;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def criar():
def Adicionar():
nome = aname.get()
data = adata.get()
preço = apreço.get()
local = alocal.get()
lista = []
lista.append(nome + ';')
lista.append(data +';')
lista.append(preço + ';')
lista.append(local + ';')
arquivo=open("eventos.txt", "r")
t=arquivo.readlines()
arquivo.close
j = []
flag = True
for i in t:
j=i.split(';')
if(j[1]==data and j[3]==local):
flag=False
Label(janelacriar, text="JA EXISTE UM EVENTO NESSE LOCAL NESSA DATA", foreground = "red").place(x=10, y=100)
aux = lista[0] + lista[1] + lista[2] + lista[3]
if(flag and len(aux) > 7):
arquivo = open("eventos.txt", "a")
arquivo.writelines(lista)
arquivo.write("\n")
arquivo.close()
tabela.insert("",'end',values=(nome, data, preço, local))
janelacriar.destroy()
return
janelacriar = Toplevel()
janelacriar.geometry("300x200")
janelacriar.title("Novo evento")
nome = Label(janelacriar, text = "Nome do evento:").place(x = 5, y = 5)
aname = Entry(janelacriar)
aname.place(x = 120, y = 5)
data = Label(janelacriar, text = "Data:").place(x = 5, y = 30)
adata = Entry(janelacriar)
adata.place(x = 120, y = 30)
Exemplo = Label(janelacriar, text = "DD/MM/AAAA", font = "Times 5").place(x = 245, y = 40)
preço = Label(janelacriar, text = "R$:").place(x = 5, y = 55)
apreço = Entry(janelacriar)
apreço.place(x = 120, y = 55)
local = Label(janelacriar, text = "Local:").place(x = 5, y = 80)
alocal = Entry(janelacriar)
alocal.place(x = 120, y = 80)
btnadd = Button(janelacriar, text = "Confirmar", font = "Times ", command = Adicionar).place(x = 200, y = 160)
janelacriar.mainloop()
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#FUNÇAO PARA EDITAR
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def editar():
x = tabela.selection()[0]
y = tabela.item(x, "values")
def adicionar():
nome = aname.get()
data = adata.get()
preço = apreço.get()
local = alocal.get()
arquivo = open("eventos.txt", "a")
lista = []
lista.append(nome + ';')
lista.append(data +';')
lista.append(preço + ';')
lista.append(local + ';')
arquivo.writelines(lista)
arquivo.write("\n")
arquivo.close()
def delete():
x = tabela.selection()[0]
y = tabela.item(x, "values")
pesquisa = y[0]
arquivo = open("eventos.txt", "r")
produtos = arquivo.readlines()
arquivo.close()
arquivo = open("eventos.txt", "w")
for i in produtos:
lista = i.split(';')
if lista[0] != pesquisa:
arquivo.writelines(i)
arquivo.close()
x = tabela.selection()[0]
tabela.delete(x)
delete()
tabela.insert("",'end',values=(nome, data, preço, local))
janelacriar.destroy()
return
janelacriar = Toplevel()
janelacriar.geometry("300x200")
janelacriar.title("Novo evento")
nome = Label(janelacriar, text = "Nome do evento:").place(x = 5, y = 5)
aname = Entry(janelacriar)
aname.place(x = 120, y = 5)
aname.insert(END, y[0])
data = Label(janelacriar, text = "Data:").place(x = 5, y = 30)
adata = Entry(janelacriar)
adata.place(x = 120, y = 30)
adata.insert(END, y[1])
Exemplo = Label(janelacriar, text = "DD/MM/AAAA", font = "Times 5").place(x = 245, y = 40)
preço = Label(janelacriar, text = "R$:").place(x = 5, y = 55)
apreço = Entry(janelacriar)
apreço.place(x = 120, y = 55)
apreço.insert(END,y[2])
local = Label(janelacriar, text = "Local:").place(x = 5, y = 80)
alocal = Entry(janelacriar)
alocal.place(x = 120, y = 80)
alocal.insert(END, y[3])
delete
btnadd = Button(janelacriar, text = "Confirmar", font = "Times ", command = adicionar).place(x = 200, y = 160)
janelacriar.mainloop()
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#FUNÇAO PARA PESQUISAR UM EVENTO;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def pesquisar():
def achar():
j = []
nome = aname.get()
data = adata.get()
preço = apreço.get()
local = alocal.get()
arquivo = open("eventos.txt", "r")
t = arquivo.readlines()
arquivo.close()
tabelapesquisar.delete(*tabelapesquisar.get_children())
for i in t:
j = i.split(';')
if(j[0]==nome or nome==):
if(j[1]==data or data==):
if(j[2]==preço or preço==):
if(j[3]==local or local==):
tabelapesquisar.insert("",'end',values=(j[0], j[1], j[2], j[3]))
janelapesquisar = Tk()
janelapesquisar.geometry("600x600")
janelapesquisar.title("Pesquisar")
nome = Label(janelapesquisar, text = "Nome do evento:").place(x = 1, y = 430)
aname = Entry(janelapesquisar)
aname.place(x = 100, y = 430)
data = Label(janelapesquisar, text = "Data:").place(x = 1, y = 455)
adata = Entry(janelapesquisar)
adata.place(x = 100, y = 455)
Exemplo = Label(janelapesquisar, text = "DD/MM/AAAA", font = "Times 5").place(x = 245, y = 40)
local = Label(janelapesquisar, text = "Local:").place(x = 1, y = 480)
alocal = Entry(janelapesquisar)
alocal.place(x = 100, y = 480)
preço = Label(janelapesquisar, text = "R$:").place(x = 1, y = 505)
apreço = Entry(janelapesquisar)
apreço.place(x = 100, y = 505)
tabelapesquisar = ttk.Treeview(janelapesquisar, selectmode = 'browse', show = 'headings', height = 20)
tabelapesquisar.place(x= 0, y = 0)
tabelapesquisar["columns"] = ("1", "2", "3", "4")
tabelapesquisar['show'] = 'headings'
tabelapesquisar.column("1", width=150, anchor='c')
tabelapesquisar.column("2", width=150, anchor='c')
tabelapesquisar.column("3", width=150, anchor='c')
tabelapesquisar.column("4", width=150, anchor='c')
arquivo = open("eventos.txt", "r")
t = arquivo.readlines()
arquivo.close()
for i in t:
j = i.split(';')
tabelapesquisar.insert("",'end',values=(j[0], j[1], j[2], j[3]))
g = Button(janelapesquisar, text = "Confirmar", font = "Times ", command = achar).place(x = 520, y = 575)
tabelapesquisar.heading("1", text="Nome")
tabelapesquisar.heading("2", text="Data")
tabelapesquisar.heading("3", text="Preço")
tabelapesquisar.heading("4", text="Local")
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#FUNÇAO PARA DELETAR UM EVENTO;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def delete():
x = tabela.selection()[0]
y = tabela.item(x, "values")
pesquisa = y[0]
arquivo = open("eventos.txt", "r")
produtos = arquivo.readlines()
arquivo.close()
arquivo = open("eventos.txt", "w")
for i in produtos:
lista = i.split(';')
if lista[0] != pesquisa:
arquivo.writelines(i)
arquivo.close()
x = tabela.selection()[0]
tabela.delete(x)
janela.mainloop()
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#JANELA;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
janela = Tk() janela.title("Let's Q Let's") janela.geometry("600x600")
v = [] arquivo = open("eventos.txt", "a") arquivo.close() tabela = ttk.Treeview(janela, selectmode = 'browse', show = 'headings', height = 29) arquivo = open("eventos.txt", "r") t = arquivo.readlines() arquivo.close()
for i in t:
v = i.split(';')
tabela.insert("",'end',text= "L1",values=(v[0], v[1], v[2], v[3]))
#BOTOES
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- BOTAO DE CRIAR
criar = Button(text = "Adicionar evento", command = criar) criar.place(x = 1, y = 575)
- BOTAO DE PESQUISAR
pesquisar = Button(text = "Pesquisar evento", command = pesquisar) pesquisar.place(x = 105, y = 575)
- BOTAO DE EDITAR
editar = Button(janela, text = "Editar", command = editar) editar.place(x = 210, y = 575)
- BOTAO DE DELETAR
delete= Button(janela, text = "Delete", command = delete) delete.place(x = 556, y = 575)
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#TABELA PRINCIPAL
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
tabela.place(x= 0, y = 0) tabela["columns"] = ("1", "2", "3", "4") tabela['show'] = 'headings'
tabela.column("1", width=150, anchor='c') tabela.column("2", width=150, anchor='c') tabela.column("3", width=150, anchor='c') tabela.column("4", width=150, anchor='c')
tabela.heading("1", text="Nome") tabela.heading("2", text="Data") tabela.heading("3", text="Preço") tabela.heading("4", text="Local")
janela.mainloop()
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
</syntaxhighlight>
21/06/2017 - 11h05
<syntaxhighlight lang="py" line="1"> from tkinter import ttk from tkinter import *
#FUNÇAO PARA CRIAR UM EVENTO;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def criar():
def Adicionar():
nome = aname.get()
data = adata.get()
preço = apreço.get()
local = alocal.get()
lista = []
lista.append(nome + ';')
lista.append(data +';')
lista.append(preço + ';')
lista.append(local + ';')
arquivo=open("eventos.txt", "r")
t=arquivo.readlines()
arquivo.close
j = []
flag = True
for i in t:
j=i.split(';')
if(j[1]==data and j[3]==local):
flag=False
Label(janelacriar, text="JA EXISTE UM EVENTO NESSE LOCAL NESSA DATA", foreground = "red").place(x=10, y=100)
if(flag):
arquivo = open("eventos.txt", "a")
arquivo.writelines(lista)
arquivo.write("\n")
arquivo.close()
tabela.insert("",'end',values=(nome, data, preço, local))
janelacriar.destroy()
return
janelacriar = Toplevel()
janelacriar.geometry("300x200")
janelacriar.title("Novo evento")
nome = Label(janelacriar, text = "Nome do evento:").place(x = 5, y = 5)
aname = Entry(janelacriar)
aname.place(x = 120, y = 5)
data = Label(janelacriar, text = "Data:").place(x = 5, y = 30)
adata = Entry(janelacriar)
adata.place(x = 120, y = 30)
Exemplo = Label(janelacriar, text = "DD/MM/AAAA", font = "Times 5").place(x = 245, y = 40)
preço = Label(janelacriar, text = "R$:").place(x = 5, y = 55)
apreço = Entry(janelacriar)
apreço.place(x = 120, y = 55)
local = Label(janelacriar, text = "Local:").place(x = 5, y = 80)
alocal = Entry(janelacriar)
alocal.place(x = 120, y = 80)
btnadd = Button(janelacriar, text = "Confirmar", font = "Times ", command = Adicionar).place(x = 200, y = 160)
janelacriar.mainloop()
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#FUNÇAO PARA EDITAR
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def editar():
x = tabela.selection()[0]
y = tabela.item(x, "values")
def adicionar():
nome = aname.get()
data = adata.get()
preço = apreço.get()
local = alocal.get()
arquivo = open("eventos.txt", "a")
lista = []
lista.append(nome + ';')
lista.append(data +';')
lista.append(preço + ';')
lista.append(local + ';')
arquivo.writelines(lista)
arquivo.write("\n")
arquivo.close()
def delete():
x = tabela.selection()[0]
y = tabela.item(x, "values")
pesquisa = y[0]
arquivo = open("eventos.txt", "r")
produtos = arquivo.readlines()
arquivo.close()
arquivo = open("eventos.txt", "w")
for i in produtos:
lista = i.split(';')
if lista[0] != pesquisa:
arquivo.writelines(i)
arquivo.close()
x = tabela.selection()[0]
tabela.delete(x)
delete()
tabela.insert("",'end',values=(nome, data, preço, local))
janelacriar.destroy()
return
janelacriar = Toplevel()
janelacriar.geometry("300x200")
janelacriar.title("Novo evento")
nome = Label(janelacriar, text = "Nome do evento:").place(x = 5, y = 5)
aname = Entry(janelacriar)
aname.place(x = 120, y = 5)
aname.insert(END, y[0])
data = Label(janelacriar, text = "Data:").place(x = 5, y = 30)
adata = Entry(janelacriar)
adata.place(x = 120, y = 30)
adata.insert(END, y[1])
Exemplo = Label(janelacriar, text = "DD/MM/AAAA", font = "Times 5").place(x = 245, y = 40)
preço = Label(janelacriar, text = "R$:").place(x = 5, y = 55)
apreço = Entry(janelacriar)
apreço.place(x = 120, y = 55)
apreço.insert(END,y[2])
local = Label(janelacriar, text = "Local:").place(x = 5, y = 80)
alocal = Entry(janelacriar)
alocal.place(x = 120, y = 80)
alocal.insert(END, y[3])
delete
btnadd = Button(janelacriar, text = "Confirmar", font = "Times ", command = adicionar).place(x = 200, y = 160)
janelacriar.mainloop()
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#FUNÇAO PARA PESQUISAR UM EVENTO;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def pesquisar():
def achar():
j = []
nome = aname.get()
data = adata.get()
preço = apreço.get()
local = alocal.get()
arquivo = open("eventos.txt", "r")
t = arquivo.readlines()
arquivo.close()
tabelapesquisar.delete(*tabelapesquisar.get_children())
for i in t:
j = i.split(';')
if(j[0]==nome or nome==):
if(j[1]==data or data==):
if(j[2]==preço or preço==):
if(j[3]==local or local==):
tabelapesquisar.insert("",'end',values=(j[0], j[1], j[2], j[3]))
janelapesquisar = Tk()
janelapesquisar.geometry("600x600")
janelapesquisar.title("Pesquisar")
nome = Label(janelapesquisar, text = "Nome do evento:").place(x = 1, y = 430)
aname = Entry(janelapesquisar)
aname.place(x = 100, y = 430)
data = Label(janelapesquisar, text = "Data:").place(x = 1, y = 455)
adata = Entry(janelapesquisar)
adata.place(x = 100, y = 455)
Exemplo = Label(janelapesquisar, text = "DD/MM/AAAA", font = "Times 5").place(x = 245, y = 40)
local = Label(janelapesquisar, text = "Local:").place(x = 1, y = 480)
alocal = Entry(janelapesquisar)
alocal.place(x = 100, y = 480)
preço = Label(janelapesquisar, text = "R$:").place(x = 1, y = 505)
apreço = Entry(janelapesquisar)
apreço.place(x = 100, y = 505)
tabelapesquisar = ttk.Treeview(janelapesquisar, selectmode = 'browse', show = 'headings', height = 20)
tabelapesquisar.place(x= 0, y = 0)
tabelapesquisar["columns"] = ("1", "2", "3", "4")
tabelapesquisar['show'] = 'headings'
tabelapesquisar.column("1", width=150, anchor='c')
tabelapesquisar.column("2", width=150, anchor='c')
tabelapesquisar.column("3", width=150, anchor='c')
tabelapesquisar.column("4", width=150, anchor='c')
arquivo = open("eventos.txt", "r")
t = arquivo.readlines()
arquivo.close()
for i in t:
j = i.split(';')
tabelapesquisar.insert("",'end',values=(j[0], j[1], j[2], j[3]))
g = Button(janelapesquisar, text = "Confirmar", font = "Times ", command = achar).place(x = 556, y = 575)
tabelapesquisar.heading("1", text="Nome")
tabelapesquisar.heading("2", text="Data")
tabelapesquisar.heading("3", text="Preço")
tabelapesquisar.heading("4", text="Local")
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#FUNÇAO PARA DELETAR UM EVENTO;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def delete():
x = tabela.selection()[0]
y = tabela.item(x, "values")
pesquisa = y[0]
arquivo = open("eventos.txt", "r")
produtos = arquivo.readlines()
arquivo.close()
arquivo = open("eventos.txt", "w")
for i in produtos:
lista = i.split(';')
if lista[0] != pesquisa:
arquivo.writelines(i)
arquivo.close()
x = tabela.selection()[0]
tabela.delete(x)
janela.mainloop()
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#JANELA;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
janela = Tk() janela.title("Let's Q Let's") janela.geometry("600x600")
v = [] arquivo = open("eventos.txt", "a") arquivo.close() tabela = ttk.Treeview(janela, selectmode = 'browse', show = 'headings', height = 29) arquivo = open("eventos.txt", "r") t = arquivo.readlines() arquivo.close()
for i in t:
v = i.split(';')
tabela.insert("",'end',text= "L1",values=(v[0], v[1], v[2], v[3]))
#BOTOES
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- BOTAO DE CRIAR
criar = Button(text = "Adicionar evento", command = criar) criar.place(x = 1, y = 575)
- BOTAO DE PESQUISAR
pesquisar = Button(text = "Pesquisar evento", command = pesquisar) pesquisar.place(x = 105, y = 575)
- BOTAO DE EDITAR
editar = Button(janela, text = "Editar", command = editar) editar.place(x = 210, y = 575)
- BOTAO DE DELETAR
delete= Button(janela, text = "Delete", command = delete) delete.place(x = 556, y = 575)
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#TABELA PRINCIPAL
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
tabela.place(x= 0, y = 0) tabela["columns"] = ("1", "2", "3", "4") tabela['show'] = 'headings'
tabela.column("1", width=150, anchor='c') tabela.column("2", width=150, anchor='c') tabela.column("3", width=150, anchor='c') tabela.column("4", width=150, anchor='c')
tabela.heading("1", text="Nome") tabela.heading("2", text="Data") tabela.heading("3", text="Preço") tabela.heading("4", text="Local")
janela.mainloop()
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
</syntaxhighlight>