Class: TkTree

Inherits:
TkCanvas show all
Defined in:
sample/tktree.rb

Constant Summary collapse

TCL_SCRIPT_PATH =
File.join(File.dirname(__FILE__), 'tktree.tcl')

Instance Method Summary collapse

Instance Method Details

#create_self(keys) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'sample/tktree.rb', line 18

def create_self(keys)
  args = [@path]
  if keys.kind_of?(Hash)
    font = keys.delete('itemfont')
#      font = hash_kv(font) if font.kind_of?(Hash)
    keys['font'] = font if font
#      args.concat(hash_kv(keys))
    args << keys
  end
  begin
    tk_call('::tktree::treecreate', *args)
  rescue NameError, RuntimeError
    Tk.load_tclscript(TkTree::TCL_SCRIPT_PATH)
    tk_call('::tktree::treecreate', *args)
  end
end

#delitem(itempath) ⇒ Object



48
49
50
# File 'sample/tktree.rb', line 48

def delitem(itempath)
  tk_call('::tktree::delitem', @path, itempath)
end

#getselectionObject



56
57
58
# File 'sample/tktree.rb', line 56

def getselection
  tk_call('::tktree::getselection', @path)
end

#labelat(xpos, ypos) ⇒ Object



52
53
54
# File 'sample/tktree.rb', line 52

def labelat(xpos, ypos)
  tk_call('::tktree::delitem', @path, xpos, ypos)
end

#newitem(itempath, keys = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'sample/tktree.rb', line 35

def newitem(itempath, keys = nil)
  if keys.kind_of?(Hash)
    keys = _symbolkey2str(keys)
    font = keys.delete('itemfont')
#      font = hash_kv(font) if font.kind_of?(Hash)
    keys['font'] = font if font
#      tk_call('::tktree::newitem', @path, itempath, *hash_kv(keys))
    tk_call('::tktree::newitem', @path, itempath, keys)
  else
    tk_call('::tktree::newitem', @path, itempath)
  end
end

#setselection(itempath) ⇒ Object



60
61
62
# File 'sample/tktree.rb', line 60

def setselection(itempath)
  tk_call('::tktree::getselection', @path, itempath)
end