Building a script for controlling components at the house. As an example I have 4 buttons. I am trying to figure out how I can edit the button images as a user. so the user can assign an image to a button. I have a folder of pre designed images the user can select from. I figured out how to open a filesystem, chose a photo and place that photo into a random button but I am not really sure where to go from here or if I am even going in the right direction. I am new so, example code would be very helpful with the explanation. thanks
import tkinter as tk
from tkinter import *
from PIL import ImageTk, Image
from tkinter.filedialog import askopenfilename
my_w = tk.Tk()
my_w.geometry("800x480")
my_w.title('SELECT PHOTOS')
l1 = tk.Label(my_w, text='EDIT BUTTON IMAGES')
l1.pack()
b = tk.Button(my_w, text='IMAGES', command=lambda:upload_file())
b.pack()
f1 = tk.Frame(my_w)
b1 = tk.Button(f1, text="button 1")
b2 = tk.Button(f1, text="button 2")
b3 = tk.Button(f1, text="button 3")
b4 = tk.Button(f1, text="button 4")
b1.grid(row=0, column=0, padx=5)
b2.grid(row=0, column=1, padx=5)
b3.grid(row=0, column=2, padx=5)
b4.grid(row=0, column=3, padx=5)
f1.pack(pady=30)
def upload_file():
f_types=[('png Files', '*.png'), ('Jpg Files', '*.png')]
filename=tk.filedialog.askopenfilename(filetypes=f_types)
img=Image.open(filename)
img=img.resize((100, 100))
img=ImageTk.PhotoImage(img)
e1=tk.Button(my_w)
e1.pack()
e1.image=img
e1['image'] = img
my_w.mainloop()