Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 刷新tkinter消息框中的文本_Python 3.x_Tkinter - Fatal编程技术网

Python 3.x 刷新tkinter消息框中的文本

Python 3.x 刷新tkinter消息框中的文本,python-3.x,tkinter,Python 3.x,Tkinter,我有一个包含许多步骤的Python代码。我做的每一步都是一张打印纸,上面写着我已经完成了这一步。我正在寻找一种方法来打开一个消息窗口,每一步结束后,打印将出现在同一窗口中,直到结束。我该怎么做?这可能会有帮助 from tkinter import * class Application(Frame): t = None def say_hi(self): self.t.message.insert(END, "hi there!! \n") def

我有一个包含许多步骤的Python代码。我做的每一步都是一张打印纸,上面写着我已经完成了这一步。我正在寻找一种方法来打开一个消息窗口,每一步结束后,打印将出现在同一窗口中,直到结束。我该怎么做?

这可能会有帮助

from tkinter import *

class Application(Frame):
    t = None

    def say_hi(self):
        self.t.message.insert(END, "hi there!! \n")

    def createWidgets(self):
        self.QUIT = Button(self)
        self.QUIT["text"] = "QUIT"
        self.QUIT["fg"]   = "red"
        self.QUIT["command"] =  self.quit

        self.QUIT.pack({"side": "left"})

        self.hi_there = Button(self)
        self.hi_there["text"] = "Launch",
        self.hi_there["command"] = self.create_window

        self.hi_there.pack({"side": "left"})

    def create_window(self):
        if(self.t):
            self.say_hi()
        else:
            self.t = Toplevel(self)
            self.t.wm_title("Message Window")
            self.t.message = Text(self.t, height=20, width=30)
            self.t.message.pack()
            self.say_hi()

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

root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()
您有一个主应用程序,它打开一个顶级窗口,上面有一个文本区域

通过函数say_hi,您可以从创建的消息窗口直接在文本区域中写入内容

我希望这就是你想要的