封装为类的tkinter,怎么在类外把信息写到Tkinter的text控件中
import tkinter as tk
from tkinter import scrolledtext
class App:
def __init__(self, window):
self.window = window
self.window.title("main")
self.window.geometry("600x300")
self.labelframe()
self.text_insert()
def labelframe(self):
lf = tk.LabelFrame(
self.window, text="运行信息", font=("微软雅黑", 10, "bold"), padx=10, pady=10
)
lf.place(x=20, y=20)
text = scrolledtext.ScrolledText(lf, height=5, width=65, font=("微软雅黑", 10))
text.grid()
self.text = text
def text_insert(self):
self.text.insert("end", "Part_1:这是类内写入的信息... \n")
# 怎么在类外把信息写到Tkinter的text控件中
message = "Part_2:这条信息,在类外写入Tkinter text控件"
root = tk.Tk()
app = App(root)
root.mainloop()