-
Notifications
You must be signed in to change notification settings - Fork 0
/
USC Cover Page Tool.py
293 lines (250 loc) · 16.1 KB
/
USC Cover Page Tool.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
import tkinter
import base64
import tempfile
import os
import threading
import time
import calendar
import datetime
from tkinter import ttk
from tkinter import filedialog
from docx import Document
from docx.shared import Pt
from docx.shared import Inches, Cm
from docx.enum.text import WD_LINE_SPACING
from docx.enum.text import WD_ALIGN_PARAGRAPH
from calendar_widget import Calendar
# Create a temporary image file
icon = "AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAgBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGJiYg12dnYrdnZ2K3Z2dit2dnYrdnZ2K3Z2dit2dnYrdnZ2K3Z2dit2dnYrdnZ2K3Z2dit2dnYrdnZ2K3Z2ditwcHArcHBwK3BwcCtwcHAr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AAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAwAAA/8AAAH/AAAB/wAAAP8AAAB/AAAAPwAAAB8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAc="
# Decode the Base64 string
decoded_bytes = base64.b64decode(icon)
with tempfile.NamedTemporaryFile(delete=False, suffix=".ico") as temp_file:
# Do whatever you need with the temporary file
temp_file.write(decoded_bytes)
iconpath = temp_file.name
#define main tkinter window
root = tkinter.Tk()
root.geometry('800x580')
root.title("USC Cover Page Tool")
root.iconbitmap(iconpath)
os.remove(iconpath)
font_style = ("Arial CE", 10)
style_select_label = tkinter.Label(root, text="Heading Style:", font=font_style).place(x=30, y=15)
Style_List = ["USC 1", "USC 2"]
style_var = tkinter.StringVar(root)
style_var.set(Style_List[0])
style_menu = tkinter.OptionMenu(root, style_var, *Style_List)
style_menu.place(x=118, y=10)
style_menu.config(width=12, font=('Arial CE', 10))
#Input Assignment Name
assignment_name_label = tkinter.Label(root, text="Assignment Name:", font=font_style).place(x=30, y=50)
assignment_name = tkinter.Entry(root, width=50)
assignment_name.place(x=30, y=70)
#Input Course Acronym and Number
acronymn_label = tkinter.Label(root, text="Course Acronym and Number:", font=font_style).place(x=30, y=100)
acronymn = tkinter.Entry(root, width=50)
acronymn.place(x=30, y=120)
#Input Course Name
course_name_label = tkinter.Label(root, text="Course Name:", font=font_style).place(x=30, y=150)
course_name = tkinter.Entry(root, width=50)
course_name.place(x=30, y=170)
#Input Instructor Title
instructor_title_label = tkinter.Label(root, text="Instructor Title:", font=font_style).place(x=30, y=200)
instructor_title = tkinter.Entry(root, width=50)
instructor_title.place(x=30, y=220)
#Input Student Name
student_name_label = tkinter.Label(root, text="Student Name:", font=font_style).place(x=30, y=250)
student_name = tkinter.Entry(root, width=50)
student_name.place(x=30, y=270)
def create_date(day):
st = "ˢᵗ"
nd = "ⁿᵈ"
rd = "ʳᵈ"
th = "ᵗʰ"
if (day == 1) or (day == 21) or (day == 31):
date_def = str(day) + st
elif (day == 2) or (day == 22):
date_def = str(day) + nd
elif (day == 3) or (day == 23):
date_def = str(day) + rd
else:
date_def = str(day) + th
return date_def
# Date Selection
date_select_label = tkinter.Label(root, text="Select Date:", font=font_style).place(x=30, y=300)
Calendar = Calendar(root, pos_x=30, pos_y=320, background='gray50', arrow_thickness=1)
#Building Document Preview
preview = tkinter.Canvas(root, width=425, height=550, background="white", bd=3, relief='sunken')
preview.place(x=360, y=10)
global infinity
infinity = True
def pull_form_data(startup=True):
while infinity:
try:
preview.delete("all")
assignment = assignment_name.get()
course_acronymn = acronymn.get()
course_title = course_name.get()
instructor = instructor_title.get()
name = student_name.get()
date = Calendar.getdate()
dates = date.split("-")
if dates[0] != "None":
startup = False
if startup:
current_date = datetime.date.today()
current_day = current_date.day
date_def = create_date(int(current_day))
else:
current_day = dates[0]
if current_day == "None":
date_def = ""
else:
date_def = create_date(int(current_day))
month_num = int(dates[1])
month_def = calendar.month_name[month_num]
year_def = dates[2]
# set dates for global use
global day, month, year
day = date_def
month = month_def
year = year_def
#Check Style Value
style = style_var.get()
if style == "USC 2":
preview.create_text(215, 60, text="ANDREWS UNIVERSITY AND EXTENSION PROGRAMS\n"
" UNIVERSITY OF THE SOUTHERN CARIBBEAN\n"
" P.O. BOX 175, PORT OF SPAIN",
font=("Times New Roman", 8))
elif style == "USC 1":
preview.create_text(215, 60, text=" UNIVERSITY OF THE SOUTHERN CARIBBEAN\n"
"MARACAS ROYAL RD, ST. JOSEPH, TRINIDAD, W.I.\n"
" P.O. BOX 175, PORT OF SPAIN",
font=("Times New Roman", 8))
preview.create_text(215, 190, text=assignment, font=("Times New Roman", 8))
preview.create_text(215, 280, text=" An Assignment\n"
" Presented in Partial Fulfilment\n"
"of the Requirements for the Course",
font=("Times New Roman", 8))
preview.create_text(215, 308, text=(course_acronymn + ": " + course_title), font=("Times New Roman", 8))
preview.create_text(215, 360, text=("INSTRUCTOR: " + instructor), font=("Times New Roman", 8))
preview.create_text(215, 400, text="By", font=("Times New Roman", 8))
preview.create_text(215, 420, text=name, font=("Times New Roman", 8))
preview.create_text(215, 440, text=(date_def + " " + month_def + " " + year_def), font=("Times New Roman", 8))
preview.create_text(345, 490, text="Approval.............................", font=("Times New Roman", 8))
time.sleep(0.05)
preview.update()
except:
pass
def create_word_doc(doc_title):
document = Document()
#Set Document Author
core_properties = document.core_properties
core_properties.author = str(student_name.get())
core_properties.comments = "University of the Southern Caribbean"
#Set Margins
sections = document.sections
for section in sections:
section.top_margin = Cm(2.54)
section.bottom_margin = Cm(2.54)
section.left_margin = Cm(2.54)
section.right_margin = Cm(2.54)
style = document.styles['Normal']
font = style.font
font.name = 'Times New Roman'
font.size = Pt(12)
style = style_var.get()
if style == "USC 2":
address = "ANDREWS UNIVERSITY AND EXTENSION PROGRAMS\n" \
"UNIVERSITY OF THE SOUTHERN CARIBBEAN\n" \
"P.O. BOX 175, PORT OF SPAIN\n\n\n\n\n\n\n\n\n"
elif style == "USC 1":
address = "UNIVERSITY OF THE SOUTHERN CARIBBEAN" \
"\n MARACAS ROYAL RD, ST. JOSEPH, TRINIDAD, W.I.\n" \
"P.O. BOX 175, PORT OF SPAIN\n\n\n\n\n\n\n\n\n"
USC_Address = document.add_paragraph(address)
paragraph_format = USC_Address.paragraph_format
paragraph_format.alignment = WD_ALIGN_PARAGRAPH.CENTER
paragraph_format.space_after = 0
paragraph_format.space_before = 0
paragraph_format.line_spacing_rule = WD_LINE_SPACING.SINGLE
USC_Address.style = document.styles['Normal']
Assignment = assignment_name.get()
Assignment_Title = document.add_paragraph(Assignment + "\n\n\n\n\n\n\n\n\n")
paragraph_format = Assignment_Title.paragraph_format
paragraph_format.alignment = WD_ALIGN_PARAGRAPH.CENTER
paragraph_format.space_after = 0
paragraph_format.space_before = 0
paragraph_format.line_spacing_rule = WD_LINE_SPACING.SINGLE
Assignment_Title.style = document.styles['Normal']
Assignment_Declaration = document.add_paragraph("An Assignment\n"
"Presented in Partial Fulfilment\n"
"of the Requirements for the Course")
paragraph_format = Assignment_Declaration.paragraph_format
paragraph_format.alignment = WD_ALIGN_PARAGRAPH.CENTER
paragraph_format.space_after = 0
paragraph_format.space_before = 0
paragraph_format.line_spacing_rule = WD_LINE_SPACING.SINGLE
Assignment_Declaration.style = document.styles['Normal']
Course_Acronym = acronymn.get()
Course_Name = course_name.get()
Course_Declaration = document.add_paragraph(Course_Acronym + ": " + Course_Name + "\n\n\n\n\n")
paragraph_format = Course_Declaration.paragraph_format
paragraph_format.alignment = WD_ALIGN_PARAGRAPH.CENTER
paragraph_format.space_after = 0
paragraph_format.space_before = 0
paragraph_format.line_spacing_rule = WD_LINE_SPACING.SINGLE
Course_Declaration.style = document.styles['Normal']
Instructor = instructor_title.get()
Course_Instructor = document.add_paragraph("INSTRUCTOR: " + Instructor + "\n\n\n")
paragraph_format = Course_Instructor.paragraph_format
paragraph_format.alignment = WD_ALIGN_PARAGRAPH.CENTER
paragraph_format.space_after = 0
paragraph_format.space_before = 0
paragraph_format.line_spacing_rule = WD_LINE_SPACING.SINGLE
Course_Instructor.style = document.styles['Normal']
Student_Name = student_name.get()
global day, month, year
Month_Due = month
Year_Due = year
Date_Due = day
Student_Declaration = document.add_paragraph("By\n\n" + Student_Name + "\n\n" + Date_Due + " " +
Month_Due + " " + Year_Due + "\n\n\n\n\n")
paragraph_format = Student_Declaration.paragraph_format
paragraph_format.alignment = WD_ALIGN_PARAGRAPH.CENTER
paragraph_format.space_after = 0
paragraph_format.space_before = 0
paragraph_format.line_spacing_rule = WD_LINE_SPACING.SINGLE
Student_Declaration.style = document.styles['Normal']
Approval_Declaration = document.add_paragraph("Approval............................")
paragraph_format = Approval_Declaration.paragraph_format
paragraph_format.alignment = WD_ALIGN_PARAGRAPH.RIGHT
paragraph_format.space_after = 0
paragraph_format.space_before = 0
paragraph_format.line_spacing_rule = WD_LINE_SPACING.SINGLE
Approval_Declaration.style = document.styles['Normal']
document.save(doc_title)
def open_save_dialog():
filename = filedialog.asksaveasfilename(defaultextension=".docx",
filetypes=[("Microsoft Word Document", "*.docx"), ("All files", "*.*")])
# Do something with the selected filename, like saving data to the file
if filename:
create_word_doc(filename)
# Create a button to trigger the save dialog
save_button = tkinter.Button(root, text="Save", width=10, command=open_save_dialog, font=font_style, background="gray80")
save_button.place(x=180, y=550, anchor='center')
#exit saftely
def safety():
global infinity
infinity = False
time.sleep(0.1)
preview.delete("all")
preview.create_text(215, 280, text="EXITING...", font=("Times New Roman", 12))
preview.update()
time.sleep(1)
root.destroy()
root.protocol('WM_DELETE_WINDOW', safety)
#call preview animation
threading.Thread(target=pull_form_data(), daemon=True).start()
# call mainloop for persistence
root.mainloop()