Duplicating a frame in a new window

From: Ryan (ryan_border_at_yahoo.com)
Date: 11/02/04


Date: 2 Nov 2004 14:11:29 -0800

You guys have been a huge help so far, I'm hoping I can tap you
again...

I would like to give my user the option to duplicate an exising frame
in a new window; which would stay open until they manually close it.
 Syntax has me befuddled. Below is a hopeless attempt to implement.
I'm trying to use my "newwin" procedure to duplicate the existing
frame .f1 in a new window (nw).

In the real app, the code defining the contents of .f1 (in this case,
just the two buttons .f1.b1 and .f1.b5) is non-trivial, and my goal is
to avoid duplication of the frame content code.

If this worked as I hoped, when the user pressed the "New Window"
button, a new window would open with b1, b5 and a close button. Is
this possible, or am I really on the wrong path here?

frame .f1
frame .f2

button .f1.b1 -text b1
button .f1.b5 -text b5

button .f2.b2 -text b2
button .f2.b3 -text "New Window" -command "newwin .f1"
button .f2.b4 -text close -command exit

pack .f1 .f1.b1 .f1.b5 -side top
pack .f2 .f2.b2 .f2.b3 .f2.b4 -side top

pack .f1 .f2 -side left

proc newwin {fn} {
  catch {destroy .nw}
  toplevel .nw
  frame .nw$fn
  button .nw.b_close -text close -command {destroy .nw}
  pack .nw$fn .nw.b_close -side top

Thanks-
Ryan Border.