Etiqueta: visualeditor
Etiqueta: visualeditor
 
(4 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 20: Linha 20:
** Ao clicar, aparecerá todas os eventos da semana
** Ao clicar, aparecerá todas os eventos da semana
<br>
<br>
= 24/07/2017=
<syntaxhighlight lang="python3">
= 24/07/2017 =


= Código =
from tkinter import ttk
<br>from tkinter import ttk


from tkinter import *
from tkinter import *


#FUNÇAO PARA CRIAR UM EVENTO;


 
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 
 
<nowiki>#</nowiki>FUNÇAO PARA CRIAR UM EVENTO;
 
<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


def criar():
def criar():


       def Adicionar():
      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("eventos.txt", "r")
 
              t=arquivo.readlines()
 
              arquivo.close
 
              j = []
 
              flag = True


              for i in t:
              nome = aname.get()


                     j=i.split(';')
              data = adata.get()


                     if(j[1]==data and j[3]==local):
              preco = apreco.get()


                            flag=False
              local = alocal.get()


                            Label(janelacriar, text="JA EXISTE UM EVENTO NESSE LOCAL NESSA DATA", foreground = "red").place(x=10, y=100)
              tipo = atipo.get()


              aux = lista[0] + lista[1] + lista[2] + lista[3] + lista[4]
              lista = []


              if(flag and len(aux) > 7):
              lista.append(nome + ';')


                     arquivo = open("eventos.txt", "a")
              lista.append(data +';')


                     arquivo.writelines(lista)
              lista.append(preco + ';')


                     arquivo.write("\n")
              lista.append(local + ';')


                     arquivo.close()
              lista.append(tipo + ';')


              arquivo=open("C:/Users/a11521BTC004/Documents/eventos.txt", "r")


              t=arquivo.readlines()


                     tabela.insert("",'end',values=(nome, data, preco, local, tipo))
              arquivo.close


                     janelacriar.destroy()
              j = []


                     return
              flag = True


       janelacriar = Toplevel()
              for i in t:


       janelacriar.geometry("300x200")
                    j=i.split(';')


       janelacriar.title("Novo evento")
                    if(j[1]==data and j[3]==local):


       nome = Label(janelacriar, text = "Nome do evento:").place(x = 5, y = 5)
                            flag=False


       aname = Entry(janelacriar)
                            Label(janelacriar, text="JA EXISTE UM EVENTO NESSE LOCAL NESSA DATA", foreground = "red").place(x=10, y=100)


       aname.place(x = 120, y = 5)
              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")


       data = Label(janelacriar, text = "Data:").place(x = 5, y = 30)
                    arquivo.writelines(lista)


       adata = Entry(janelacriar)
                    arquivo.write("\n")


       adata.place(x = 120, y = 30)
                    arquivo.close()


       Exemplo = Label(janelacriar, text = "DD/MM/AAAA", font = "Times 5").place(x = 245, y = 40)
                    tabela.insert("",'end',values=(nome, data, preco, local, tipo))


                    janelacriar.destroy()


                    return


       preco = Label(janelacriar, text = "R$:").place(x = 5, y = 55)
      janelacriar = Toplevel()


       apreco = Entry(janelacriar)
      janelacriar.geometry("300x200")


       apreco.place(x = 120, y = 55)
      janelacriar.title("Novo evento")


      nome = Label(janelacriar, text = "Nome do evento:").place(x = 5, y = 5)


      aname = Entry(janelacriar)


       local = Label(janelacriar, text = "Local:").place(x = 5, y = 80)
      aname.place(x = 120, y = 5)


       alocal = Entry(janelacriar)
      data = Label(janelacriar, text = "Data:").place(x = 5, y = 30)


       alocal.place(x = 120, y = 80)
      adata = Entry(janelacriar)


      adata.place(x = 120, y = 30)


      Exemplo = Label(janelacriar, text = "DD/MM/AAAA", font = "Times 5").place(x = 245, y = 40)


       tipo = Label(janelacriar, text = "Tipo:").place(x = 5, y = 100)
      preco = Label(janelacriar, text = "R$:").place(x = 5, y = 55)


       atipo = Entry(janelacriar)
      apreco = Entry(janelacriar)


       atipo.place(x = 120, y = 100)
      apreco.place(x = 120, y = 55)


      local = Label(janelacriar, text = "Local:").place(x = 5, y = 80)


      alocal = Entry(janelacriar)


       btnadd = Button(janelacriar, text = "Confirmar", font = "Times ", command = Adicionar).place(x = 200, y = 160)
      alocal.place(x = 120, y = 80)


       janelacriar.mainloop()
      tipo = Label(janelacriar, text = "Tipo:").place(x = 5, y = 100)


<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      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


 
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 
 
<nowiki>#</nowiki>FUNÇAO PARA EDITAR
 
<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


def editar():
def editar():


       x = tabela.selection()[0]
      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("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("eventos.txt", "r")
 
                     produtos = arquivo.readlines()
 
                     arquivo.close()
 
 
 
                     arquivo = open("eventos.txt", "w")


                     for i in produtos:
      y = tabela.item(x, "values")


                            lista = i.split(';')
      def adicionar():


                            if lista[0] != pesquisa:
              nome = aname.get()


                                   arquivo.writelines(i)
              data = adata.get()


              preço = apreço.get()


              local = alocal.get()


                     arquivo.close()
              tipo = atipo.get()


                     x = tabela.selection()[0]
              arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "a")


                     tabela.delete(x)
              lista = []


              delete()
              lista.append(nome + ';')


              tabela.insert("",'end',values=(nome, data, preço, local, tipo))
              lista.append(data +';')


              janelacriar.destroy()
              lista.append(preço + ';')


              return
              lista.append(local + ';')


              lista.append(tipo + ';')


              arquivo.writelines(lista)


       janelacriar = Toplevel()
              arquivo.write("\n")


       janelacriar.geometry("300x200")
              arquivo.close()


       janelacriar.title("Novo evento")
              def delete():


       nome = Label(janelacriar, text = "Nome do evento:").place(x = 5, y = 5)
                    x = tabela.selection()[0]


       aname = Entry(janelacriar)
                    y = tabela.item(x, "values")


       aname.place(x = 120, y = 5)
                    pesquisa = y[0]


       aname.insert(END, y[0])
                    arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "r")


                    produtos = arquivo.readlines()


                    arquivo.close()


       data = Label(janelacriar, text = "Data:").place(x = 5, y = 30)
                    arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "w")


       adata = Entry(janelacriar)
                    for i in produtos:


       adata.place(x = 120, y = 30)
                            lista = i.split(';')


       adata.insert(END, y[1])
                            if lista[0] != pesquisa:


       Exemplo = Label(janelacriar, text = "DD/MM/AAAA", font = "Times 5").place(x = 245, y = 40)
                                  arquivo.writelines(i)


                    arquivo.close()


                    x = tabela.selection()[0]


       preço = Label(janelacriar, text = "R$:").place(x = 5, y = 55)
                    tabela.delete(x)


       apreço = Entry(janelacriar)
              delete()


       apreço.place(x = 120, y = 55)
              tabela.insert("",'end',values=(nome, data, preço, local, tipo))


       apreço.insert(END,y[2])
              janelacriar.destroy()


              return


      janelacriar = Toplevel()


       local = Label(janelacriar, text = "Local:").place(x = 5, y = 80)
      janelacriar.geometry("300x200")


       alocal = Entry(janelacriar)
      janelacriar.title("Novo evento")


       alocal.place(x = 120, y = 80)
      nome = Label(janelacriar, text = "Nome do evento:").place(x = 5, y = 5)


       alocal.insert(END, y[3])
      aname = Entry(janelacriar)


      aname.place(x = 120, y = 5)


      aname.insert(END, y[0])


       tipo = Label(janelacriar, text = "Tipo:").place(x = 5, y = 100)
      data = Label(janelacriar, text = "Data:").place(x = 5, y = 30)


       atipo = Entry(janelacriar)
      adata = Entry(janelacriar)


       atipo.place(x = 120, y = 100)
      adata.place(x = 120, y = 30)


       atipo.insert(END, y[4])
      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)


       btnadd = Button(janelacriar, text = "Confirmar", font = "Times ", command = adicionar).place(x = 200, y = 160)
      alocal = Entry(janelacriar)


       janelacriar.mainloop()
      alocal.place(x = 120, y = 80)


       return
      alocal.insert(END, y[3])


      tipo = Label(janelacriar, text = "Tipo:").place(x = 5, y = 100)


      atipo = Entry(janelacriar)


