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]
我得到了这个错误:
_tkinter.TclError: bitmap "icons/50d.png" not defined
请帮帮我
这是一个误解,
image_lbl['bitmap']
不用于显示png文件或加载的图像文件,更像是显示加载到tkinter中的位图:如果要加载png图像,请使用
tk.PhotoImage
,如:尽管值得注意的是,为了使用
jpeg
,必须使用名为PIL
的附加模块看看这些有用的链接:
Bitmaps on tkinter
PhotoImage on tkinter
相关问题 更多 >
编程相关推荐