I have written an app to abstract data and save to excel sheet.
I plan to package the app using PyInstaller (which is working fine). However I am having issues referencing an image path that I am using for the title screen using Tkinter.
My thinking is the easiest way would be save the title image in a documents folder on the laptop and write the programme to reference this path for the image. However, I plan to share the app with a colleague so need the path name needs to be dynamic but have the final reference as /Documents/xxxxx.png
Below is the code to add context:
image = Image.open('MG_title.png') #this needs to be updated to include the dynamic pathname irrespective of system / user
#add function to resize Image
def resize_image(event):
new_width = event.width
new_height = event.height
image = copy_of_image.resize((new_width, new_height))
photo = ImageTk.PhotoImage(image)
label.config(image = photo)
label.image = photo #avoid garbage collection
#title page for programme
root = tk.Tk()
root.title('Manchester Giants')
root.resizable(False, False)
w = 600 # popup window width
h = 330 # popup window height
sw = root.winfo_screenwidth()
sh = root.winfo_screenheight()
x = (sw - w)/2
y = (sh - h)/2
root.geometry('%dx%d+%d+%d' % (w, h, x, y))
copy_of_image = image.copy()
photo = ImageTk.PhotoImage(image)
label = Label(root, image = photo)
label.bind('<Configure>', resize_image)
label.pack(fill=BOTH, expand = YES)