text="Todas las imagenes", command=lambda: save_all(all_images), height=1, width=15) save_btn = Button(root, text="Guardar imagen", command=lambda: save_image(all_images[img_idx[-1]]), height=1, width=15) copyText_btn.grid(row=3, column=0) saveAll_btn.grid(row=3, column=1) save_btn.grid(row=3, column=2) display_logo('img/logo.png', 0, 0) # instruction instruction = Label(root, text="Selecciona un PDF", bg="white") instruction.grid(column=2, row=0, sticky=SE, padx=75, pady=5) # browse browse_text = StringVar() browse_btn = Button(root, textvariable=browse_text, command=lambda: open_file(), bg="#20bebe", fg="white", height=1, width=15) browse_text.set("Browse")
def open_file(): browse_text.set("loading...") file = askopenfile(parent=root, mode='rb', filetypes=[("Pdf file", "*.pdf")]) if file: read_pdf = PyPDF2.PdfFileReader(file) page = read_pdf.getPage(0) page_content = page.extractText() #page_content = page_content.encode('cp1252') page_content = page_content.replace('\u2122', "'") #show text box on row 2 col 0 display_textbox(page_content, 2, 0, root) #reset the button text back to Browse browse_text.set("Browse") display_logo('logo.png', 0, 0) #instructions instructions = Label(root, text="Select a PDF file", font=("Raleway", 10), bg="white") instructions.grid(column=2, row=0, sticky=SE, padx=75, pady=5) #browse button browse_text = StringVar() browse_btn = Button(root, textvariable=browse_text, command=lambda:open_file(), font=("Raleway",12), bg="#20bebe", fg="white", height=1, width=15) browse_text.set("Browse") browse_btn.grid(column=2, row=1, sticky=NE, padx=50) root.mainloop()
root, text="save image", command=lambda: save_image(all_images[img_idx[-1]]), font=("shanti", 10), height=1, width=15, ) # place buttons on grid copyText_btn.grid(row=3, column=0) saveAll_btn.grid(row=3, column=1) save_btn.grid(row=3, column=2) # BEGIN INITIAL APP COMPONENTS display_logo("logo.png", 0, 0) # instructions instructions = Label(root, text="Select a PDF file", font=("Raleway", 10), bg="white") instructions.grid(column=2, row=0, sticky=SE, padx=75, pady=5) # browse button browse_text = StringVar() browse_btn = Button( root, textvariable=browse_text, command=lambda: open_file(), font=("Raleway", 12),