import tkinter as tk
from tkinter import filedialog
import os
from pdf2docx import parse
def select_pdf():
global pdf_path
pdf_path = filedialog.askopenfilename(title="选择 PDF", filetypes=[("PDF Files", "*.pdf")])
pdf_label.config(text=f"Selected PDF: {os.path.basename(pdf_path)}")
def select_output():
global output_path
output_path = filedialog.asksaveasfilename(title="Select Output", defaultextension=".docx", filetypes=[("Word Files", "*.docx")])
output_label.config(text=f"Output Path: {output_path}")
def convert_pdf():
parse(pdf_path, output_path)
success_label.config(text="转换成功!!!")
root = tk.Tk()
root.title("PDF转换成Word version1-By HuangAnthony 有问题请联系445218346@qq.com")
root.geometry("400x300")
pdf_label = tk.Label(root, text="暂未选择pdf")
pdf_label.pack()
pdf_button = tk.Button(root, text="请选择要转换的PDF", command=select_pdf)
pdf_button.pack()
output_label = tk.Label(root, text="务必要为生成的文件命名新的名字")
output_label.pack()
output_button = tk.Button(root, text="请选择要保存的路径", command=select_output)
output_button.pack()
convert_button = tk.Button(root, text="转换", command=convert_pdf)
convert_button.pack()
success_label = tk.Label(root, text="")
success_label.pack()
root.mainloop()
Python+GUI将pdf转换成为word
最新推荐文章于 2025-11-20 14:25:05 发布
这是一个使用Python的tkinter库创建的简单GUI应用,它允许用户选择PDF文件并将其转换为Word文档。应用依赖于pdf2docx库来执行转换,并让用户指定输出文件的保存路径。
371

被折叠的 条评论
为什么被折叠?



