Escopo
- Desenvolver uma aplicação que informe sobre eventos da cidade de Uberlândia.
- Participantes:
- Gabrielle Alves
- Henrique Lara
- Matheus Alves
- Yaraline Vilela
Funcionalidades
- Cadastrar os eventos
- Alterar os eventos cadastrados
- Excluir algum evento
- Mostrar eventos de acordo com:
- o dia
- estilo
- o preço
- Sincronizar contatos do Face
- Nova funcionalidade:
- Criar botão: Eventos da Semana
- Ao clicar, aparecerá todas os eventos da semana
<syntaxhighlight lang="python3">
from tkinter import ttk
from tkinter import *
- FUNÇAO PARA CRIAR UM EVENTO;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def criar():
def Adicionar():
nome = aname.get()
data = adata.get()
preco = apreco.get()
local = alocal.get()
tipo = atipo.get()
lista = []
lista.append(nome + ';')
lista.append(data +';')
lista.append(preco + ';')
lista.append(local + ';')
lista.append(tipo + ';')
arquivo=open("C:/Users/a11521BTC004/Documents/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] + lista[4]
if(flag and len(aux) > 7):
arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "a")
arquivo.writelines(lista)
arquivo.write("\n")
arquivo.close()
tabela.insert("",'end',values=(nome, data, preco, local, tipo))
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)
preco = Label(janelacriar, text = "R$:").place(x = 5, y = 55)
apreco = Entry(janelacriar)
apreco.place(x = 120, y = 55)
local = Label(janelacriar, text = "Local:").place(x = 5, y = 80)
alocal = Entry(janelacriar)
alocal.place(x = 120, y = 80)
tipo = Label(janelacriar, text = "Tipo:").place(x = 5, y = 100)
atipo = Entry(janelacriar)
atipo.place(x = 120, y = 100)
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()
tipo = atipo.get()
arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "a")
lista = []
lista.append(nome + ';')
lista.append(data +';')
lista.append(preço + ';')
lista.append(local + ';')
lista.append(tipo + ';')
arquivo.writelines(lista)
arquivo.write("\n")
arquivo.close()
def delete():
x = tabela.selection()[0]
y = tabela.item(x, "values")
pesquisa = y[0]
arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "r")
produtos = arquivo.readlines()
arquivo.close()
arquivo = open("C:/Users/a11521BTC004/Documents/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, tipo))
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])
tipo = Label(janelacriar, text = "Tipo:").place(x = 5, y = 100)
atipo = Entry(janelacriar)
atipo.place(x = 120, y = 100)
atipo.insert(END, y[4])
btnadd = Button(janelacriar, text = "Confirmar", font = "Times ", command = adicionar).place(x = 200, y = 160)
janelacriar.mainloop()
return
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#FUNÇAO PARA PESQUISAR UM EVENTO;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def pesquisar():
def achar():
j = []
nome = aname.get()
data = adata.get()
preco = apreco.get()
local = alocal.get()
tipo = atipo.get()
arquivo = open("C:/Users/a11521BTC004/Documents/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]==preco or preco==):
if(j[3]==local or local==):
if(j[4]==tipo or tipo==):
tabelapesquisar.insert("",'end',values=(j[0], j[1], j[2], j[3], j[4]))
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)
preco = Label(janelapesquisar, text = "R$:").place(x = 1, y = 505)
apreco = Entry(janelapesquisar)
apreco.place(x = 100, y = 505)
tipo = Label(janelapesquisar, text = "Tipo:").place(x = 1, y = 535)
atipo = Entry(janelapesquisar)
atipo.place(x = 100, y = 535)
tabelapesquisar = ttk.Treeview(janelapesquisar, selectmode = 'browse', show = 'headings', height = 20)
tabelapesquisar.place(x= 0, y = 0)
tabelapesquisar["columns"] = ("1", "2", "3", "4", "5")
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')
tabelapesquisar.column("5", width=150, anchor='c')
arquivo = open("C:/Users/a11521BTC004/Documents/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], j[4]))
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="preco")
tabelapesquisar.heading("4", text="Local")
tabelapesquisar.heading("5", text="Tipo")
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#FUNÇAO PARA DELETAR UM EVENTO;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def delete():
x = tabela.selection()[0]
y = tabela.item(x, "values")
pesquisa = y[0]
arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "r")
produtos = arquivo.readlines()
arquivo.close()
arquivo = open("C:/Users/a11521BTC004/Documents/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()
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- FUNÇAO DE PESQUISAR EVENTOS DA SEMANA
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def eventosSemana():
from datetime import datetime
hj = datetime.today()
futuro = datetime.fromordinal(hj.toordinal()+7)
arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "r")
t = arquivo.readlines()
arquivo.close()
listarEventosSemana(hj.strftime('%d/%m/%Y') + " ate " + futuro.strftime('%d/%m/%Y'), t)
#tabelapesquisar.delete(*tabelapesquisar.get_children())
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- FUNÇAO PARA LISTAR EVENTOS DA SEMANA;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def listarEventosSemana(periodo, lista):
janela = Tk()
janela.title("Eventos da Semana: " + periodo)
janela.geometry("600x300")
tabela = ttk.Treeview(janela, selectmode = 'browse', show = 'headings', height = 29)
tabela.place(x= 0, y = 0)
tabela["columns"] = ("1", "2", "3", "4", "5")
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.column("5", width=150, anchor='c')
tabela.heading("1", text="Nome")
tabela.heading("2", text="Data")
tabela.heading("3", text="preco")
tabela.heading("4", text="Local")
tabela.heading("5", text="Tipo")
#janela.mainloop()
from datetime import datetime
hj = datetime.today()
futuro = datetime.fromordinal(hj.toordinal()+7)
for evento in lista:
v = evento.split(';')
dataconvertida = datetime.strptime(v[1], '%d/%m/%Y')
if dataconvertida >= hj and dataconvertida <= futuro:
tabela.insert("",'end',text= "L1",values=(v[0], v[1], "R$" + v[2], v[3], v[4]))
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#JANELA;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
janela = Tk()
janela.title("UbeRolê")
janela.geometry("600x600")
v = []
arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "a")
arquivo.close()
tabela = ttk.Treeview(janela, selectmode = 'browse', show = 'headings', height = 29)
arquivo = open("C:/Users/a11521BTC004/Documents/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], v[4]))
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#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 = "Deletar", command = delete)
delete.place(x = 556, y = 575)
- BOTÃO DE EVENTOS DA SEMANA
eventos= Button(janela, text = "Eventos da semana", command = eventosSemana)
eventos.place(x = 255, y = 575)
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#TABELA PRINCIPAL
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
tabela.place(x= 0, y = 0)
tabela["columns"] = ("1", "2", "3", "4", "5")
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.column("5", width=150, anchor='c')
tabela.heading("1", text="Nome")
tabela.heading("2", text="Data")
tabela.heading("3", text="preco")
tabela.heading("4", text="Local")
tabela.heading("5", text="Tipo")
janela.mainloop()
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
</syntaxhighlight>
Código novo