How to use focar method in SeleniumBase

Best Python code snippet using SeleniumBase

cadastro_lacres.py

Source:cadastro_lacres.py Github

copy

Full Screen

1import subprocess2import tempfile3import tkinter4from datetime import datetime, date5from tkinter import StringVar, Label, Entry, Button, W, messagebox, DISABLED6from reportlab.graphics.barcode import code397from reportlab.lib.pagesizes import A48from reportlab.lib.units import mm9from reportlab.pdfgen import canvas10from model import Lacre11from service import LacreService12from utilitarios import NumberUtils13class CadastroLacres:14 def __init__(self, master):15 self.app_main = tkinter.Toplevel(master)16 self.app_main.title("Cadastro de Lacres")17 self.app_main.resizable(False, False)18 # self.app_main.geometry('220x400')19 self.centralizar_tela()20 self.atualizando_cadastro = False21 self.nome = StringVar()22 self.lacre_1 = StringVar()23 self.lacre_2 = StringVar()24 self.lacre_3 = StringVar()25 self.lacre_4 = StringVar()26 self.lacre_5 = StringVar()27 self.lacre_6 = StringVar()28 self.lacre_7 = StringVar()29 self.lacre_8 = StringVar()30 self.lacre_9 = StringVar()31 self.lacre_10 = StringVar()32 self.lacre_11 = StringVar()33 self.lacre_12 = StringVar()34 self.lacre_13 = StringVar()35 self.lacre_14 = StringVar()36 self.lacres_atual = None37 Label(self.app_main, text="Lacres: ", font=(None, 8, 'bold')).grid(sticky=W, column=0, row=0, padx=10)38 Label(self.app_main, text="Lacre 01: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=1, padx=10)39 self.entry_lacre_1 = Entry(self.app_main, textvariable=self.lacre_1)40 self.entry_lacre_1.grid(sticky="we", column=1, row=1, padx=(0, 10), pady=2, columnspan=2)41 self.entry_lacre_1.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))42 self.entry_lacre_1.bind('<Return>', CadastroLacres.focar_proximo_elemento)43 self.entry_lacre_1.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_1))44 Label(self.app_main, text="Lacre 02: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=2, padx=10)45 self.entry_lacre_2 = Entry(self.app_main, textvariable=self.lacre_2)46 self.entry_lacre_2.grid(sticky="we", column=1, row=2, padx=(0, 10), pady=2, columnspan=2)47 self.entry_lacre_2.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))48 self.entry_lacre_2.bind('<Return>', CadastroLacres.focar_proximo_elemento)49 self.entry_lacre_2.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_2))50 Label(self.app_main, text="Lacre 03: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=3, padx=10)51 self.entry_lacre_3 = Entry(self.app_main, textvariable=self.lacre_3)52 self.entry_lacre_3.grid(sticky="we", column=1, row=3, padx=(0, 10), pady=2, columnspan=2)53 self.entry_lacre_3.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))54 self.entry_lacre_3.bind('<Return>', CadastroLacres.focar_proximo_elemento)55 self.entry_lacre_3.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_3))56 Label(self.app_main, text="Lacre 04: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=4, padx=10)57 self.entry_lacre_4 = Entry(self.app_main, textvariable=self.lacre_4)58 self.entry_lacre_4.grid(sticky="we", column=1, row=4, padx=(0, 10), pady=2, columnspan=2)59 self.entry_lacre_4.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))60 self.entry_lacre_4.bind('<Return>', CadastroLacres.focar_proximo_elemento)61 self.entry_lacre_4.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_4))62 Label(self.app_main, text="Lacre 05: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=5, padx=10)63 self.entry_lacre_5 = Entry(self.app_main, textvariable=self.lacre_5)64 self.entry_lacre_5.grid(sticky="we", column=1, row=5, padx=(0, 10), pady=2, columnspan=2)65 self.entry_lacre_5.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))66 self.entry_lacre_5.bind('<Return>', CadastroLacres.focar_proximo_elemento)67 self.entry_lacre_5.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_5))68 Label(self.app_main, text="Lacre 06: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=6, padx=10)69 self.entry_lacre_6 = Entry(self.app_main, textvariable=self.lacre_6)70 self.entry_lacre_6.grid(sticky="we", column=1, row=6, padx=(0, 10), pady=2, columnspan=2)71 self.entry_lacre_6.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))72 self.entry_lacre_6.bind('<Return>', CadastroLacres.focar_proximo_elemento)73 self.entry_lacre_6.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_6))74 Label(self.app_main, text="Lacre 07: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=7, padx=10)75 self.entry_lacre_7 = Entry(self.app_main, textvariable=self.lacre_7)76 self.entry_lacre_7.grid(sticky="we", column=1, row=7, padx=(0, 10), pady=2, columnspan=2)77 self.entry_lacre_7.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))78 self.entry_lacre_7.bind('<Return>', CadastroLacres.focar_proximo_elemento)79 self.entry_lacre_7.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_7))80 Label(self.app_main, text="Lacre 08: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=8, padx=10)81 self.entry_lacre_8 = Entry(self.app_main, textvariable=self.lacre_8)82 self.entry_lacre_8.grid(sticky="we", column=1, row=8, padx=(0, 10), pady=2, columnspan=2)83 self.entry_lacre_8.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))84 self.entry_lacre_8.bind('<Return>', CadastroLacres.focar_proximo_elemento)85 self.entry_lacre_8.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_8))86 Label(self.app_main, text="Lacre 09: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=9, padx=10)87 self.entry_lacre_9 = Entry(self.app_main, textvariable=self.lacre_9)88 self.entry_lacre_9.grid(sticky="we", column=1, row=9, padx=(0, 10), pady=2, columnspan=2)89 self.entry_lacre_9.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))90 self.entry_lacre_9.bind('<Return>', CadastroLacres.focar_proximo_elemento)91 self.entry_lacre_9.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_9))92 Label(self.app_main, text="Lacre 10: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=10, padx=10)93 self.entry_lacre_10 = Entry(self.app_main, textvariable=self.lacre_10)94 self.entry_lacre_10.grid(sticky="we", column=1, row=10, padx=(0, 10), pady=2, columnspan=2)95 self.entry_lacre_10.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))96 self.entry_lacre_10.bind('<Return>', CadastroLacres.focar_proximo_elemento)97 self.entry_lacre_10.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_10))98 Label(self.app_main, text="Lacre 11: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=11, padx=10)99 self.entry_lacre_11 = Entry(self.app_main, textvariable=self.lacre_11)100 self.entry_lacre_11.grid(sticky="we", column=1, row=11, padx=(0, 10), pady=2, columnspan=2)101 self.entry_lacre_11.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))102 self.entry_lacre_11.bind('<Return>', CadastroLacres.focar_proximo_elemento)103 self.entry_lacre_11.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_11))104 Label(self.app_main, text="Lacre 12: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=12, padx=10)105 self.entry_lacre_12 = Entry(self.app_main, textvariable=self.lacre_12)106 self.entry_lacre_12.grid(sticky="we", column=1, row=12, padx=(0, 10), pady=2, columnspan=2)107 self.entry_lacre_12.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))108 self.entry_lacre_12.bind('<Return>', CadastroLacres.focar_proximo_elemento)109 self.entry_lacre_12.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_12))110 Label(self.app_main, text="Lacre 13: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=13, padx=10)111 self.entry_lacre_13 = Entry(self.app_main, textvariable=self.lacre_13)112 self.entry_lacre_13.grid(sticky="we", column=1, row=13, padx=(0, 10), pady=2, columnspan=2)113 self.entry_lacre_13.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))114 self.entry_lacre_13.bind('<Return>', CadastroLacres.focar_proximo_elemento)115 self.entry_lacre_13.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_13))116 Label(self.app_main, text="Lacre 14: ", font=(None, 8, 'normal')).grid(sticky=W, column=0, row=14, padx=10)117 self.entry_lacre_14 = Entry(self.app_main, textvariable=self.lacre_14)118 self.entry_lacre_14.grid(sticky="we", column=1, row=14, padx=(0, 10), pady=2, columnspan=2)119 self.entry_lacre_14.config(validate="key", validatecommand=(self.app_main.register(NumberUtils.eh_lacre), '%P'))120 self.entry_lacre_14.bind("<FocusOut>", lambda event: self.preencher_com_zeros(event, self.lacre_14))121 self.botao_salvar = Button(self.app_main, text='Salvar', command=self.salvar_ou_atualizar)122 self.botao_salvar.grid(sticky='we', column=0, row=15, padx=10, pady=10)123 self.botao_deletar = Button(self.app_main, text='Excluir', command=self.deletar, state=DISABLED)124 self.botao_deletar.grid(sticky='we', column=1, row=15, padx=10, pady=10)125 self.botao_gerar_envelope = Button(self.app_main, text='Gerar Envelope', state=DISABLED,126 command=self.gerar_envelope)127 self.botao_gerar_envelope.grid(sticky='we', column=2, row=15, padx=10, pady=10)128 @staticmethod129 def focar_proximo_elemento(event):130 event.widget.tk_focusNext().focus()131 @staticmethod132 def preencher_com_zeros(event, entry):133 texto = entry.get().strip()134 if 7 > len(texto) > 0:135 entry.set(texto.zfill(7))136 def centralizar_tela(self):137 # Gets the requested values of the height and widht.138 window_width = self.app_main.winfo_reqwidth()139 window_height = self.app_main.winfo_reqheight()140 print("Width", window_width, "Height", window_height)141 # Gets both half the screen width/height and window width/height142 position_right = int(self.app_main.winfo_screenwidth() / 2.3 - window_width / 2)143 position_down = int(self.app_main.winfo_screenheight() / 3 - window_height / 2)144 # Positions the window in the center of the page.145 self.app_main.geometry("+{}+{}".format(position_right, position_down))146 def nome_maiusculo(self, event):147 self.nome.set(self.nome.get().upper())148 def salvar_ou_atualizar(self):149 try:150 self.lacres_atual = self.preencher_lista_lacres()151 self.verificar_campos_obrigatorios()152 if self.lacres_atual is None or self.lacres_atual[0].id is None:153 self.salvar()154 else:155 self.atualizar()156 except Exception as e:157 messagebox.showerror("Erro", e)158 finally:159 self.app_main.lift()160 def verificar_campos_obrigatorios(self):161 if len(self.lacres_atual) < 4:162 raise RuntimeError("Informar pelo menos 4 lacres!")163 def preencher_lista_lacres(self):164 lacres = []165 self.preencher_com_zeros(None, self.lacre_1)166 self.preencher_com_zeros(None, self.lacre_2)167 self.preencher_com_zeros(None, self.lacre_3)168 self.preencher_com_zeros(None, self.lacre_4)169 self.preencher_com_zeros(None, self.lacre_5)170 self.preencher_com_zeros(None, self.lacre_6)171 self.preencher_com_zeros(None, self.lacre_7)172 self.preencher_com_zeros(None, self.lacre_8)173 self.preencher_com_zeros(None, self.lacre_9)174 self.preencher_com_zeros(None, self.lacre_10)175 self.preencher_com_zeros(None, self.lacre_11)176 self.preencher_com_zeros(None, self.lacre_12)177 self.preencher_com_zeros(None, self.lacre_13)178 self.preencher_com_zeros(None, self.lacre_14)179 codigo = CadastroLacres.gerar_codigo()180 self.lacres_atual = []181 if self.lacre_1.get():182 lacre = Lacre()183 lacre.codigo = codigo184 lacre.numero = self.lacre_1.get().strip()185 lacres.append(lacre)186 if self.lacre_2.get():187 lacre = Lacre()188 lacre.codigo = codigo189 lacre.numero = self.lacre_2.get().strip()190 lacres.append(lacre)191 if self.lacre_3.get():192 lacre = Lacre()193 lacre.codigo = codigo194 lacre.numero = self.lacre_3.get().strip()195 lacres.append(lacre)196 if self.lacre_4.get():197 lacre = Lacre()198 lacre.codigo = codigo199 lacre.numero = self.lacre_4.get().strip()200 lacres.append(lacre)201 if self.lacre_5.get():202 lacre = Lacre()203 lacre.codigo = codigo204 lacre.numero = self.lacre_5.get().strip()205 lacres.append(lacre)206 if self.lacre_6.get():207 lacre = Lacre()208 lacre.codigo = codigo209 lacre.numero = self.lacre_6.get().strip()210 lacres.append(lacre)211 if self.lacre_7.get():212 lacre = Lacre()213 lacre.codigo = codigo214 lacre.numero = self.lacre_7.get().strip()215 lacres.append(lacre)216 if self.lacre_8.get():217 lacre = Lacre()218 lacre.codigo = codigo219 lacre.numero = self.lacre_8.get().strip()220 lacres.append(lacre)221 if self.lacre_9.get():222 lacre = Lacre()223 lacre.codigo = codigo224 lacre.numero = self.lacre_9.get().strip()225 lacres.append(lacre)226 if self.lacre_10.get():227 lacre = Lacre()228 lacre.codigo = codigo229 lacre.numero = self.lacre_10.get().strip()230 lacres.append(lacre)231 if self.lacre_11.get():232 lacre = Lacre()233 lacre.codigo = codigo234 lacre.numero = self.lacre_11.get().strip()235 lacres.append(lacre)236 if self.lacre_12.get():237 lacre = Lacre()238 lacre.codigo = codigo239 lacre.numero = self.lacre_12.get().strip()240 lacres.append(lacre)241 if self.lacre_13.get():242 lacre = Lacre()243 lacre.codigo = codigo244 lacre.numero = self.lacre_13.get().strip()245 lacres.append(lacre)246 if self.lacre_14.get():247 lacre = Lacre()248 lacre.codigo = codigo249 lacre.numero = self.lacre_14.get().strip()250 lacres.append(lacre)251 return lacres252 def salvar(self):253 try:254 LacreService.salvar_ou_atualizar(self.lacres_atual)255 messagebox.showinfo("Sucesso", 'Lacres salvos com sucesso!')256 self.gerar_envelope()257 self.novo_cadastro()258 except Exception as e:259 raise e260 @staticmethod261 def gerar_codigo():262 data_atual = date.today().strftime("%d%m%y")263 hora_atual = datetime.now().strftime("%H%M%S")264 return '{}{}'.format(data_atual, hora_atual)265 def atualizar(self):266 try:267 if len(self.lacres_atual) > 0:268 self.lacres_atual[0].numero = self.lacre_1.get()269 if len(self.lacres_atual) > 1:270 self.lacres_atual[1].numero = self.lacre_2.get()271 if len(self.lacres_atual) > 2:272 self.lacres_atual[2].numero = self.lacre_3.get()273 if len(self.lacres_atual) > 3:274 self.lacres_atual[3].numero = self.lacre_4.get()275 if len(self.lacres_atual) > 4:276 self.lacres_atual[4].numero = self.lacre_5.get()277 if len(self.lacres_atual) > 5:278 self.lacres_atual[5].numero = self.lacre_6.get()279 if len(self.lacres_atual) > 6:280 self.lacres_atual[6].numero = self.lacre_7.get()281 if len(self.lacres_atual) > 7:282 self.lacres_atual[7].numero = self.lacre_8.get()283 if len(self.lacres_atual) > 8:284 self.lacres_atual[8].numero = self.lacre_9.get()285 if len(self.lacres_atual) > 9:286 self.lacres_atual[9].numero = self.lacre_10.get()287 if len(self.lacres_atual) > 10:288 self.lacres_atual[10].numero = self.lacre_11.get()289 if len(self.lacres_atual) > 11:290 self.lacres_atual[11].numero = self.lacre_12.get()291 if len(self.lacres_atual) > 12:292 self.lacres_atual[12].numero = self.lacre_13.get()293 if len(self.lacres_atual) > 13:294 self.lacres_atual[13].numero = self.lacre_14.get()295 # desabilitar campos vazios296 if len(self.lacres_atual) < 2:297 self.entry_lacre_2['state'] = 'disabled'298 if len(self.lacres_atual) < 3:299 self.entry_lacre_3['state'] = 'disabled'300 if len(self.lacres_atual) < 4:301 self.entry_lacre_4['state'] = 'disabled'302 if len(self.lacres_atual) < 5:303 self.entry_lacre_5['state'] = 'disabled'304 if len(self.lacres_atual) < 6:305 self.entry_lacre_6['state'] = 'disabled'306 if len(self.lacres_atual) < 7:307 self.entry_lacre_7['state'] = 'disabled'308 if len(self.lacres_atual) < 8:309 self.entry_lacre_8['state'] = 'disabled'310 if len(self.lacres_atual) < 9:311 self.entry_lacre_9['state'] = 'disabled'312 if len(self.lacres_atual) < 10:313 self.entry_lacre_10['state'] = 'disabled'314 if len(self.lacres_atual) < 11:315 self.entry_lacre_11['state'] = 'disabled'316 if len(self.lacres_atual) < 12:317 self.entry_lacre_12['state'] = 'disabled'318 if len(self.lacres_atual) < 13:319 self.entry_lacre_13['state'] = 'disabled'320 if len(self.lacres_atual) < 14:321 self.entry_lacre_14['state'] = 'disabled'322 LacreService.salvar_ou_atualizar(self.lacres_atual)323 messagebox.showinfo("Sucesso", "Lacres atualizados com sucesso!")324 self.app_main.destroy()325 except Exception as e:326 raise e327 def deletar(self):328 deletar = messagebox.askokcancel("Confirmar", "Excluir registro pernamentemente ?")329 if deletar:330 try:331 LacreService.deletar(self.lacres_atual)332 messagebox.showinfo("Sucesso", "Lacres deletados com sucesso!")333 self.app_main.destroy()334 except Exception as e:335 raise e336 def setar_campos_para_edicao(self, lacres):337 self.botao_salvar['state'] = 'disable'338 self.botao_deletar['state'] = 'normal'339 self.botao_gerar_envelope['state'] = 'normal'340 self.lacres_atual = lacres341 # setando o 4 primeiros lacres (pelo menos 4 sao obrigatorios)342 self.lacre_1.set(self.lacres_atual[0].numero)343 self.lacre_2.set(self.lacres_atual[1].numero)344 self.lacre_3.set(self.lacres_atual[2].numero)345 self.lacre_4.set(self.lacres_atual[3].numero)346 # setando os outros lacres (não obrigatorios)347 if len(self.lacres_atual) > 4:348 self.lacre_5.set(self.lacres_atual[4].numero)349 if len(self.lacres_atual) > 5:350 self.lacre_6.set(self.lacres_atual[5].numero)351 if len(self.lacres_atual) > 6:352 self.lacre_7.set(self.lacres_atual[6].numero)353 if len(self.lacres_atual) > 7:354 self.lacre_8.set(self.lacres_atual[7].numero)355 if len(self.lacres_atual) > 8:356 self.lacre_9.set(self.lacres_atual[8].numero)357 if len(self.lacres_atual) > 9:358 self.lacre_10.set(self.lacres_atual[9].numero)359 if len(self.lacres_atual) > 10:360 self.lacre_11.set(self.lacres_atual[10].numero)361 if len(self.lacres_atual) > 11:362 self.lacre_12.set(self.lacres_atual[11].numero)363 if len(self.lacres_atual) > 12:364 self.lacre_13.set(self.lacres_atual[12].numero)365 if len(self.lacres_atual) > 13:366 self.lacre_14.set(self.lacres_atual[13].numero)367 self.entry_lacre_14['state'] = 'disable'368 self.entry_lacre_13['state'] = 'disable'369 self.entry_lacre_12['state'] = 'disable'370 self.entry_lacre_11['state'] = 'disable'371 self.entry_lacre_10['state'] = 'disable'372 self.entry_lacre_9['state'] = 'disable'373 self.entry_lacre_8['state'] = 'disable'374 self.entry_lacre_7['state'] = 'disable'375 self.entry_lacre_6['state'] = 'disable'376 self.entry_lacre_5['state'] = 'disable'377 self.entry_lacre_4['state'] = 'disable'378 self.entry_lacre_3['state'] = 'disable'379 self.entry_lacre_2['state'] = 'disable'380 self.entry_lacre_1['state'] = 'disable'381 # desabilitando os campos que nao contem lacres não é possível adicionar lacres na edicao, apenas editar os382 # que ja estao lançados. o motivo de nao poder adicionar lacre é que adicionar seria um novo inserte no383 # banco, e como o código é um campo unique, isso geraria um comflito no banco de dados.384 '''385 if len(self.lacres_atual) < 14:386 self.entry_lacre_14['state'] = 'disable'387 if len(self.lacres_atual) < 13:388 self.entry_lacre_13['state'] = 'disable'389 if len(self.lacres_atual) < 12:390 self.entry_lacre_12['state'] = 'disable'391 if len(self.lacres_atual) < 11:392 self.entry_lacre_11['state'] = 'disable'393 if len(self.lacres_atual) < 10:394 self.entry_lacre_10['state'] = 'disable'395 if len(self.lacres_atual) < 9:396 self.entry_lacre_9['state'] = 'disable'397 if len(self.lacres_atual) < 8:398 self.entry_lacre_8['state'] = 'disable'399 if len(self.lacres_atual) < 7:400 self.entry_lacre_7['state'] = 'disable'401 if len(self.lacres_atual) < 6:402 self.entry_lacre_6['state'] = 'disable'403 if len(self.lacres_atual) < 5:404 self.entry_lacre_5['state'] = 'disable'405 '''406 @staticmethod407 def criar_string_lacres(lista_lacres):408 cont = 0409 string = ""410 for lacre in lista_lacres:411 string += lacre412 if cont < len(lista_lacres) - 1:413 string += '/'414 cont += 1415 return string416 def gerar_envelope(self):417 try:418 tamanho_lista = len(self.lacres_atual)419 f = tempfile.NamedTemporaryFile()420 nome_pdf = f.name + '.pdf'421 pdf = canvas.Canvas(nome_pdf, pagesize=A4)422 y = 700423 x_inicial = 40 * mm424 pdf.setTitle(nome_pdf)425 pdf.setFont("Helvetica-Bold", 22)426 pdf.drawString(x_inicial, y, 'Lacres')427 y = y - 25428 pdf.setFont("Helvetica-Bold", 16)429 pdf.drawString(x_inicial, y, "Quantidade: {}".format(tamanho_lista))430 y = y - 25431 codigo = self.lacres_atual[0].codigo432 pdf.setFont("Helvetica-Bold", 16)433 pdf.drawString(x_inicial, y, 'Código: {}'.format(codigo))434 pdf.setFont("Helvetica", 12)435 i = 0436 f = 4437 continuar = True438 lista_lacres = []439 for lacre in self.lacres_atual:440 lista_lacres.append(lacre.numero)441 while continuar:442 y -= 25443 s = ' / '.join(lista_lacres[i:f])444 pdf.drawString(x_inicial, y, s)445 i += 4446 f += 4447 if i > tamanho_lista:448 continuar = False449 bc = code39.Extended39(codigo, barWidth=0.5 * mm, barHeight=20 * mm)450 y = y - 70451 bc.drawOn(pdf, x_inicial - 20, y)452 pdf.setFont("Helvetica-Bold", 14)453 linha = '--------------------------------------------------------------------------------------------------'454 pdf.drawString(x_inicial - 50, 380, linha)455 # now create the actual PDF456 pdf.showPage()457 pdf.save()458 subprocess.Popen([nome_pdf], shell=True)459 except Exception as e:460 print('erro' + str(e))461 def novo_cadastro(self):462 self.entry_lacre_1.focus()463 self.lacre_1.set('')464 self.lacre_2.set('')465 self.lacre_3.set('')466 self.lacre_4.set('')467 self.lacre_5.set('')468 self.lacre_6.set('')469 self.lacre_7.set('')470 self.lacre_8.set('')471 self.lacre_9.set('')472 self.lacre_10.set('')473 self.lacre_11.set('')474 self.lacre_12.set('')475 self.lacre_13.set('')476 self.lacre_14.set('')477 self.lacres_atual = None478if __name__ == '__main__':479 '''480 lacres = ["1234567", "1234567", "1234567", "1234567", "1234567", "1234567", "1234567", "1234567", "1234567",481 "1234567", "1234567", "1234567", "1234567", "1234567"]482 CadastroLacres.gerar_pdf(lacres)483 '''484 app_main = tkinter.Tk()485 CadastroLacres(app_main)...

