mirror of
https://github.com/metafy-social/python-scripts.git
synced 2025-01-18 07:17:03 +00:00
Add word to pdf converter
This commit is contained in:
parent
c58deeb8b7
commit
dc926313b0
BIN
scripts/word_to_pdf_converter/Test.docx
Normal file
BIN
scripts/word_to_pdf_converter/Test.docx
Normal file
Binary file not shown.
BIN
scripts/word_to_pdf_converter/Test.pdf
Normal file
BIN
scripts/word_to_pdf_converter/Test.pdf
Normal file
Binary file not shown.
1
scripts/word_to_pdf_converter/requirements.txt
Normal file
1
scripts/word_to_pdf_converter/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
docx2pdf==0.1.8
|
32
scripts/word_to_pdf_converter/script.py
Normal file
32
scripts/word_to_pdf_converter/script.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
import tkinter as tk
|
||||
from docx2pdf import convert
|
||||
import tkinter.ttk as ttk
|
||||
from tkinter.filedialog import askopenfile, askdirectory
|
||||
from tkinter.messagebox import showinfo
|
||||
|
||||
win = tk.Tk()
|
||||
win.title("Docx to PDF Converter")
|
||||
|
||||
|
||||
def openfile():
|
||||
file = askopenfile(filetypes=[("Word Files", "*.docx")])
|
||||
convert(file.name)
|
||||
showinfo("Done", "File Converted Successfully")
|
||||
|
||||
|
||||
def openfolder():
|
||||
folder = askdirectory()
|
||||
convert(folder)
|
||||
showinfo("Done", "Files Converted Successfully")
|
||||
|
||||
|
||||
label = tk.Label(win, text="Select File/Folder to convert: ")
|
||||
label.grid(row=0, column=0, padx=5, pady=5)
|
||||
|
||||
button1 = ttk.Button(win, text="Select File", width=30, command=openfile)
|
||||
button1.grid(row=1, column=0, padx=5, pady=5)
|
||||
|
||||
button2 = ttk.Button(win, text="Select Folder", width=30, command=openfolder)
|
||||
button2.grid(row=2, column=0, padx=5, pady=5)
|
||||
|
||||
win.mainloop()
|
Loading…
Reference in New Issue
Block a user