在Tkinter Gui界面中打印天气更新

时间:2018-10-16 16:44:14

标签: python tkinter

我想在tkinter gui界面上打印天气状况。所以我写了这段代码。...

import tkinter as tk
from tkinter import *
from weather import Weather,Unit

win=tk.Tk()

weather = Weather(unit=Unit.CELSIUS)
location=weather.lookup_by_location('Dhaka')
condition=location.condition
label=Label(text=condition)
label.pack()

win.mainloop()

但是输出样本是... This is my unexpected output

但是我希望输出显示类似Sunny,雷暴等情况的情况。

1 个答案:

答案 0 :(得分:2)

您已将对象链接到标签,需要调用文本。 from collections import defaultdict dd = defaultdict(list) for d in (d1, labels): # you can list as many input dicts as you want here # d.iteritems() in 2.0 for key, value in d.items(): dd[key].append(value)

condition.text