require 'phi'
include Phi

form = Form.new

i = TreeView.new form, :tree_view
i.align = Phi::AL_CLIENT
i.items

i = Button.new form, :btn1, '&Make'
i.align = Phi::AL_TOP

form.show

form.btn1.on_click = proc do
  ns = form.tree_view.items
  ns.clear
  n1 = ns.add nil, 'RootTreeNode1'
  ns.add_child n1, 'ChildNode1'
  n2 = ns.add n1, 'RootTreeNode2'
  ns.add_child n2, 'ChildNode2'
  n2 = ns[3]
  ns.add_child n2, 'ChildNode2a'
  ns.add n2, 'ChildNode2b'
  ns.add n1, 'RootTreeNode3'
  form.tree_view.save 'tree.dat'
end

Phi.mainloop
