Code: Alles auswählen
Code: Alles auswählen
#!/usr/bin/env python3
# tk_label.py
from tkinter import * # Python 2.7 "from Tkinter import *"
from tkinter import ttk # Python 2.7 "import ttk"
mainWin = Tk()
result = StringVar()
result.set('weigu.lu')
imageLabel_1 = PhotoImage(file='luftfeuchtigkeit.png')
label_1 = ttk.Label(mainWin, textvariable=result, image=imageLabel_1, compound='top')
label_1.grid()
mainWin.mainloop()
Ich bekomme jedoch folgende Fehlermeldung :
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/maxkoster/PycharmProjects/WetterstationALR/image_test.py
Traceback (most recent call last):
File "/Users/maxkoster/PycharmProjects/WetterstationALR/image_test.py", line 8, in <module>
imageLabel_1 = PhotoImage(file='luftfeuchtigkeit.png')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 3366, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 3320, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "luftfeuchtigkeit.png"
Process finished with exit code 1
Ich bin mir jedoch sicher, dass ich die datei in dem selben ordner als das .py programm gespecihert haben.
Mit freundlichen Grüssen.
Max