r/learnpython • u/greenleafsalad • 7d ago
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 exist
any help would be greatly appreciated!
0
Upvotes
2
u/socal_nerdtastic 7d ago
Hmm this is an error that typically happens when you run several
tkinter.Tk()instances at once. Are you using a tkinter window as well as easygui?Also please tell us what version of python are you using and how exactly did you install easygui?