r/learnpython • u/greenleafsalad • Sep 02 '26
Help making image appear in easygui msgbox
hi there - i'm trying to add a small image to an easygui msgbox, but i think i'm probably not importing it properly. what i have at the beginning is:
import easygui
image_1 = "skull_tiny.png"and then a bunch of stuff (it's a short choose-your-own-adventure story) and then i would like to add the image at the point the player dies, like so:
if answer5 == "turn":
easygui.msgbox("You choose to turn and find yourself face to face with an enormous dinosaur. The last thing you see before you die is two rows of sharp teeth coming towards you from above.", image = image_1, ok_button = "Game over.")the code works fine without the image, but as soon as i add it, all that comes up when you get to that part is a small empty box, with no clickable options. the image is in the same folder as the .py file, but maybe i need to put in the full path?
this is what's in the console:
File ~\AppData\Local\spyder-6\envs\spyder-runtime\Lib\tkinter__init__.py:1711, in Misc._configure(self, cmd, cnf, kw)
1709 if isinstance(cnf, str):
1710 return self._getconfigure1(_flatten((self._w, cmd, '-'+cnf)))
-> 1711 self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
TclError: image "pyimage4" doesn't existany help would be greatly appreciated!
View all comments
Show parent comment
1
u/greenleafsalad Sep 03 '26
thanks for replying! afaik i wasn't using a tkinter window, but i could be mistaken. i was using the same install of spyder that i installed last year for a programming class, and i can't remember how i originally installed easygui, but i ran the program from vs code and it works now, so maybe it had something to do with that?
for now, problem solved. in the future maybe there'll come a time where i'll want/need to understand exactly what was wrong, but for right now that's above my pay grade 🥲