title: Can't pack a widget inside a sibling toplevel
body: <p>I'm trying to <code>pack</code> (or <code>place</code>) a widget which is child of the root toplevel <code>.</code> inside another toplevel, that is a child of <code>.</code> itself. That is,</p>
  
  <pre><code>% toplevel .tl
  .tl
  % frame .f
  .f
  % pack .f -in .tl
  can't pack .f inside .tl
  </code></pre>
  
  <p>However, I've found this code <em>almost</em> works:</p>
  
  <pre><code>% frame .tl
  .tl
  % frame .f
  .f
  % pack .f -in .tl
  % wm manage .tl
  </code></pre>
  
  <p>I said <em>almost</em>, because <code>.f</code> is not visible. It's a bit strange, because if I put a button inside <code>.f</code>, such as</p>
  
  <pre><code>button .f.b -text FooBar
  pack .f.b
  </code></pre>
  
  <p>I see the empty space reserved by the geometry manager, but no widget is visible.</p>
  
  <p>I'm sure I'm doing something wrong, but I don't know what and why, and the <code>pack</code>, <code>grid</code> and <code>place</code> man pages don't help.</p>
  
  <hr>
  
  <p><strong>Edit: some details about what I'm doing</strong></p>
  
  <p>I'm trying to build a snit widget which automates some toplevel creation stuff. One thing I usually do is putting a <code>ttk::frame</code> inside every toplevel I create, and managing it using a <code>pack ... -fill both -expand true</code> command.</p>
  
  <p>My snidget should always do it, but I'd like to hide it from the user perspective, so that any change to the implementation wouldn't break existing code.</p>
  
  <p>The simple way is this</p>
  
  <pre><code>snit::widget Toplevel {
      hulltype toplevel
      component f
  
      constructor {args} {
          set f [ttk::frame $self.f -padding 2]
          pack $f -fill both -expand 1
  
          $self configurelist $args
      }
  }
  </code></pre>
  
  <p>but the user must know about the <code>f</code> component, and create other widgets as children of it.</p>
  
  <p>So, I tried another solution: I use a <code>ttk::frame</code> widget as hull type, then build a <em>sibling</em> toplevel of the hull, and try to put the hull inside the toplevel.</p>
  
  <p>The code I tried is similar to the following:</p>
  
  <pre><code>snit::widget Toplevel {
      hulltype ttk::frame
      component tl
  
      constructor {args} {
          set segments [split $self .]
          set wname [join [lreplace $segments end end _[lindex $segments end]] .]
  
          set tl [frame $wname -width 100 -height 100]
          pack $self -in $tl -fill both -expand 1
          wm manage $tl
  
          $self configurelist $args
      }
  }
  </code></pre>
  
  <p>If it would work as expected, the user could write something like this:</p>
  
  <pre><code>% Toplevel .t
  .t
  % button .t.b -text Foobar
  .t.b
  % pack .t.b
  </code></pre>
  
  <p>and would get a button inside the toplevel <code>.t</code> build using the snidget.</p>