将现有框架移动到新框架并使用旧名称创建新框架
我在 tcl 中使用了一个名为frame1 的框架,还有其他框架。 现在我设置了一个过程来销毁所有这些帧。我想要做的是将这些帧移动到一个新变量并创建同名的新帧。 我的代码如下所示:
proc DestroyAll {} {
global parent_widget
global new_widget
destroy .sf.frame.main.xName
for {set i 0} {$i < $Count} {incr i} {
destroy .sf.frame.main.parameter($i)
}
destroy .sf.frame.main.buttons
destroy .sf.frame.buttons
destroy .sf.frame.main
destroy .sf.frame
destroy .sf
}
Populatenewdata --->>该过程创建并填充 sf 框架 我不想破坏这些框架,但我想创建新框架。有什么方法可以做到这一点,因为该帧的填充过程非常冗长并且无法使用循环来完成。
i've used a frame in tcl named frame1 and others also.
Now i set a proc to destroy all these frames. what i want to do is to move these frames to a new variable and create new frames of same names.
my code looks like this:
proc DestroyAll {} {
global parent_widget
global new_widget
destroy .sf.frame.main.xName
for {set i 0} {$i < $Count} {incr i} {
destroy .sf.frame.main.parameter($i)
}
destroy .sf.frame.main.buttons
destroy .sf.frame.buttons
destroy .sf.frame.main
destroy .sf.frame
destroy .sf
}
Populatenewdata --->> this proc creates and fills the sf frame
I dont want to destroy these frames, but i want to create new frame. Is there any way of doing this as the filling procedure of this frames is very lengthy and cant be done using loop.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Tk 不允许您重新设置窗口小部件的父级;它们的名字从你创建它们的那一刻到你销毁它们的那一刻都是固定的。 (您可以使用适当的
-in
选项来pack
和grid
使它们视觉上出现在不同的小部件中,但那就是严格的视觉效果。)是否可以更好地管理支持小部件的模型,以便您可以轻松地在该模型上重新创建视图? (答案取决于所使用的小部件 - 重新创建
canvas
或text
小部件一点也不简单,尽管使用text
您可以克隆从 8.5 开始 — 但通常相当容易。)重新思考您在 MVC 方面所做的事情会有所帮助。Tk doesn't let you reparent widgets; their names are fixed from the moment you create them to the moment you destroy them. (You can make them visually appear inside different widgets with appropriate
-in
options topack
andgrid
, but that's a strictly visual effect.)Is it possible to manage the model backing up your widgets better so that you can easily recreate views onto that model? (The answer depends on the widgets in use — recreating a
canvas
ortext
widget is not at all trivial, though with thetext
you can clone it from 8.5 onwards — but it's usually fairly easy.) Rethinking what you're doing more strongly in terms of MVC will help.