-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (27 loc) · 813 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from tkinter import *
from tkinter import filedialog
from PyPDF2 import PdfMerger
pdf = PdfMerger()
window = Tk()
text = Text(window, height=250, width=250)
files = []
def open_file():
name = filedialog.askopenfilename()
if name != '' and name not in files:
text.insert(END, name)
files.append(name)
def merge_files():
for f in files:
pdf.append(f)
with open("result.pdf", "wb") as new_file: # write binary
pdf.write(new_file)
if __name__ == '__main__':
window.wm_minsize(300, 300)
window.wm_maxsize(300, 300)
window.wm_title("PDF Merger")
button = Button(text="Select PDF", command=open_file)
button.pack()
button_merge = Button(text="Merge PDF", command=merge_files)
button_merge.pack()
text.pack()
window.mainloop()