<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      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;


                     #FUNÇAO PARA PESQUISAR UM EVENTO;
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 
<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


def pesquisar():
def pesquisar():


       def achar():
      def achar():
 
              j = []
 
              nome = aname.get()
 
              data = adata.get()
 
              preco = apreco.get()
 
              local = alocal.get()
 
              tipo = atipo.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==<nowiki>''</nowiki>):
 
                            if(j[1]==data or data==<nowiki>''</nowiki>):
 
                                   if(j[2]==preco or preco==<nowiki>''</nowiki>):
 
                                          if(j[3]==local or local==<nowiki>''</nowiki>):
 
                                                if(j[4]==tipo or tipo==<nowiki>''</nowiki>):
 
                                                    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)
              j = []


       aname.place(x = 100, y = 430)
              nome = aname.get()


              data = adata.get()


              preco = apreco.get()


       data = Label(janelapesquisar, text = "Data:").place(x = 1, y = 455)
              local = alocal.get()


       adata = Entry(janelapesquisar)
              tipo = atipo.get()


       adata.place(x = 100, y = 455)
              arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "r")


       Exemplo = Label(janelapesquisar, text = "DD/MM/AAAA", font = "Times 5").place(x = 245, y = 40)
              t = arquivo.readlines()


              arquivo.close()


              tabelapesquisar.delete(*tabelapesquisar.get_children())


       local = Label(janelapesquisar, text = "Local:").place(x = 1, y = 480)
              for i in t:


       alocal = Entry(janelapesquisar)
                    j = i.split(';')


       alocal.place(x = 100, y = 480)
                    if(j[0]==nome or nome==''):


                            if(j[1]==data or data==''):


                                  if(j[2]==preco or preco==''):


       preco = Label(janelapesquisar, text = "R$:").place(x = 1, y = 505)
                                          if(j[3]==local or local==''):


       apreco = Entry(janelapesquisar)
                                                if(j[4]==tipo or tipo==''):


       apreco.place(x = 100, y = 505)
                                                    tabelapesquisar.insert("",'end',values=(j[0], j[1], j[2], j[3], j[4]))


      janelapesquisar = Tk()


      janelapesquisar.geometry("600x600")


       tipo = Label(janelapesquisar, text = "Tipo:").place(x = 1, y = 535)
      janelapesquisar.title("Pesquisar")


       atipo = Entry(janelapesquisar)
      nome = Label(janelapesquisar, text = "Nome do evento:").place(x = 1, y = 430)


       atipo.place(x = 100, y = 535)
      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)


       tabelapesquisar = ttk.Treeview(janelapesquisar, selectmode = 'browse', show = 'headings', height = 20)
      Exemplo = Label(janelapesquisar, text = "DD/MM/AAAA", font = "Times 5").place(x = 245, y = 40)


       tabelapesquisar.place(x= 0, y = 0)
      local = Label(janelapesquisar, text = "Local:").place(x = 1, y = 480)


       tabelapesquisar["columns"] = ("1", "2", "3", "4", "5")
      alocal = Entry(janelapesquisar)


       tabelapesquisar['show'] = 'headings'
      alocal.place(x = 100, y = 480)


       tabelapesquisar.column("1", width=150, anchor='c')
      preco = Label(janelapesquisar, text = "R$:").place(x = 1, y = 505)


       tabelapesquisar.column("2", width=150, anchor='c')
      apreco = Entry(janelapesquisar)


       tabelapesquisar.column("3", width=150, anchor='c')
      apreco.place(x = 100, y = 505)


       tabelapesquisar.column("4", width=150, anchor='c')
      tipo = Label(janelapesquisar, text = "Tipo:").place(x = 1, y = 535)


       tabelapesquisar.column("5", width=150, anchor='c')
      atipo = Entry(janelapesquisar)


       arquivo = open("eventos.txt", "r")
      atipo.place(x = 100, y = 535)


       t = arquivo.readlines()
      tabelapesquisar = ttk.Treeview(janelapesquisar, selectmode = 'browse', show = 'headings', height = 20)


       arquivo.close()
      tabelapesquisar.place(x= 0, y = 0)


       for i in t:
      tabelapesquisar["columns"] = ("1", "2", "3", "4", "5")


              j = i.split(';')
      tabelapesquisar['show'] = 'headings'


              tabelapesquisar.insert("",'end',values=(j[0], j[1], j[2], j[3], j[4]))
      tabelapesquisar.column("1", width=150, anchor='c')


       g = Button(janelapesquisar, text = "Confirmar", font = "Times ", command = achar).place(x = 520, y = 575)
      tabelapesquisar.column("2", width=150, anchor='c')


      tabelapesquisar.column("3", width=150, anchor='c')


      tabelapesquisar.column("4", width=150, anchor='c')


       tabelapesquisar.heading("1", text="Nome")
      tabelapesquisar.column("5", width=150, anchor='c')


       tabelapesquisar.heading("2", text="Data")
      arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "r")


       tabelapesquisar.heading("3", text="preco")
      t = arquivo.readlines()


       tabelapesquisar.heading("4", text="Local")
      arquivo.close()


       tabelapesquisar.heading("5", text="Tipo")
      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")


