tkinter中的文本不是cmd python中的文本?

tkinter中的文本不是cmd python中的文本?,tkinter,Tkinter,当我在CMD中运行它时,tkinter会出现并运行程序,但当我进入一个城市时,结果/预测会在CMD中出现,我想在tkinter box程序中出现我该怎么办 我需要标签还是什么 from tkinter import * import requests import json class Application(Frame): def __init__(self, master=None): Frame.__init__(self

当我在CMD中运行它时,tkinter会出现并运行程序,但当我进入一个城市时,结果/预测会在CMD中出现,我想在tkinter box程序中出现我该怎么办

我需要标签还是什么

from tkinter import *
    import requests
    import json

    class Application(Frame):

        def __init__(self, master=None):
            Frame.__init__(self, master)
            self.root = master
            self.pack()
            self.create_widgets()

        def create_widgets(self):
            self.v = StringVar()
            self.e = Entry(self, textvariable=self.v)
            self.e.pack(side="left")

            self.v.set("Enter City")
            self.e.focus_set()


            self.butn = Button(self)
            self.butn["text"] = "Forecast"
            self.butn["command"] = self.make_request
            self.butn.pack(side="left")

            self.QUIT = Button(self, text="QUIT", command=self.root.destroy)
            self.QUIT.pack(side="right")


        def make_request(self):
            r = requests.get("http://api.wunderground.com/api/ab78bcbaca641959/forecast/q/Sweden/" + self.v.get() + ".json")
            data = r.json()
            for day in data['forecast']['simpleforecast']['forecastday']:
                print (day['date']['weekday'] + ":")
                print ("Conditions: ", day['conditions'])
                print ("High: ", day['high']['celsius'] + "C", "Low: ", day['low']['celsius'] + "C", '\n')
            return data






    rot = Tk()
    rot.geometry("900x650+200+50")
    rot.title("The Trip")

    app = Application(master=rot)
    app.mainloop()

是的,您应该为要在Tkinter窗口上显示的数据使用标签:
下面是这样做的一个基本示例:

from Tkinter import *
root = Tk()
e = Entry(root)
e.pack()
var = StringVar()

def callback():
    var.set(e.get())

e.focus_set()
b = Button(root, text="submit", width=10, command=callback)
b.pack()
label = Label( root, textvariable=var, relief=RAISED)
label.pack()
root.mainloop()

此示例将让您了解如何使用StringVar或其他工具更新标签。
某些信息

这是因为您正在打印结果。请改用
标签