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 Comentado
<syntaxhighlight lang="python3"> from tkinter import ttk
from tkinter import *
- FUNÇAO PARA CRIAR UM EVENTO;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def criar(): #Def funciona para definir uma função
def Adicionar():
nome = aname.get()
data = adata.get()
preco = apreco.get()
local = alocal.get()
tipo = atipo.get()
ingresso = aingresso.get() # Aqui foi adicionado a variavel ingresso assim #
fetaria = afetaria.get() # Aqui foi adicionado a variável faixa etária #
lista = []
lista.append(nome + ';') # função append de adicionar à lista o que for digitado #
lista.append(data +';')
lista.append(preco + ';')
lista.append(local + ';')
lista.append(tipo + ';')
lista.append(ingresso + ';')
lista.append(fetaria + ';')
arquivo=open("C:/Users/Yaraline/Documents/eventos.txt", "r") # função de abrir o arquivo para leitura"
t=arquivo.readlines()
arquivo.close
j = []
flag = True
for i in t: #função para evitar a repetição de eventos "
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/Yaraline/Documents/eventos.txt", "a") #função para ler e escrever no documento já criado#
arquivo.writelines(lista)
arquivo.write("\n")
arquivo.close()
tabela.insert("",'end',values=(nome, data, preco, local, tipo, ingresso, fetaria))
janelacriar.destroy()
return
janelacriar = Toplevel() #função para criação de uma janela para a inserção dos dados #
janelacriar.geometry("300x245")
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 = 105)
atipo = Entry(janelacriar)
atipo.place(x = 120, y = 105)
ingresso = Label(janelacriar, text = "Ingresso:").place(x = 5, y = 130)#Aqui foi introduzido o layout da categoria ingresso no programa assim como o da F. Etaria. #
aingresso = Entry(janelacriar)
aingresso.place(x = 120, y = 130)
fetaria = Label(janelacriar, text = "Faixa Etária:").place(x = 5, y = 155) #
afetaria = Entry(janelacriar)
afetaria.place(x = 120, y = 155)
btnadd = Button(janelacriar, text = "Confirmar", font = "Times ", command = Adicionar).place(x = 210, y = 200) #função para a o botão Confirmar #
janelacriar.mainloop()
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- FUNÇAO PARA EDITAR
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def editar(): #função para a leitura e edição de eventos já salvos #
x = tabela.selection()[0]
y = tabela.item(x, "values")
def adicionar():
nome = aname.get()
data = adata.get()
preco = apreco.get()
local = alocal.get()
tipo = atipo.get()
ingresso = aingresso.get()
fetaria = afetaria.get()
arquivo = open("C:/Users/Yaraline/Documents/eventos.txt", "a") #abertura, leitura, e edição do documento salvo #
lista = []
lista.append(nome + ';')
lista.append(data +';')
lista.append(preco + ';')
lista.append(local + ';')
lista.append(tipo + ';')
lista.append(ingresso + ';')
lista.append(fetaria + ';')
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/Yaraline/Documents/eventos.txt", "r")
produtos = arquivo.readlines()
arquivo.close()
arquivo = open("C:/Users/Yaraline/Documents/eventos.txt", "w") #função de escrita para o documento #
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, preco, local, tipo, ingresso, fetaria))
janelacriar.destroy()
return
janelacriar = Toplevel()
janelacriar.geometry("300x245")
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)
preco = Label(janelacriar, text = "R$:").place(x = 5, y = 55)
apreco = Entry(janelacriar)
apreco.place(x = 120, y = 55)
apreco.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 = 105)
atipo = Entry(janelacriar)
atipo.place(x = 120, y = 105)
atipo.insert(END, y[4])
ingresso = Label(janelacriar, text = "Ingresso:").place(x = 5, y = 130) #
aingresso = Entry(janelacriar)
aingresso.place(x=120, y=130)
aingresso.insert(END, y[5])
fetaria = Label(janelacriar, text = "Faixa Etária:").place(x = 5, y = 155)
afetaria = Entry(janelacriar)
afetaria.place(x = 120, y = 155)
afetaria.insert(END, y[6])
btnadd = Button(janelacriar, text = "Confirmar", font = "Times ", command = adicionar).place(x = 210, y = 200)
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()
ingresso = aingresso.get()
fetaria = afetaria.get()
arquivo = open("C:/Users/Yaraline/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==):
if(j[5]==ingresso or ingresso==): # Adicionado posiçao do vetor 5 e 6, para ingresso e faixa etaria #
if(j[6]==fetaria or fetaria==):
tabelapesquisar.insert("",'end',values=(j[0], j[1], j[2], j[3], j[4], j[5], j[6]))
janelapesquisar = Tk()
janelapesquisar.geometry("1050x610") # Foi aumentada a geometria da janela em 10 pixels #
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 = 530)
atipo = Entry(janelapesquisar)
atipo.place(x = 100, y = 530)
ingresso = Label(janelapesquisar, text = "Ingresso:").place(x = 1, y = 555) # Foi adicionado a caixa de ingresso e faixa etaria na janela pesquisar #
aingresso = Entry(janelapesquisar)
aingresso.place(x = 100, y = 555)
fetaria = Label(janelapesquisar, text = "Faixa Etária:").place(x = 1, y = 580)
afetaria = Entry(janelapesquisar)
afetaria.place(x = 100, y = 580)
tabelapesquisar = ttk.Treeview(janelapesquisar, selectmode = 'browse', show = 'headings', height = 20)
tabelapesquisar.place(x= 0, y = 0)
tabelapesquisar["columns"] = ("1", "2", "3", "4", "5", "6", "7") # Foi adicionado duas colunas na exibição da janela de pesquisa #
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')
tabelapesquisar.column("6", width=150, anchor='c') # Foi definido a largura das novas colunas da janela #
tabelapesquisar.column("7", width=150, anchor='c')
arquivo = open("C:/Users/Yaraline/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], j[5], j[6]))
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")
tabelapesquisar.heading("5", text="Tipo")
tabelapesquisar.heading("6", text="Ingresso") # Aqui foi dado nome às colunas da janela #
tabelapesquisar.heading("7", text="Faixa Etária")
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#FUNÇAO PARA DELETAR UM EVENTO;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
def delete():
x = tabela.selection()[0]
y = tabela.item(x, "values")
pesquisa = y[0]
arquivo = open("C:/Users/Yaraline/Documents/eventos.txt", "r")
produtos = arquivo.readlines()
arquivo.close()
arquivo = open("C:/Users/Yaraline/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 #função import para importar uma informação da máquina, como a data #
hj = datetime.today()
futuro = datetime.fromordinal(hj.toordinal()+7)
arquivo = open("C:/Users/Yaraline/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", "6", "7") # Foi adicionado duas colunas a janela para listagem de evento da semana #
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.column("6", width=150, anchor='c') # Foi defindo a largura da coluna #
tabela.column("7", 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")
tabela.heading("6", text="Ingresso") # Foi definido o nome da coluna #
tabela.heading("7", text="Faixa Etária")
#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], v[5], v[6]))
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#JANELA;
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
janela = Tk()
janela.title("UbeRolê")
janela.geometry("1052x600+100+0") # Aqui foi alterado a dimensão da janela e seu posicionamento no monitor #
v = []
arquivo = open("C:/Users/Yaraline/Documents/eventos.txt", "a")
arquivo.close()
tabela = ttk.Treeview(janela, selectmode = 'browse', show = 'headings', height = 29)
arquivo = open("C:/Users/Yaraline/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], v[5], v[6]))
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#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 = 1005, 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", "6", "7")
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.column("6", width=150, anchor='c')
tabela.column("6", width=150, anchor='c')
tabela.column("7", 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")
tabela.heading("5", text="Tipo")
tabela.heading("6", text="Ingresso")
tabela.heading("7", text="F. Etária")
janela.mainloop() </syntaxhighlight>