Class: TkComponent::Window

Inherits:
Base
  • Object
show all
Defined in:
lib/tk_component/base/window.rb

Instance Attribute Summary

Attributes inherited from Base

#children, #node, #parent, #parent_node, #tk_item

Instance Method Summary collapse

Methods inherited from Base

#add_child, #build, #component_did_build, #emit, #generate, #parse_component, #parse_nodes, #rebuild, #regenerate, #regenerate_after_node, #regenerate_from_index, #regenerate_from_node, #render

Methods included from BasicComponent

#focus

Constructor Details

#initialize(options = {}) ⇒ Window

Returns a new instance of Window.



3
4
5
6
# File 'lib/tk_component/base/window.rb', line 3

def initialize(options = {})
  super
  @tk_item = Builder::TkItem.create(nil, :root, options)
end

Instance Method Details

#nameObject



8
9
10
# File 'lib/tk_component/base/window.rb', line 8

def name
  "Window"
end

#place_root_component(component, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/tk_component/base/window.rb', line 12

def place_root_component(component, options = {})
  component.parent = self
  component.generate(self)
  component.build(self)
  x_flex = options[:x_flex] || 1
  y_flex = options[:y_flex] || 1
  TkGrid.columnconfigure tk_item.native_item, 0, weight: x_flex
  TkGrid.rowconfigure tk_item.native_item, 0, weight: y_flex
  add_child(component)
end