I already have a set of code that is similarly formatted as the one below, and that seems to work. But somehow, the image for this one isn't popping up. And they're in the same folder as the code. Def small is the code that has the image working, and def stripes is the one that is giving me an error.
from tkinter import * import tkinter as tk from tkinter import ttk def small(): s = Tk() s.title('Small Preset Shirt (Not fit to scale)') canvas = Canvas(s, width = 800, height = 100) canvas.pack() b1=ttk.Button(s,text='Click to Start', command = questions) b1.pack() photo = PhotoImage(file = 'small.png') b1.config(image=photo,compound=RIGHT) s.mainloop() def stripes(): stripes = Tk() stripes.title('Black Shirt with Stripes') canvas = Canvas(stripes, width = 800, height = 100) canvas.pack() b2=ttk.Button(stripes,text='Click to See Final Price', command = final) b2.pack() photo = PhotoImage(file = 'stripes.png') b2.config(image=photo,compound=RIGHT) stripes.mainloop()
Here is the full Traceback:
Exception in Tkinter callback Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter /__init__.py", line 1705, in __call__ return self.func(*args) File "/Users/Business/Documents/Python/small.py", line 159, in stripes b2.config(image=photo,compound=RIGHT) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter. /__init__.py", line 1485, in configure return self._configure('configure', cnf, kw) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter. /__init__.py", line 1476, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) _tkinter.TclError: image "pyimage2" doesn't exist