mirror of
https://github.com/UofCBaja/BajaUofCReimbursementForm.git
synced 2025-06-15 13:24:18 -06:00
IT WORKS now just need to add commments and make it as an .exe file
This commit is contained in:
parent
6eed24095d
commit
ad9eba771f
@ -1 +0,0 @@
|
|||||||
,brock,brock-XPS-13-9350,22.10.2023 00:49,file:///home/brock/.config/libreoffice/4;
|
|
Binary file not shown.
BIN
Cleaned Up Forms/Test Jensen102820231
Normal file
BIN
Cleaned Up Forms/Test Jensen102820231
Normal file
Binary file not shown.
After Width: | Height: | Size: 120 KiB |
@ -8,8 +8,8 @@ from tkinter import filedialog as fd
|
|||||||
|
|
||||||
#https://www.geeksforgeeks.org/python-gui-tkinter/
|
#https://www.geeksforgeeks.org/python-gui-tkinter/
|
||||||
|
|
||||||
receipt_file = 0
|
global receipt_file
|
||||||
|
receipt_file = ""
|
||||||
|
|
||||||
|
|
||||||
def submit_window():
|
def submit_window():
|
||||||
@ -51,20 +51,20 @@ def submit_window():
|
|||||||
open_button = Button(form_window, text='Browse...' , command=lambda:select_file(selected_file, receipt_file)).grid(row=row_counter, column=1)
|
open_button = Button(form_window, text='Browse...' , command=lambda:select_file(selected_file, receipt_file)).grid(row=row_counter, column=1)
|
||||||
row_counter += 1
|
row_counter += 1
|
||||||
|
|
||||||
Button(form_window, text='Submit', command=lambda:submitted(form_window, person_name, amount_CAD, reason, selected_file), anchor='w', justify='left').grid(row=row_counter)
|
Button(form_window, text='Submit', command=lambda:submitted(form_window, person_name, amount_CAD, reason), anchor='w', justify='left').grid(row=row_counter)
|
||||||
row_counter += 1
|
row_counter += 1
|
||||||
|
|
||||||
form_window.mainloop()
|
form_window.mainloop()
|
||||||
|
|
||||||
def submitted(window, name_submitted, total_money, reason, proof_of_payment):
|
def submitted(window, name_submitted, total_money, reason):
|
||||||
|
global receipt_file
|
||||||
current_time = datetime.now()
|
current_time = datetime.now()
|
||||||
file_submitted_name = f'{name_submitted.get()}{current_time.month:02d}{current_time.day:02d}{current_time.year}{total_money.get()}'
|
file_submitted_name = f'{name_submitted.get()}{current_time.month:02d}{current_time.day:02d}{current_time.year}{total_money.get()}'
|
||||||
#file_submitted_name = proof_of_payment.cget("text")
|
|
||||||
|
|
||||||
file_name = "Reimbursement Data.xlsx"
|
excel_file = "Reimbursement Data.xlsx"
|
||||||
subdirectory_name = "Cleaned Up Forms"
|
subdirectory_name = "Cleaned Up Forms"
|
||||||
|
|
||||||
file_path = os.path.join(os.getcwd(), subdirectory_name, file_name)
|
file_path = os.path.join(os.getcwd(), subdirectory_name, excel_file)
|
||||||
|
|
||||||
if not os.path.exists(file_path):
|
if not os.path.exists(file_path):
|
||||||
messagebox.showerror(
|
messagebox.showerror(
|
||||||
@ -74,12 +74,14 @@ def submitted(window, name_submitted, total_money, reason, proof_of_payment):
|
|||||||
window.destroy()
|
window.destroy()
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
|
|
||||||
|
file_extension = os.path.splitext(file_submitted_name)[1]
|
||||||
|
file_submit = f'{file_submitted_name}{file_extension}'
|
||||||
appended_data = {
|
appended_data = {
|
||||||
'Name': name_submitted.get(),
|
'Name': name_submitted.get(),
|
||||||
'Final Total $CAD': total_money.get(),
|
'Final Total $CAD': total_money.get(),
|
||||||
'Reason(optional)': reason.get(),
|
'Reason(optional)': reason.get(),
|
||||||
'Reimbursed (Y/N)': 'N',
|
'Reimbursed (Y/N)': 'N',
|
||||||
'Receipt File Name': file_submitted_name
|
'Receipt File Name': file_submit
|
||||||
}
|
}
|
||||||
new_data = pd.DataFrame([appended_data], index=[0])
|
new_data = pd.DataFrame([appended_data], index=[0])
|
||||||
excel_file_path = file_path
|
excel_file_path = file_path
|
||||||
@ -95,19 +97,23 @@ def submitted(window, name_submitted, total_money, reason, proof_of_payment):
|
|||||||
|
|
||||||
file_submit_path = os.path.join(os.getcwd(), subdirectory_name)
|
file_submit_path = os.path.join(os.getcwd(), subdirectory_name)
|
||||||
file_extension = os.path.splitext(file_submitted_name)[1]
|
file_extension = os.path.splitext(file_submitted_name)[1]
|
||||||
file_submit = f'{file_submitted_name}{file_extension}'
|
file_submit_path = os.path.join(file_submit_path, file_submit)
|
||||||
|
|
||||||
new_file_name = os.path.join(file_submit_path, file_submit)
|
new_file_name = os.path.join(file_submit_path, file_submit)
|
||||||
with open(receipt_file, 'r') as input_file:
|
if os.path.exists(receipt_file):
|
||||||
|
# with open(receipt_file, 'r') as input_file:
|
||||||
|
with open(receipt_file, 'rb') as input_file:
|
||||||
|
# Continue with file operations
|
||||||
# Read the contents of the input file
|
# Read the contents of the input file
|
||||||
file_contents = input_file.read()
|
file_contents = input_file.read()
|
||||||
|
|
||||||
# Open the new file for writing
|
# Open the new file for writing
|
||||||
with open(file_submit, 'w') as new_file:
|
with open(file_submit_path, 'wb') as new_file:
|
||||||
# Write the contents to the new file
|
# Write the contents to the new file
|
||||||
new_file.write(file_contents)
|
new_file.write(file_contents)
|
||||||
|
|
||||||
|
else:
|
||||||
|
messagebox.showinfo(title="error", message=f"File '{receipt_file}' does not exist.")
|
||||||
|
|
||||||
messagebox.showinfo(title='Submitted', message='You have successfully submitted')
|
messagebox.showinfo(title='Submitted', message='You have successfully submitted')
|
||||||
return
|
return
|
||||||
@ -120,17 +126,16 @@ def select_file(tk_window, selected_file):
|
|||||||
('JPEG file', '*.jpeg'),
|
('JPEG file', '*.jpeg'),
|
||||||
('JPG file', '*.jpg')
|
('JPG file', '*.jpg')
|
||||||
)
|
)
|
||||||
|
global receipt_file
|
||||||
file_name = fd.askopenfilename(
|
receipt_file = fd.askopenfilename(
|
||||||
title='Open a file',
|
title='Open a file',
|
||||||
filetypes=filetypes)
|
filetypes=filetypes)
|
||||||
if(file_name != None):
|
if(receipt_file != None):
|
||||||
messagebox.showinfo(
|
messagebox.showinfo(
|
||||||
title='Selected File',
|
title='Selected File',
|
||||||
message=file_name
|
message=receipt_file
|
||||||
)
|
)
|
||||||
receipt_file = file_name
|
formatted_file_name = os.path.basename(receipt_file)
|
||||||
formatted_file_name = os.path.basename(file_name)
|
|
||||||
tk_window["text"] = formatted_file_name
|
tk_window["text"] = formatted_file_name
|
||||||
else:
|
else:
|
||||||
messagebox.showinfo(
|
messagebox.showinfo(
|
||||||
|
BIN
Schulich Off Road Logo.jpg
Normal file
BIN
Schulich Off Road Logo.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 120 KiB |
Loading…
x
Reference in New Issue
Block a user