<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      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;


 
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                     #FUNÇAO PARA DELETAR UM EVENTO;
 
<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


def delete():
def delete():


       x = tabela.selection()[0]
      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")
      y = tabela.item(x, "values")


       for i in produtos:
      pesquisa = y[0]


              lista = i.split(';')
      arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "r")


              if lista[0] != pesquisa:
      produtos = arquivo.readlines()


                     arquivo.writelines(i)
      arquivo.close()


      arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "w")


      for i in produtos:


       arquivo.close()
              lista = i.split(';')


       x = tabela.selection()[0]
              if lista[0] != pesquisa:


       tabela.delete(x)
                    arquivo.writelines(i)


       janela.mainloop()
      arquivo.close()


<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      x = tabela.selection()[0]


      tabela.delete(x)


      janela.mainloop()


#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


#FUNÇAO DE PESQUISAR EVENTOS DA SEMANA


<nowiki>#</nowiki>FUNÇAO DE PESQUISAR EVENTOS DA SEMANA
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 
<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


def eventosSemana():
def eventosSemana():


        from datetime import datetime


        hj = datetime.today()


        from datetime import datetime
        futuro = datetime.fromordinal(hj.toordinal()+7)
 
        hj = datetime.today()
 
        futuro = datetime.fromordinal(hj.toordinal()+7)
 
 
 
        arquivo = open("eventos.txt", "r")
 
        t = arquivo.readlines()
 
        arquivo.close()
 
 
 
        listarEventosSemana(hj.strftime('%d/%m/%Y') + " ate " + futuro.strftime('%d/%m/%Y'), t)


        arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "r")


        t = arquivo.readlines()


        #tabelapesquisar.delete(*tabelapesquisar.get_children())
        arquivo.close()


