Ich versuche mit folgendem Code ein Bildchen auf ein Button-Widget zu bekommen:
Code: Alles auswählen
#!/usr/bin/python
from Tkinter import *
import Image
def spam():
print 'pressed me!'
root = Tk()
im = Image.open('Select.jpg')
print im.size, im.mode
test = Button(root, image = im, command = spam)
test.pack()
root.mainloop()
... und kriege folgende Ausgabe:
(32, 32) L
Traceback (most recent call last):
File "buttontest.py", line 11, in ?
test = Button(root, image = im, command = spam)
File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 1906, in __init__
Widget.__init__(self, master, 'button', cnf, kw)
File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 1835, in __init__
self.tk.call(
_tkinter.TclError: image "<JpegImagePlugin.JpegImageFile instance at 0x408a490c>" doesn't exist
Weiss jemand Rat?
(Python 2.3, Suse Linux 9.0)
Wie immer heissen Dank im Voraus,