Class: Tkri::Tabsbar
- Inherits:
-
TkFrame
- Object
- TkFrame
- Tkri::Tabsbar
- Defined in:
- lib/tkri.rb
Overview
The tabsbar holds the buttons used to switch among the tabs.
Instance Method Summary collapse
- #build_buttons ⇒ Object
-
#initialize(tk_parent, tabs, configuration = {}) ⇒ Tabsbar
constructor
A new instance of Tabsbar.
- #interactive_close_button_tab(e) ⇒ Object
- #set_current_tab_by_index(new) ⇒ Object
Constructor Details
#initialize(tk_parent, tabs, configuration = {}) ⇒ Tabsbar
Returns a new instance of Tabsbar.
665 666 667 668 669 670 |
# File 'lib/tkri.rb', line 665 def initialize(tk_parent, tabs, configuration = {}) @tabs = tabs super(tk_parent, configuration) @buttons = [] end |
Instance Method Details
#build_buttons ⇒ Object
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 |
# File 'lib/tkri.rb', line 679 def @buttons.each { |b| b.destroy } @buttons = [] @tabs.each_with_index do |tab, i| b = TkButton.new(self, :text => (tab.topic || '<new>')).pack :side => 'left' b.configure Settings::get_configuration('tab_button') b.command { set_current_tab_by_index i } Tkri.attach_bindings b, 'tabbutton' @buttons << b end plus = TkButton.new(self, :text => '+').pack :side => 'left', :padx => 10 plus.configure Settings::get_configuration('tab_button') plus.command { @tabs.new_tab } @buttons << plus set_current_tab_by_index @tabs.current_tab_as_index end |
#interactive_close_button_tab(e) ⇒ Object
696 697 698 699 700 |
# File 'lib/tkri.rb', line 696 def e if idx = @buttons.index(e.) @tabs.close @tabs.get(idx) end end |
#set_current_tab_by_index(new) ⇒ Object
672 673 674 675 676 677 |
# File 'lib/tkri.rb', line 672 def set_current_tab_by_index new @buttons.each_with_index do |b, i| b.relief = (i == new) ? 'sunken' : 'raised' end @tabs.set_current_tab_by_index new end |