Problem compiling Tkinter program with bmp images using py2

erkidevries@pandora.be erkidevries at telenet.be
Wed Jan 25 22:20:01 EST 2006


Problem compiling Tkinter program with bmp images (using py2exe)

I have a Tkinter gui program that uses bmp as backgrounds.

The program itself works when I run from the source.
I placed the .bmp files in the same folder as the script.
I run my .py script (from IDLE) and all the backgrounds are loaded as intended.

in my script I load the images like this:

root = Tk()
im = PIL.Image.open('backg2.bmp')
photo1 = PIL.ImageTk.PhotoImage(im)

iminfo = PIL.Image.open('backg3.bmp')
photo2 = PIL.ImageTk.PhotoImage(iminfo)

imlabel = PIL.Image.open('backg4.bmp')
photo4 = PIL.ImageTk.PhotoImage(imlabel)
...

and put them on the widgets like this:

Label(win, text=message, background=rgb(150,150,120), image=photo2).pack()
...

Now, I want the same program to run as exe file on another computer, so I compiled it with py2exe.
I copied the bmp's to the same folder as my executable.
When I try to run the compiled exe i get:

Traceback (most recent call last):
  File "make_ma2.py", line 461, in ?
  File "PIL\Image.pyo", line 1745, in open
IOError: cannot identify image file

Are there specific things to take care of when compiling a tkinter program with bitmap backgrounds?

thanks,
tim






More information about the Python-list mailing list