-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdfgui.py
169 lines (161 loc) · 5.52 KB
/
pdfgui.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# -*- encoding: utf-8 -*-
"""
@File : test.py
@Time : 2021/1/11 19:12
@Author : SJY
@Email : [email protected]
@Software: PyCharm
@function: PDF合并的的界面程序,集成整个项目的多个步骤,合并,著录,添加照片,改名
"""
from tkinter import *
from tkinter.filedialog import askdirectory
from pdf import BatchSM
from rcordtoexcl import Rcord
from pdfaddimg import pdf2pic
from pdfrename import BatchRename
import threading
def selectPath(p_):
path_ = askdirectory()
p_.set(path_)
def Processsm():
print("子进程")
print("开始合并")
demo = BatchSM(path1.get(), path2.get()) # 构建合并文件类,参数为源文件夹和目标文件夹
demo.rem()
print("完成合并")
B1['command'] = record
L1['text'] = "案卷保存"
L1['bg'] = "green"
L3['text'] = "点击按钮进行著录->"
B1['text'] = "附件pdf著录"
B1['state'] = 'normal'
def Processrecord():
print("子进程")
global jnpath
print(path2.get(), "开始著录") # path2为合并后附件文件夹
demo = Rcord(ry.get(), path1.get()) # 著录实现
jnpath = demo.rcord(path2.get())
print(path2.get(), "完成著录")
L1['text'] = "毕业照片"
L1['bg'] = "yellow"
L3['text'] = "选择照片路径高亮->"
B1['command'] = addimg
B1['text'] = "添加照片"
B1['state'] = 'normal'
def Processaddimg():
print("子进程")
print("添加照片")
pdf2pic(path2.get(), path1.get(), jnpath)
print("添加照片完成")
L3['text'] = "点击按钮进行改名->"
B1['command'] = rename
L1['bg'] = 'SystemButtonFace'
B1['text'] = "改名"
B1['state'] = 'normal'
def Processrename():
print("子进程")
print("改名")
demo = BatchRename() # 重命名类
demo.rename(path2.get())
print("改名完成")
B1['command'] = root.quit
B1['text'] = "退出程序"
B1['state'] = 'normal'
def sm():
# print("开始合并")
# demo = BatchSM(path1.get(), path2.get()) # 构建合并文件类,参数为源文件夹和目标文件夹
# demo.rem()
# print("完成合并")
# B1['command'] = record
# L1['text'] = "案卷保存"
# L1['bg'] = "green"
# L3['text'] = "点击按钮进行著录->"
# B1['text'] = "附件pdf著录"
B1['text'] = "pdf合并中"
B1['state']='disabled'
t = threading.Thread(target=Processsm)
# # 守护线程
t.setDaemon(True)
t.start()
def record():
# global jnpath
# print(path2.get(), "开始著录") # path2为合并后附件文件夹
# demo = Rcord(ry.get(),path1.get()) # 著录实现
# jnpath=demo.rcord(path2.get())
# print(path2.get(), "完成著录")
# L1['text']="毕业照片"
# L1['bg']="yellow"
# L3['text']="选择照片路径高亮->"
# B1['command'] = addimg
# B1['text'] = "添加照片"
B1['text'] = "著录中"
B1['state'] = 'disabled'
t = threading.Thread(target=Processrecord)
# # 守护线程
t.setDaemon(True)
t.start()
def addimg():
# print("添加照片")
# pdf2pic(path2.get(),path1.get(),jnpath)
# print("添加照片完成")
# L3['text'] = "点击按钮进行改名->"
# B1['command'] = rename
# B1['text'] = "改名"
B1['text'] = "添加照片中"
B1['state'] = 'disabled'
t = threading.Thread(target=Processaddimg)
# # 守护线程
t.setDaemon(True)
t.start()
def rename():
# print('目标路径:%s' % p_.get())
# demo = BatchSM(path1.get(), path2.get()) # 构建合并文件类,参数为源文件夹和目标文件夹
# print(path1.get(), "pdf附件路径")
# print("改名")
# demo = BatchRename() # 重命名类
# demo.rename(path2.get())
# print("改名完成")
# B1['command'] = root.quit
# B1['text'] = "退出程序"
B1['text'] = "改名中"
B1['state'] = 'disabled'
t = threading.Thread(target=Processrename)
# # 守护线程
t.setDaemon(True)
t.start()
# e.delete(0, END) # 获取完信息,清楚掉输入框的
jnpath = '' # 卷内Excel路径
root = Tk()
root.title('学生档案电子化')
root.geometry('500x450')
path1 = StringVar()
path2 = StringVar()
ry =StringVar()
photo = PhotoImage(file='logo.png')
# ,ipadx=500,ipady=180 设置logo
Label(root, image=photo).grid(row=0, column=0, rowspan=2, columnspan=3)
# 第3行,获取原路径
L1=Label(root, text="原始路径:")
L1.grid(row=3, column=0)
e1 = Entry(root, textvariable=path1) # 输入框,内容和path1绑定
e1.grid(row=3, column=1, ipadx=60)
Button(root, text="路径选择", command=lambda: selectPath(path1)).grid(row=3, column=2)
# 第四行,获取目标路径
L2=Label(root, text="目标路径:")
L2.grid(row=4, column=0)
e2 = Entry(root, textvariable=path2) # 输入框,内容和path2绑定
e2.grid(row=4, column=1, ipadx=60)
Button(root, text="路径选择", command=lambda: selectPath(path2)).grid(row=4, column=2)
# 第5行,开始按钮
L3 =Label(root, text="选择路径然后点击->")
L3.grid(row=5, column=0)
B1=Button(root, text='pdf合并', command=sm,overrelief='sunken',width = 10,height = 2, bd=10)
B1.grid(row=5, column=1)
# Button(root, text='著录', command=record).grid(row=5, column=1)
# Button(root, text='开始pdf合并', command=lambda:(demo.rem())).grid(row=5, column=1)
Label(root, text="清空路径跳过").grid(row=5, column=2)
Label(root, text="操作人员").grid(row=6, column=0)
Entry(root, textvariable=ry).grid(row=6, column=1, ipadx=15)
# weight 设置宽度
Button(root, text='退出程序', command=root.quit).grid(row=8, column=2)
root.mainloop()