Hi,
The problem seems to be the following... "room_image.jpg"...from what I know about Tkinter it only accepts the .gif type of images. There are one or two free image converters on the internet that convert a whole plethora of images such as .jpg etc to the .gif type of image format.
If you want a free image converter try here http://www.homeplansoftware.com/imgconv.htm
I've used it and it works just fine.
fredzik.
fredzik
Junior Poster in Training
55 posts since Feb 2007
Reputation Points: 10
Solved Threads: 5
P.S.
As others may want to test your code and send you help, please email your code again and in the "Reply to Thread" Message box do the following:
At the end of your code, after you've pasted it in, type this [/code] including brackets.
Before you paste in your code, type this [code=Python] including brackets.
The reason I've done this upside down was because the Message box kept on thinking I was trying to put some code in.
Anyway, good luck with your replies:icon_smile:.
fredzik.
fredzik
Junior Poster in Training
55 posts since Feb 2007
Reputation Points: 10
Solved Threads: 5
Here is the use of the Python Image Library, works well with Tkinter, to get image formats other than .gif ...
# use a Tkinter label as a panel/frame with a background image
# note that Tkinter only reads gif and ppm images
# use the Python Image Library (PIL) for other image formats
# free from <a href="http://www.pythonware.com/products/pil/index.htm">http://www.pythonware.com/products/pil/index.htm</a>
# give Tkinter a namespace to avoid conflicts with PIL
# (they both have a class named Image)
import Tkinter as tk
from PIL import Image, ImageTk
root = tk.Tk()
root.title('background image')
# pick an image file you have .bmp .jpg .gif. .png
# load the file and covert it to a Tkinter image object
imageFile = "Flowers.jpg"
image1 = ImageTk.PhotoImage(Image.open(imageFile))
# get the image size
w = image1.width()
h = image1.height()
# position coordinates of root 'upper left corner'
x = 0
y = 0
# make the root window the size of the image
root.geometry("%dx%d+%d+%d" % (w, h, x, y))
# root has no image argument, so use a label as a panel
panel1 = tk.Label(root, image=image1)
panel1.pack(side='top', fill='both', expand='yes')
# put a button on the image panel to test it
button2 = tk.Button(panel1, text='button2')
button2.pack(side='top')
# save the panel's image from 'garbage collection'
panel1.image = image1
# start the event loop
root.mainloop()
Please use the[code=python] and [/code] tag pair to enclose your python code.
vegaseat
DaniWeb's Hypocrite
5,976 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,416