<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
        listarEventosSemana(hj.strftime('%d/%m/%Y') + " ate " + futuro.strftime('%d/%m/%Y'), t)


        #tabelapesquisar.delete(*tabelapesquisar.get_children())


#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


<nowiki>#</nowiki>FUNÇAO PARA LISTAR EVENTOS DA SEMANA;
#FUNÇAO PARA LISTAR EVENTOS DA SEMANA;


<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


def listarEventosSemana(periodo, lista):
def listarEventosSemana(periodo, lista):


       janela = Tk()
      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")
      janela.title("Eventos da Semana: " + periodo)


       tabela.heading("5", text="Tipo")
      janela.geometry("600x300")


      tabela = ttk.Treeview(janela, selectmode = 'browse', show = 'headings', height = 29)


      tabela.place(x= 0, y = 0)


       #janela.mainloop()
      tabela["columns"] = ("1", "2", "3", "4", "5")


      tabela['show'] = 'headings'


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


       from datetime import datetime
      tabela.column("2", width=150, anchor='c')


       hj = datetime.today()
      tabela.column("3", width=150, anchor='c')


       futuro = datetime.fromordinal(hj.toordinal()+7)
      tabela.column("4", width=150, anchor='c')


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


      tabela.heading("1", text="Nome")


       for evento in lista:
      tabela.heading("2", text="Data")


           v = evento.split(';')
      tabela.heading("3", text="preco")


      tabela.heading("4", text="Local")


      tabela.heading("5", text="Tipo")


           dataconvertida = datetime.strptime(v[1], '%d/%m/%Y')
      #janela.mainloop()


      from datetime import datetime


      hj = datetime.today()


           if dataconvertida >= hj and dataconvertida <= futuro:
      futuro = datetime.fromordinal(hj.toordinal()+7)


                tabela.insert("",'end',text= "L1",values=(v[0], v[1], "R$" + v[2], v[3], v[4]))
      for evento in lista:


<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
          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;
 
<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


janela = Tk()
janela = Tk()
Linha 673: Linha 533:


janela.geometry("600x600")
janela.geometry("600x600")


v = []
v = []


arquivo = open("eventos.txt", "a")
arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "a")


arquivo.close()
arquivo.close()
Linha 684: Linha 542:
tabela = ttk.Treeview(janela, selectmode = 'browse', show = 'headings', height = 29)
tabela = ttk.Treeview(janela, selectmode = 'browse', show = 'headings', height = 29)


arquivo = open("eventos.txt", "r")
arquivo = open("C:/Users/a11521BTC004/Documents/eventos.txt", "r")


t = arquivo.readlines()
t = arquivo.readlines()


arquivo.close()
arquivo.close()


