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 thes开发者_如何学运维e 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.
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 to pack
and grid
, 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
or text
widget is not at all trivial, though with the text
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.
精彩评论