GerOrdensGerente.py 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. from tkinter import *
  2. from tkinter import ttk
  3. from tkinter import messagebox
  4. from tkinter.font import BOLD
  5. import TabOrd as ordem
  6. class ver_Ordens():
  7. def __init__(self):
  8. self.janelaVerOrd = Tk()
  9. self.janelaVerOrd.title('Gerenciar Ordem')
  10. self.janelaVerOrd.geometry('1600x900')
  11. self.janelaVerOrd.config(bg='#484848')
  12. self.janelaVerOrd.state('zoomed')
  13. self.janelaVerOrd.iconbitmap('automotivo.ico')
  14. # ==========| SEÇÕES | =========== #
  15. self.frameTop = Frame(self.janelaVerOrd, bg='#484848')
  16. self.frameMid = Frame(self.janelaVerOrd, bg='#484848')
  17. # self.frameBot = Frame(self.janelaVerOrc, bg='#484848')
  18. self.frameTop.pack(pady=(20, 0))
  19. self.frameMid.pack()
  20. # self.frameBot.pack()
  21. self.wrapper_trv = LabelFrame(
  22. self.frameMid, text=' Ordens Cadastradas ', bg='#484848', fg='white', font=('Roboto', 10, BOLD))
  23. self.wrapper_aprov = LabelFrame(
  24. self.frameMid, text=' Gerenciar ', bg='#484848', fg='white', font=('Roboto', 10, BOLD))
  25. self.wrapper_filtrar = LabelFrame(
  26. self.frameMid, text=' Pesquisar ', bg='#484848', fg='white', font=('Roboto', 10, BOLD))
  27. self.frameRodape = Frame(self.janelaVerOrd, bg='#484848')
  28. self.wrapper_trv.pack(fill='both', expand='yes', padx=20, pady=10)
  29. self.wrapper_aprov.pack(fill='both', expand='yes', padx=20, pady=10)
  30. self.wrapper_filtrar.pack(fill='both', expand='yes', padx=20, pady=10)
  31. self.frameRodape.pack(fill='both', expand='yes', padx=20, pady=10)
  32. # =========| TOP |========= #
  33. self.titulo = Label(self.frameTop, text='Ordens de Serviços',
  34. bg='#484848', fg='white', font=('Roboto', 20, BOLD))
  35. self.titulo.pack(padx=20, pady=10)
  36. # ========| MIDDLE |======== #
  37. # =======| TREEVIEW |======== #
  38. self.cabecalho = ('#', 'cliente', 'carro', 'cpf_cliente',
  39. 'mecanico', 'cpf_mec', 'valor', 'descricao', 'status')
  40. self.trv = ttk.Treeview(
  41. self.wrapper_trv, selectmode='browse', columns=self.cabecalho, show='headings')
  42. self.trv.column('#', width=10)
  43. self.trv.column('cliente', width=150, anchor='center')
  44. self.trv.column('carro', width=150, anchor='center')
  45. self.trv.column('cpf_cliente', width=150, anchor='center')
  46. self.trv.column('mecanico', width=150, anchor='center')
  47. self.trv.column('cpf_mec', width=150, anchor='center')
  48. self.trv.column('valor', width=150, anchor='center')
  49. self.trv.column('descricao', width=300)
  50. self.trv.column('status', width=100, anchor='center')
  51. self.trv.heading('#', text='#')
  52. self.trv.heading('cliente', text='Cliente')
  53. self.trv.heading('carro', text='Carro')
  54. self.trv.heading('cpf_cliente', text='CPF Cliente')
  55. self.trv.heading('mecanico', text='Mecânico')
  56. self.trv.heading('cpf_mec', text='CPF Mec')
  57. self.trv.heading('valor', text='Valor R$')
  58. self.trv.heading('descricao', text='Descrição do Serviço')
  59. self.trv.heading('status', text='Status')
  60. self.trv.bind('<Double 1>', self.pegar_linhaBind)
  61. self.trv.pack(pady=10)
  62. self.popular()
  63. # =========| GERAR ORDEM DE SERVIÇO |======== #
  64. self.btn_Concluir = Button(
  65. self.wrapper_aprov, text='Concluir', command=self.concluir, bg='#484848', fg='white')
  66. self.btn_Excluir = Button(
  67. self.wrapper_aprov, text='Excluir', command=self.excluir, bg='#484848', fg='white')
  68. self.btn_Concluir.pack(side='left', padx=(30, 0), pady=10, ipadx=20)
  69. self.btn_Excluir.pack(side='left', padx=30, pady=10, ipadx=20)
  70. # =========| CAMPO DE BUSCA |======== #
  71. self.lblChave = Label(self.wrapper_filtrar,
  72. text='Palavra-chave', bg='#484848', fg='white')
  73. self.lblChave.pack(side='left', padx=6, pady=10)
  74. self.entBusca = Entry(self.wrapper_filtrar, textvariable='filtro')
  75. self.entBusca.pack(side='left', padx=6, pady=10, ipadx=15)
  76. self.btn_procurar = Button(
  77. self.wrapper_filtrar, text='Procurar', command=self.procurar, bg='#484848', fg='white')
  78. self.btn_mostrar = Button(
  79. self.wrapper_filtrar, text='Mostrar Todos', command=self.popular, bg='#484848', fg='white')
  80. self.btn_procurar.pack(side='left', padx=6, pady=10, ipadx=20)
  81. self.btn_mostrar.pack(side='left', padx=6, pady=10, ipadx=20)
  82. # ===========| BOTTOM |=========== #
  83. # ===========| VOLTAR |=========== #
  84. self.btn_voltar = Button(
  85. self.frameRodape, text='Voltar', command=self.voltar, bg='#484848', fg='white')
  86. self.btn_voltar.pack(side='right', padx=6, pady=10, ipadx=30)
  87. self.varDeArmaz = ''
  88. self.btn_voltar.bind("<Enter>", self.hoverIn3)
  89. self.btn_voltar.bind("<Leave>", self.hoverOut)
  90. self.btn_Excluir.bind("<Enter>", self.hoverIn3)
  91. self.btn_Excluir.bind("<Leave>", self.hoverOut)
  92. self.btn_Concluir.bind("<Enter>", self.hoverIn1)
  93. self.btn_Concluir.bind("<Leave>", self.hoverOut)
  94. mainloop()
  95. # ===========| FUNÇÕES |============ #
  96. def pegar_linhaBind(self, event):
  97. return self.pegar_linha()
  98. def pegar_linha(self):
  99. for item in self.trv.selection():
  100. self.id = self.trv.item(item, 'values')
  101. ident = self.id
  102. self.varDeArmaz = ident
  103. def popular(self):
  104. self.trv.delete(*self.trv.get_children())
  105. for i in ordem.populate(self):
  106. self.trv.insert('', 'end', values=i)
  107. def status(self):
  108. state = 'Finalizada'
  109. tupla = self.varDeArmaz
  110. lista1 = []
  111. for i in tupla:
  112. lista1.append(i)
  113. idordem = lista1[0]
  114. ordem.update(state, idordem)
  115. self.popular()
  116. self.varDeArmaz = ''
  117. def concluir(self):
  118. return self.status()
  119. def excluir(self):
  120. tupla = self.varDeArmaz
  121. pickingID = []
  122. for i in tupla:
  123. pickingID.append(i)
  124. idordem = pickingID[0]
  125. ordem.delete(idordem)
  126. self.popular()
  127. self.varDeArmaz = ''
  128. def procurar(self):
  129. chave = self.entBusca.get()
  130. self.trv.delete(*self.trv.get_children())
  131. for i in ordem.filtrar(chave):
  132. self.trv.insert('', END, values=i)
  133. def voltar(self):
  134. self.janelaVerOrd.destroy()
  135. return
  136. def hoverIn1(self, event): # verde
  137. event.widget.config(bg="#3CB371", fg="white", relief=GROOVE)
  138. def hoverIn3(self, event): # vermelho
  139. event.widget.config(bg="#8B0000", fg="white", relief=GROOVE)
  140. def hoverOut(self, event):
  141. event.widget.config(bg='#484848', fg="#e1e3db", relief=RAISED)
  142. app = ver_Ordens()