for i in t:
for i in t:


       v = i.split(';')
      v = i.split(';')


       tabela.insert("",'end',text= "L1",values=(v[0], v[1], v[2], v[3], v[4]))
      tabela.insert("",'end',text= "L1",values=(v[0], v[1], v[2], v[3], v[4]))


<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


                    #BOTOES


#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


 
#BOTAO DE CRIAR
 
                     #BOTOES
 
<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 
<nowiki>#</nowiki>BOTAO DE CRIAR


criar = Button(text = "Adicionar evento", command = criar)
criar = Button(text = "Adicionar evento", command = criar)
Linha 716: Linha 566:
criar.place(x = 1, y = 575)
criar.place(x = 1, y = 575)


 
#BOTAO DE PESQUISAR
 
<nowiki>#</nowiki>BOTAO DE PESQUISAR


pesquisar = Button(text = "Pesquisar evento", command = pesquisar)
pesquisar = Button(text = "Pesquisar evento", command = pesquisar)
Linha 724: Linha 572:
pesquisar.place(x = 105, y = 575)
pesquisar.place(x = 105, y = 575)


 
#BOTAO DE EDITAR
 
<nowiki>#</nowiki>BOTAO DE EDITAR


editar = Button(janela, text = "Editar", command = editar)
editar = Button(janela, text = "Editar", command = editar)
Linha 732: Linha 578:
editar.place(x = 210, y = 575)
editar.place(x = 210, y = 575)


 
#BOTAO DE DELETAR
 
<nowiki>#</nowiki>BOTAO DE DELETAR


delete= Button(janela, text = "Deletar", command = delete)
delete= Button(janela, text = "Deletar", command = delete)
Linha 740: Linha 584:
delete.place(x = 556, y = 575)
delete.place(x = 556, y = 575)


 
#BOTÃO DE EVENTOS DA SEMANA
 
<nowiki>#</nowiki>BOTÃO DE EVENTOS DA SEMANA


eventos= Button(janela, text = "Eventos da semana", command = eventosSemana)
eventos= Button(janela, text = "Eventos da semana", command = eventosSemana)
Linha 748: Linha 590:
eventos.place(x = 255, y = 575)
eventos.place(x = 255, y = 575)


<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 
 
 
 
 
 
 
 
 


                    #TABELA PRINCIPAL


                     #TABELA PRINCIPAL
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 
<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


tabela.place(x= 0, y = 0)
tabela.place(x= 0, y = 0)
Linha 769: Linha 601:


tabela['show'] = 'headings'
tabela['show'] = 'headings'


tabela.column("1", width=150, anchor='c')
tabela.column("1", width=150, anchor='c')
Linha 781: Linha 611:


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


tabela.heading("1", text="Nome")
tabela.heading("1", text="Nome")
Linha 793: Linha 621:


tabela.heading("5", text="Tipo")
tabela.heading("5", text="Tipo")


janela.mainloop()
janela.mainloop()


<nowiki>#</nowiki>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
</syntaxhighlight>

Edição atual tal como às 13h02min de 24 de julho de 2017

Escopo


  • Desenvolver uma aplicação que informe sobre eventos da cidade de Uberlândia.


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


24/07/2017

<syntaxhighlight lang="python3">

24/07/2017

from tkinter import ttk

from tkinter import *

  1. FUNÇAO PARA CRIAR UM EVENTO;
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

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()
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  1. FUNÇAO PARA EDITAR
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

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
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                    #FUNÇAO PARA PESQUISAR UM EVENTO;
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

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")
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                    #FUNÇAO PARA DELETAR UM EVENTO;
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

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()
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  1. FUNÇAO DE PESQUISAR EVENTOS DA SEMANA
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

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())
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  1. FUNÇAO PARA LISTAR EVENTOS DA SEMANA;
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

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]))
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                    #JANELA;
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

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]))
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                    #BOTOES
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  1. BOTAO DE CRIAR

criar = Button(text = "Adicionar evento", command = criar)

criar.place(x = 1, y = 575)

  1. BOTAO DE PESQUISAR

pesquisar = Button(text = "Pesquisar evento", command = pesquisar)

pesquisar.place(x = 105, y = 575)

  1. BOTAO DE EDITAR

editar = Button(janela, text = "Editar", command = editar)

editar.place(x = 210, y = 575)

  1. BOTAO DE DELETAR

delete= Button(janela, text = "Deletar", command = delete)

delete.place(x = 556, y = 575)

  1. BOTÃO DE EVENTOS DA SEMANA

eventos= Button(janela, text = "Eventos da semana", command = eventosSemana)

eventos.place(x = 255, y = 575)

  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                    #TABELA PRINCIPAL
  1. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

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

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

</syntaxhighlight>