Full Screen

Full Screen

URI-2961.py

Source:URI-2961.py Github

copy

Full Screen

1n = int(input())2focar = [0, 0, 0, 0]3for i in range(n):4 palpites = []5 vencedores = []6 ent = input()7 for i in range(4):8 ent = input()9 palpites.append(ent)10 ent = input()11 for i in range(4):12 ent = input()13 vencedores.append(ent)14 for i in range(len(palpites)):15 if palpites[i] == vencedores[i]:16 focar[i] += 117# print(focar)18output = ""19m = focar[0]20for i in range(len(focar)):21 if focar[i] < focar[m]:22 m = focar[i]23for i in range(len(focar)):24 if focar[i] == m:25 output += str(i + 1) + " "...

Full Screen

Full Screen

diario_federal.py

Source:diario_federal.py Github

copy

Full Screen

1#dia 17/05/222# hoje eu começo a escrever meu diário, meu objetivo é te-lô como registro da minha jornada de3# "luto" por desistir da PRF e focar no meu novo objetivo de ser Perito Federal. Tenho muitas dúvidas4# se tomei a decisão certa, e me pergunto isso todos os dias. Quero me manter focado e acreditando5# que vai dar certo. Hoje estou mais triste e desanimado que o normal, mas vou focar nos estudos...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful