I meant something like this:
I changed the car_list file to make each Car instance's image attribute as a string of the image filename. Like so:
# ... title = "Golf Mk1 (A1/Typ 17, 1974-1984)" info = """\ In May, 1974 Volkswagen presented the first-generation Golf as a modern front wheel drive long-range replacement of the Beetle. """ image = 'Golf_Mk1.jpg' # just the image filename # create the class instance and append to the list car_list.append(Car(title, info, image)) # ...
This means that you can remove all the imports for tk and PIL at the top of your car_list script, and also delete the
root = tk.Tk() part.
Then, in the main file, I changed the show function so that it creates a Tk image of the filename upon showing it. Like this:
def show(car_num): global car_list global screen global info # delete any previous picture, title and info screen.delete(0.0, 'end') info.delete(0.0, 'end') # create picture heading s = car_list[car_num].title + '\n\n' screen.insert('1.0', s) # insert picture img = ImageTk.PhotoImage(file=car_list[car_num].image) # make image upon showing screen.image_create('2.0', image=img) # changed to use the newly created image # insert information about the picture info.insert('1.0', car_list[car_num].info) # ...
I'm also re-attaching this modified version so that you can see the changes better.