Class: TkWrapper::Widgets::Menu
Defined Under Namespace
Classes: Cascade, Command
Instance Attribute Summary
Attributes inherited from Base::Widget
#cell, #childs, #config, #font, #ids, #manager, #opts, #parent, #winfo
Class Method Summary
collapse
Instance Method Summary
collapse
#create_tk_widget, #each, #init_id, #initialize, #initialize_utilities, #normalize_childs, #push, #tk_widget
Class Method Details
.create(structure: [], config: {}) ⇒ Object
36
37
38
39
40
41
|
# File 'lib/widgets/menu.rb', line 36
def self.create(structure: [], config: {})
new(
config: config,
childs: structure.map { |entry| create_subentry(entry) }
)
end
|
.create_subentries(structure) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/widgets/menu.rb', line 43
def self.create_subentries(structure)
return [] unless structure && !structure.nil?
structure = [structure] unless structure.is_a?(Array)
structure.map { |entry| create_subentry(**entry) }
end
|
.create_subentry(entry) ⇒ Object
50
51
52
53
54
55
56
57
|
# File 'lib/widgets/menu.rb', line 50
def self.create_subentry(entry)
case entry
in { config: config, structure: st }
return Cascade.new config: config, childs: create_subentries(st)
else
return Command.new config: entry
end
end
|
Instance Method Details
#build(parent, **args) ⇒ Object
10
11
12
13
|
# File 'lib/widgets/menu.rb', line 10
def build(parent, **args)
super(parent, **args)
parent.tk_widget['menu'] = tk_widget
end
|
#tk_class ⇒ Object
6
7
8
|
# File 'lib/widgets/menu.rb', line 6
def tk_class
TkMenu
end
|