PythonTkinter或ttk,发送文本到其他顶级风

2024-10-02 18:19:48 发布

您现在位置:Python中文网/ 问答频道 /正文

在开发pythontttk代码的过程中,我使用了一个单独的顶层窗口,并希望从root用户向debug顶层窗口发送消息。在

这是一些伪代码

from Tkinter import *
import ttk
from MyFunctions import *    # some code I wrote (see below)
root = Tk()
SetupMyFunct(root)           # see below
de_bug = Toplevel(root)
dbug_frame = Frame(de_bug).grid()
debug_string1 = StringVar()
debug1_window = ttk.Label(dbug_frame, textvariable = debug_string1).grid()
root.mainloop()

在我的MyFunctions.py公司名称:

^{pr2}$

在这一点上,我想发送一些文本自动更新在de_bug窗口,但我真的不知道从这里到哪里去。在

请帮忙? 作记号。在


Tags: 代码fromdebugimportderootframebug
1条回答
网友
1楼 · 发布于 2024-10-02 18:19:48

链接几何管理方法会阻止您保留对这些小部件的引用,因为这些方法返回存储在这些变量中的None。别这样。这将允许您做一些事情,比如使用对小部件的引用。具体地说,您将能够将dbug_frame指定为debug1_window小部件的父对象。在

from Tkinter import *
import ttk
from MyFunctions import *
root = Tk()
f,w = SetupMyFunct(root)
de_bug = Toplevel(root)
dbug_frame = Frame(de_bug)
dbug_frame.grid()
debug_string1 = StringVar()
debug1_window = ttk.Label(dbug_frame, textvariable=debug_string1)
debug1_window.grid()
root.mainloop()

^{pr2}$

相关问题 更多 >