diff options
Diffstat (limited to 'ext/tk/sample/demos-en/tree.rb')
-rw-r--r-- | ext/tk/sample/demos-en/tree.rb | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/ext/tk/sample/demos-en/tree.rb b/ext/tk/sample/demos-en/tree.rb index 0c7f0e71a..cd62ba8c9 100644 --- a/ext/tk/sample/demos-en/tree.rb +++ b/ext/tk/sample/demos-en/tree.rb @@ -6,7 +6,7 @@ # based on "Id: tree.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp" if defined?($tree_demo) && $tree_demo - $tree_demo.destroy + $tree_demo.destroy $tree_demo = nil end @@ -19,8 +19,8 @@ $tree_demo = TkToplevel.new {|w| base_frame = TkFrame.new($tree_demo).pack(:fill=>:both, :expand=>true) ## Explanatory text -Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', - :justify=>:left, :anchor=>'n', :padding=>[10, 2, 10, 6], +Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', + :justify=>:left, :anchor=>'n', :padding=>[10, 2, 10, 6], :text=><<EOL).pack(:fill=>:x) Ttk is the new Tk themed widget set. \ One of the widgets it includes is a tree widget, \ @@ -37,16 +37,16 @@ EOL Ttk::Frame.new(base_frame) {|frame| sep = Ttk::Separator.new(frame) Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) - TkGrid('x', - Ttk::Button.new(frame, :text=>'See Code', - :image=>$image['view'], :compound=>:left, - :command=>proc{showCode 'tree'}), - Ttk::Button.new(frame, :text=>'Dismiss', - :image=>$image['delete'], :compound=>:left, + TkGrid('x', + Ttk::Button.new(frame, :text=>'See Code', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'tree'}), + Ttk::Button.new(frame, :text=>'Dismiss', + :image=>$image['delete'], :compound=>:left, :command=>proc{ $tree_demo.destroy $tree_demo = nil - }), + }), :padx=>4, :pady=>4) grid_columnconfigure(0, :weight=>1) pack(:side=>:bottom, :fill=>:x) @@ -55,7 +55,7 @@ Ttk::Frame.new(base_frame) {|frame| ## Code to populate the roots of the tree (can be more than one on Windows) def populate_roots(tree) TkComm.simplelist(Tk.tk_call('file', 'volumes')).sort.each{|dir| - populate_tree(tree, tree.insert(nil, :end, :text=>dir, + populate_tree(tree, tree.insert(nil, :end, :text=>dir, :values=>[dir, 'directory'])) } end @@ -68,7 +68,7 @@ def populate_tree(tree, node) tree.delete(tree.children(node)) Dir.glob("#{path}/*").sort.each{|f| type = File.ftype(f) - id = tree.insert(node, :end, + id = tree.insert(node, :end, :text=>File.basename(f), :values=>[f, type]).id if type == 'directory' ## Make it so that this node is openable @@ -94,7 +94,7 @@ def populate_tree(tree, node) end ## Create the tree and set it up -tree = Ttk::Treeview.new(base_frame, :columns=>%w(fullpath type size), +tree = Ttk::Treeview.new(base_frame, :columns=>%w(fullpath type size), :displaycolumns=>['size']) if Tk.windowingsystem != 'aqua' vsb = tree.yscrollbar(Ttk::Scrollbar.new(base_frame)) |