from tkinter import *
from configparser import ConfigParser
from tkinter import messagebox
import requests
if weather:
location_lbl['text'] = '{}, {}'.format(weather[0], weather[1])
image_lbl['bitmap'] = 'icons/{}.png'.format(weather[4])
temp_lbl['text'] = '{:.2f}°C, {:.2f}°F'.format(weather[2], weather[3])
weather_lbl['text'] = weather[5]
I got this error:
_tkinter.TclError: bitmap "icons/50d.png" not defined
Please help me.
This is a misunderstanding, image_lbl['bitmap']
is NOT used for showing png files or your loaded image files, its more like for showing the bitmaps loaded into tkinter:
image_lbl['bitmap'] = 'error' #or questionhead, warning, gray50, etc.
If you want to load a png image then use tk.PhotoImage
, like:
img = tk.PhotoImage(file='icons/{}.png'.format(weather[4]))
image_lbl['image'] = img
Though its worth noting that for using jpeg
, an additional module named PIL
has to be used.
Take a look at these, helpful links: