Method: Tk::BLT::Tabnotebook::Tab#initialize

Defined in:
ext/lib/tkextlib/blt/tabnotebook.rb

#initialize(parent, pos, name, keys) ⇒ Tab

Returns a new instance of Tab.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'ext/lib/tkextlib/blt/tabnotebook.rb', line 50

def initialize(parent, pos, name, keys)
  @t = parent
  @tpath = parent.path
  if name
    @path = @id = name
    unless (list(tk_call(@tpath, 'tab', 'names', @id)).empty?)
      if pos
        idx = tk_call(@tpath, 'index', @id)
        if pos.to_s == 'end'
          tk_call(@tpath, 'move', idx, 'after', 'end')
        else
          tk_call(@tpath, 'move', idx, 'before', pos)
        end
      end
      tk_call(@tpath, 'tab', 'configure', @id, keys)
    else
      fail ArgumentError, "can't find tab \"#{@id}\" in #{@t}"
    end
  else
    pos = 'end' unless pos
    @path = @id = tk_call(@tpath, 'insert', pos, keys)
  end
end