require 'tk'

def clear_all(frame)
    frame.pack_slaves.each{|x| x.unpack }
end


    root = TkRoot.new { title "Nephros H2H" }
    top = TkFrame.new(root)
    
    src     = TkFrame.new(top).pack('side'=>'top')
    buttons = TkFrame.new(top).pack('side'=>'bottom')
    a = TkButton.new(buttons, 'text'=>'A').pack('side'=>'left')
    b = TkButton.new(buttons, 'text'=>'B').pack('side'=>'left')
    c = TkButton.new(buttons, 'text'=>'C').pack('side'=>'left')
    
    p src.pack_slaves.length
    f1 = TkFrame.new(src)
    TkLabel.new(f1,'text'=>'One').pack
    
    p src.pack_slaves.length
    f2 = TkFrame.new(src)
    TkLabel.new(f2,'text'=>'Two-Left') .pack('side'=>'left')
    TkLabel.new(f2,'text'=>'Two-Right').pack('side'=>'right')
    
    p src.pack_slaves.length
    f3 = TkFrame.new(src)
    TkLabel.new(f3,'text'=>'Three-Up')  .pack('side'=>'top')
    TkLabel.new(f3,'text'=>'Three-Down').pack('side'=>'bottom')
   
    p src.pack_slaves.length
   
    f3.pack
   
    a.command proc{ p src.pack_slaves.length;  clear_all(src); f1.pack }
    b.command proc{ p src.pack_slaves.length;  clear_all(src); f2.pack }
    c.command proc{ p src.pack_slaves.length;  clear_all(src); f3.pack }
    
    
    
    top.pack
    Tk.mainloop
