glimmer-dsl-tk 0.0.38 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -0
- data/README.md +311 -17
- data/VERSION +1 -1
- data/glimmer-dsl-tk.gemspec +0 -0
- data/lib/glimmer/dsl/tk/block_attribute_expression.rb +6 -2
- data/lib/glimmer/dsl/tk/dsl.rb +1 -1
- data/lib/glimmer/tk/checkbutton_proxy.rb +0 -2
- data/lib/glimmer/tk/menu_item_proxy.rb +67 -9
- data/lib/glimmer/tk/menu_proxy.rb +48 -7
- data/lib/glimmer/tk/radiobutton_proxy.rb +0 -3
- data/lib/glimmer/tk/scrollbar_frame_proxy.rb +133 -0
- data/lib/glimmer/tk/widget_proxy.rb +36 -16
- data/lib/glimmer-dsl-tk.rb +12 -0
- data/samples/elaborate/meta_sample.rb +10 -0
- data/samples/hello/hello_button.rb +4 -4
- data/samples/hello/hello_checkbutton.rb +1 -1
- data/samples/hello/hello_menu_bar.rb +91 -14
- data/{lib/glimmer/tk/commandable.rb → samples/hello/hello_scrollbar.rb} +43 -19
- data/samples/hello/hello_scrollbar_frame.rb +77 -0
- data/samples/hello/hello_text.rb +10 -5
- data/samples/hello/hello_toplevel.rb +1 -1
- metadata +6 -5
- data/lib/glimmer/tk/button_proxy.rb +0 -34
@@ -45,7 +45,7 @@ module Glimmer
|
|
45
45
|
|
46
46
|
def accelerator=(value)
|
47
47
|
@accelerator = value
|
48
|
-
|
48
|
+
configure_menu_item_attribute(accelerator: value)
|
49
49
|
root_parent_proxy.bind(accelerator_event) do |event|
|
50
50
|
@command_block&.call(event)
|
51
51
|
end
|
@@ -64,16 +64,38 @@ module Glimmer
|
|
64
64
|
|
65
65
|
def state=(value)
|
66
66
|
@state = value
|
67
|
-
|
67
|
+
configure_menu_item_attribute(state: value)
|
68
68
|
end
|
69
69
|
|
70
70
|
def state
|
71
71
|
@state
|
72
72
|
end
|
73
73
|
|
74
|
+
def label
|
75
|
+
@options[:label]
|
76
|
+
end
|
77
|
+
|
78
|
+
def image=(*args)
|
79
|
+
@image = image_argument(args)
|
80
|
+
configure_menu_item_attribute(image: @image)
|
81
|
+
end
|
82
|
+
|
83
|
+
def image
|
84
|
+
@image
|
85
|
+
end
|
86
|
+
|
87
|
+
def compound=(value)
|
88
|
+
@compound = value
|
89
|
+
configure_menu_item_attribute(compound: @compound)
|
90
|
+
end
|
91
|
+
|
92
|
+
def compound
|
93
|
+
@compound
|
94
|
+
end
|
95
|
+
|
74
96
|
def command_block=(proc)
|
75
97
|
@command_block = proc
|
76
|
-
|
98
|
+
configure_menu_item_attribute(command: @command_block)
|
77
99
|
end
|
78
100
|
|
79
101
|
def handle_listener(listener_name, &listener)
|
@@ -101,6 +123,22 @@ module Glimmer
|
|
101
123
|
@args.first == :separator
|
102
124
|
end
|
103
125
|
|
126
|
+
def about?
|
127
|
+
@args.first == :about
|
128
|
+
end
|
129
|
+
|
130
|
+
def preferences?
|
131
|
+
@args.first == :preferences
|
132
|
+
end
|
133
|
+
|
134
|
+
def help?
|
135
|
+
@args.first == :help
|
136
|
+
end
|
137
|
+
|
138
|
+
def quit?
|
139
|
+
@args.first == :quit
|
140
|
+
end
|
141
|
+
|
104
142
|
def variable(auto_create: true)
|
105
143
|
if @variable.nil? && auto_create
|
106
144
|
sibling_variable = sibling_radio_menu_items.map {|mi| mi.variable(auto_create: false)}.compact.first
|
@@ -113,15 +151,27 @@ module Glimmer
|
|
113
151
|
|
114
152
|
def selection=(value)
|
115
153
|
if value
|
116
|
-
variable.value =
|
117
|
-
# TODO handle image case where there is no label
|
154
|
+
variable.value = label
|
118
155
|
elsif checkbutton?
|
119
|
-
variable.value = '
|
156
|
+
variable.value = ''
|
120
157
|
end
|
121
158
|
end
|
122
159
|
|
123
160
|
def selection
|
124
|
-
variable.value ==
|
161
|
+
variable.value == label
|
162
|
+
end
|
163
|
+
|
164
|
+
# configures menu item attribute through parent menu
|
165
|
+
def configure_menu_item_attribute(attribute_value_hash)
|
166
|
+
if preferences? && attribute_value_hash[:command]
|
167
|
+
::Tk.ip_eval("proc ::tk::mac::ShowPreferences {} {#{::Tk.install_cmd(attribute_value_hash[:command])}}") if OS.mac?
|
168
|
+
elsif help? && attribute_value_hash[:command]
|
169
|
+
::Tk.ip_eval("proc ::tk::mac::ShowHelp {} {#{::Tk.install_cmd(attribute_value_hash[:command])}}") if OS.mac?
|
170
|
+
elsif quit? && attribute_value_hash[:command]
|
171
|
+
::Tk.ip_eval("proc ::tk::mac::Quit {} {#{::Tk.install_cmd(attribute_value_hash[:command])}}") if OS.mac?
|
172
|
+
else
|
173
|
+
@parent_proxy.tk.entryconfigure label, attribute_value_hash
|
174
|
+
end
|
125
175
|
end
|
126
176
|
|
127
177
|
private
|
@@ -133,10 +183,18 @@ module Glimmer
|
|
133
183
|
def build_widget
|
134
184
|
@args.prepend(:command) if @args.first.is_a?(Hash)
|
135
185
|
@args.append({}) if !@args.last.is_a?(Hash)
|
136
|
-
@args.last.merge!(variable: variable, value:
|
186
|
+
@args.last.merge!(variable: variable, value: label) if radiobutton? || checkbutton?
|
137
187
|
case @parent_proxy
|
138
188
|
when MenuProxy
|
139
|
-
@parent_proxy.
|
189
|
+
if @parent_proxy.application?
|
190
|
+
if OS.mac?
|
191
|
+
if about?
|
192
|
+
@parent_proxy.tk.add :command, :label => label
|
193
|
+
end
|
194
|
+
end
|
195
|
+
else
|
196
|
+
@parent_proxy.tk.add(*@args) unless help?
|
197
|
+
end
|
140
198
|
end
|
141
199
|
end
|
142
200
|
end
|
@@ -31,16 +31,57 @@ module Glimmer
|
|
31
31
|
super
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
def build_widget
|
37
|
-
tk_widget_class = self.class.tk_widget_class_for(@keyword)
|
38
|
-
@tk = tk_widget_class.new(@parent_proxy.tk)
|
34
|
+
def post_add_content
|
39
35
|
case @parent_proxy
|
40
36
|
when ToplevelProxy
|
41
37
|
@parent_proxy.tk['menu'] = @tk
|
42
|
-
|
43
|
-
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def label
|
42
|
+
@options[:label]
|
43
|
+
end
|
44
|
+
|
45
|
+
def help?
|
46
|
+
label == 'Help'
|
47
|
+
end
|
48
|
+
|
49
|
+
def window?
|
50
|
+
label == 'Window'
|
51
|
+
end
|
52
|
+
|
53
|
+
def system?
|
54
|
+
label == 'System'
|
55
|
+
end
|
56
|
+
|
57
|
+
def application?
|
58
|
+
@args.first == :application
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def build_widget
|
64
|
+
if application?
|
65
|
+
if OS.mac?
|
66
|
+
@tk = ::TkSysMenu_Apple.new(@parent_proxy.tk)
|
67
|
+
@parent_proxy.tk.add :cascade, :menu => @tk
|
68
|
+
end
|
69
|
+
else
|
70
|
+
if @parent_proxy.parent_proxy.is_a?(ToplevelProxy) && (OS.mac? || OS.linux?) && help?
|
71
|
+
@tk = ::TkSysMenu_Help.new(@parent_proxy.tk)
|
72
|
+
elsif @parent_proxy.parent_proxy.is_a?(ToplevelProxy) && OS.mac? && window?
|
73
|
+
@tk = ::Tk::TkSysMenu_Window.new(@parent_proxy.tk)
|
74
|
+
# Windows system menu does not seem to work
|
75
|
+
# elsif @parent_proxy.parent_proxy.is_a?(ToplevelProxy) && OS.windows? && system?
|
76
|
+
# @tk = ::TkSysMenu_System.new(@parent_proxy.tk)
|
77
|
+
else
|
78
|
+
tk_widget_class = self.class.tk_widget_class_for(@keyword)
|
79
|
+
@tk = tk_widget_class.new(@parent_proxy.tk)
|
80
|
+
end
|
81
|
+
case @parent_proxy
|
82
|
+
when MenuProxy
|
83
|
+
@parent_proxy.tk.add(:cascade, {menu: @tk}.merge(@options))
|
84
|
+
end
|
44
85
|
end
|
45
86
|
end
|
46
87
|
end
|
@@ -20,7 +20,6 @@
|
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
require 'glimmer/tk/widget_proxy'
|
23
|
-
require 'glimmer/tk/commandable'
|
24
23
|
|
25
24
|
module Glimmer
|
26
25
|
module Tk
|
@@ -28,8 +27,6 @@ module Glimmer
|
|
28
27
|
#
|
29
28
|
# Follows the Proxy Design Pattern
|
30
29
|
class RadiobuttonProxy < WidgetProxy
|
31
|
-
include Commandable
|
32
|
-
|
33
30
|
def sibling_radio_buttons
|
34
31
|
@parent_proxy.children.select {|child| child.is_a?(RadiobuttonProxy) && child != self}
|
35
32
|
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# Copyright (c) 2020-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/tk/widget_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module Tk
|
26
|
+
# Scrolledframe (#scrolledframe_tk attribute)
|
27
|
+
# Nested widgets go into the child site (#tk attribute or @scrolledframe_tk.child_site)
|
28
|
+
class ScrollbarFrameProxy < WidgetProxy
|
29
|
+
attr_reader :original_parent_proxy, :container_frame_proxy, :canvas_proxy, :yscrollbar_proxy, :xscrollbar_proxy
|
30
|
+
|
31
|
+
def post_add_content
|
32
|
+
@tk.bind('Configure') {
|
33
|
+
@canvas_proxy.tk.scrollregion(@canvas_proxy.tk.bbox("all"))
|
34
|
+
}
|
35
|
+
@canvas_proxy.tk.yscrollcommand {|*args| @yscrollbar_proxy&.set(*args)}
|
36
|
+
@canvas_proxy.tk.xscrollcommand {|*args| @xscrollbar_proxy&.set(*args)}
|
37
|
+
end
|
38
|
+
|
39
|
+
def has_attribute?(attribute, *args)
|
40
|
+
case attribute.to_s
|
41
|
+
when 'yscrollbar', 'xscrollbar'
|
42
|
+
true
|
43
|
+
else
|
44
|
+
container_frame_proxy.has_attribute?(attribute, *args)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def set_attribute(attribute, *args)
|
49
|
+
case attribute.to_s
|
50
|
+
when 'yscrollbar'
|
51
|
+
@yscrollbar = args.first
|
52
|
+
if @yscrollbar == true
|
53
|
+
build_yscrollbar unless @yscrollbar_proxy
|
54
|
+
elsif @yscrollbar.is_a?(Glimmer::Tk::WidgetProxy)
|
55
|
+
@yscrollbar_proxy.destroy
|
56
|
+
build_yscrollbar(@yscrollbar)
|
57
|
+
else
|
58
|
+
@yscrollbar_proxy.destroy
|
59
|
+
@yscrollbar_proxy = nil
|
60
|
+
end
|
61
|
+
when 'xscrollbar'
|
62
|
+
@xscrollbar = args.first
|
63
|
+
if @xscrollbar == true
|
64
|
+
build_xscrollbar unless @xscrollbar_proxy
|
65
|
+
elsif @xscrollbar.is_a?(Glimmer::Tk::WidgetProxy)
|
66
|
+
@xscrollbar_proxy.destroy
|
67
|
+
build_xscrollbar(@xscrollbar)
|
68
|
+
else
|
69
|
+
@xscrollbar_proxy.destroy
|
70
|
+
@xscrollbar_proxy = nil
|
71
|
+
end
|
72
|
+
else
|
73
|
+
container_frame_proxy.set_attribute(attribute, *args)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_attribute(attribute, *args)
|
78
|
+
case attribute.to_s
|
79
|
+
when 'show_yscrollbar'
|
80
|
+
@yscrollbar
|
81
|
+
when 'show_xscrollbar'
|
82
|
+
@xscrollbar
|
83
|
+
else
|
84
|
+
container_frame_proxy.get_attribute(attribute, *args)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def griddable_parent_proxy
|
91
|
+
@original_parent_proxy
|
92
|
+
end
|
93
|
+
|
94
|
+
def griddable_proxy
|
95
|
+
@container_frame_proxy
|
96
|
+
end
|
97
|
+
|
98
|
+
def build_widget
|
99
|
+
@original_parent_proxy = @parent_proxy
|
100
|
+
@container_frame_proxy = WidgetProxy.new('frame', @parent_proxy, @args)
|
101
|
+
@parent_proxy = @canvas_proxy = WidgetProxy.new('canvas', @container_frame_proxy, [{width: 300, height: 300}])
|
102
|
+
@canvas_proxy.grid(row: 0, column: 0, row_weight: 1, column_weight: 1)
|
103
|
+
build_yscrollbar
|
104
|
+
build_xscrollbar
|
105
|
+
tk_widget_class = self.class.tk_widget_class_for('frame')
|
106
|
+
@tk = tk_widget_class.new(@canvas_proxy.tk, *args)
|
107
|
+
TkcWindow.new(@canvas_proxy.tk, 0, 0, :anchor => "nw", :window => @tk)
|
108
|
+
end
|
109
|
+
|
110
|
+
def build_yscrollbar(scrollbar_widget_proxy = nil)
|
111
|
+
@yscrollbar_proxy = scrollbar_widget_proxy || WidgetProxy.new('scrollbar', @container_frame_proxy, [])
|
112
|
+
@yscrollbar_proxy.orient = 'vertical'
|
113
|
+
@yscrollbar_proxy.grid(row: 0, column: 1) unless scrollbar_widget_proxy
|
114
|
+
@yscrollbar_proxy.command {|*args| @canvas_proxy.tk.yview(*args)}
|
115
|
+
end
|
116
|
+
|
117
|
+
def build_xscrollbar(scrollbar_widget_proxy = nil)
|
118
|
+
@xscrollbar_proxy = scrollbar_widget_proxy || WidgetProxy.new('scrollbar', @container_frame_proxy, [])
|
119
|
+
@xscrollbar_proxy.orient = 'horizontal'
|
120
|
+
@xscrollbar_proxy.grid(row: 1, column: 0, column_span: 2, row_weight: 0) unless scrollbar_widget_proxy
|
121
|
+
@xscrollbar_proxy.command {|*args| @canvas_proxy.tk.xview(*args)}
|
122
|
+
end
|
123
|
+
|
124
|
+
def initialize_defaults
|
125
|
+
options = {}
|
126
|
+
options[:sticky] = 'nsew'
|
127
|
+
options[:column_weight] = 1 if @original_parent_proxy.children.count == 1
|
128
|
+
options[:row_weight] = 1 if @original_parent_proxy.children.count == 1
|
129
|
+
grid(options)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -46,10 +46,13 @@ module Glimmer
|
|
46
46
|
# This supports widgets in and out of basic Tk
|
47
47
|
def tk_widget_class_for(underscored_widget_name)
|
48
48
|
tk_widget_class_basename = underscored_widget_name.camelcase(:upper)
|
49
|
+
# TODO consider exposing this via Glimmer::Config
|
49
50
|
potential_tk_widget_class_names = [
|
50
51
|
"::Tk::Tile::#{tk_widget_class_basename}",
|
51
|
-
"::Tk::#{tk_widget_class_basename}",
|
52
|
+
"::Tk::BWidget::#{tk_widget_class_basename}",
|
53
|
+
"::Tk::Iwidgets::#{tk_widget_class_basename}",
|
52
54
|
"::Tk#{tk_widget_class_basename}",
|
55
|
+
"::Tk::#{tk_widget_class_basename}",
|
53
56
|
"::Glimmer::Tk::#{tk_widget_class_basename}Proxy",
|
54
57
|
]
|
55
58
|
tk_widget_class = nil
|
@@ -79,7 +82,7 @@ module Glimmer
|
|
79
82
|
@block = block
|
80
83
|
build_widget
|
81
84
|
# a common widget initializer
|
82
|
-
@parent_proxy
|
85
|
+
@parent_proxy&.post_initialize_child(self)
|
83
86
|
initialize_defaults
|
84
87
|
post_add_content if @block.nil?
|
85
88
|
end
|
@@ -124,6 +127,7 @@ module Glimmer
|
|
124
127
|
end
|
125
128
|
|
126
129
|
def tk_widget_has_attribute_setter?(attribute)
|
130
|
+
return true if @tk.respond_to?(attribute) && attribute != 'focus' # TODO configure exceptions via constant if needed
|
127
131
|
result = nil
|
128
132
|
begin
|
129
133
|
# TK Widget currently doesn't support respond_to? properly, so I have to resort to this trick for now
|
@@ -249,7 +253,6 @@ module Glimmer
|
|
249
253
|
|
250
254
|
def grid(options = {})
|
251
255
|
options = options.stringify_keys
|
252
|
-
index_in_parent = @parent_proxy&.children&.index(self)
|
253
256
|
options['rowspan'] = options.delete('row_span') if options.keys.include?('row_span')
|
254
257
|
options['columnspan'] = options.delete('column_span') if options.keys.include?('column_span')
|
255
258
|
options['rowweight'] = options.delete('row_weight') if options.keys.include?('row_weight')
|
@@ -262,13 +265,14 @@ module Glimmer
|
|
262
265
|
options['columnminsize'] = options.delete('minwidth') if options.keys.include?('minwidth')
|
263
266
|
options['columnminsize'] = options.delete('min_width') if options.keys.include?('min_width')
|
264
267
|
options['columnminsize'] = options['rowminsize'] = options.delete('minsize') if options.keys.include?('minsize')
|
268
|
+
index_in_parent = griddable_parent_proxy&.children&.index(griddable_proxy)
|
265
269
|
if index_in_parent
|
266
|
-
TkGrid.rowconfigure(
|
267
|
-
TkGrid.rowconfigure(
|
268
|
-
TkGrid.columnconfigure(
|
269
|
-
TkGrid.columnconfigure(
|
270
|
+
TkGrid.rowconfigure(griddable_parent_proxy.tk, index_in_parent, 'weight'=> options.delete('rowweight')) if options.keys.include?('rowweight')
|
271
|
+
TkGrid.rowconfigure(griddable_parent_proxy.tk, index_in_parent, 'minsize'=> options.delete('rowminsize')) if options.keys.include?('rowminsize')
|
272
|
+
TkGrid.columnconfigure(griddable_parent_proxy.tk, index_in_parent, 'weight'=> options.delete('columnweight')) if options.keys.include?('columnweight')
|
273
|
+
TkGrid.columnconfigure(griddable_parent_proxy.tk, index_in_parent, 'minsize'=> options.delete('columnminsize')) if options.keys.include?('columnminsize')
|
270
274
|
end
|
271
|
-
|
275
|
+
griddable_proxy&.tk&.grid(options)
|
272
276
|
end
|
273
277
|
|
274
278
|
def font=(value)
|
@@ -380,6 +384,7 @@ module Glimmer
|
|
380
384
|
if observer.is_a?(Glimmer::DataBinding::ModelBinding)
|
381
385
|
model = observer.model
|
382
386
|
options_model_property = observer.property_name + '_options'
|
387
|
+
# TODO perform data-binding to values too
|
383
388
|
@tk.values = model.send(options_model_property) if model.respond_to?(options_model_property)
|
384
389
|
end
|
385
390
|
@tk.bind('<ComboboxSelected>') {
|
@@ -450,6 +455,7 @@ module Glimmer
|
|
450
455
|
|
451
456
|
def handle_listener(listener_name, &listener)
|
452
457
|
listener_name = listener_name.to_s
|
458
|
+
# TODO return a listener registration object that has a deregister method
|
453
459
|
if listener_name == 'destroy'
|
454
460
|
# 'destroy' is a more reliable alternative listener binding to '<Destroy>'
|
455
461
|
@on_destroy_procs ||= []
|
@@ -457,22 +463,26 @@ module Glimmer
|
|
457
463
|
@on_destroy_procs << listener
|
458
464
|
@tk.bind('<Destroy>', listener)
|
459
465
|
parent_proxy.handle_listener(listener_name, &listener) if parent_proxy
|
460
|
-
# TODO return a listener registration object that has a deregister method
|
461
466
|
else
|
462
467
|
@listeners ||= {}
|
463
468
|
begin
|
464
469
|
@listeners[listener_name] ||= []
|
465
|
-
@tk.
|
470
|
+
if @tk.respond_to?(listener_name)
|
471
|
+
@tk.send(listener_name) { |*args| @listeners[listener_name].each {|l| l.call(*args)} } if @listeners[listener_name].empty?
|
472
|
+
else
|
473
|
+
@tk.bind(listener_name) { |*args| @listeners[listener_name].each {|l| l.call(*args)} } if @listeners[listener_name].empty?
|
474
|
+
end
|
466
475
|
@listeners[listener_name] << listener
|
467
476
|
rescue => e
|
468
477
|
@listeners.delete(listener_name)
|
469
|
-
Glimmer::Config.logger.debug {"Unable to bind to #{listener_name} .. attempting to surround with <>"}
|
478
|
+
Glimmer::Config.logger.debug {"Unable to bind to #{listener_name} .. attempting to surround with <> ..."}
|
470
479
|
Glimmer::Config.logger.debug {e.full_message}
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
@
|
475
|
-
@listeners[
|
480
|
+
new_listener_name = listener_name
|
481
|
+
new_listener_name = "<#{new_listener_name}" if !new_listener_name.start_with?('<')
|
482
|
+
new_listener_name = "#{new_listener_name}>" if !new_listener_name.end_with?('>')
|
483
|
+
@listeners[new_listener_name] ||= []
|
484
|
+
@tk.bind(new_listener_name) { |*args| @listeners[new_listener_name].each {|l| l.call(*args)} } if @listeners[new_listener_name].empty?
|
485
|
+
@listeners[new_listener_name] << listener
|
476
486
|
end
|
477
487
|
end
|
478
488
|
end
|
@@ -506,6 +516,16 @@ module Glimmer
|
|
506
516
|
|
507
517
|
private
|
508
518
|
|
519
|
+
# The griddable parent widget proxy to apply grid to (is different from @tk in composite widgets like notebook or scrolledframe)
|
520
|
+
def griddable_parent_proxy
|
521
|
+
@parent_proxy
|
522
|
+
end
|
523
|
+
|
524
|
+
# The griddable widget proxy to apply grid to (is different from @tk in composite widgets like notebook or scrolledframe)
|
525
|
+
def griddable_proxy
|
526
|
+
self
|
527
|
+
end
|
528
|
+
|
509
529
|
def build_widget
|
510
530
|
tk_widget_class = self.class.tk_widget_class_for(@keyword)
|
511
531
|
@tk = tk_widget_class.new(@parent_proxy.tk, *args)
|
data/lib/glimmer-dsl-tk.rb
CHANGED
@@ -27,6 +27,8 @@ require 'glimmer'
|
|
27
27
|
require 'puts_debuggerer' if ENV['pd'].to_s.downcase == 'true'
|
28
28
|
# require 'super_module'
|
29
29
|
require 'tk'
|
30
|
+
#require 'tkextlib/bwidget' # does not work on Windows
|
31
|
+
#require 'tkextlib/iwidgets' # does not work on Windows
|
30
32
|
require 'os'
|
31
33
|
require 'facets/hash/symbolize_keys'
|
32
34
|
require 'facets/string/underscore'
|
@@ -37,10 +39,20 @@ require 'delegate'
|
|
37
39
|
# require 'ext/glimmer/config'
|
38
40
|
# require 'ext/glimmer'
|
39
41
|
require 'glimmer/dsl/tk/dsl'
|
42
|
+
|
40
43
|
Glimmer::Config.loop_max_count = -1
|
44
|
+
|
41
45
|
Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
|
42
46
|
method = method_symbol.to_s
|
43
47
|
result = false
|
44
48
|
result ||= method == 'load_iseq'
|
45
49
|
end
|
50
|
+
|
51
|
+
Tk::Tile::Style.theme_use 'alt' if OS.linux?
|
52
|
+
|
46
53
|
::TkOption.add '*tearOff', 0
|
54
|
+
|
55
|
+
class ::Tk::TkSysMenu_Window < Tk::Menu
|
56
|
+
include Tk::SystemMenu
|
57
|
+
SYSMENU_NAME = 'window'
|
58
|
+
end
|
@@ -130,6 +130,16 @@ class MetaSample
|
|
130
130
|
grid row: 0, column: 1, column_weight: 1
|
131
131
|
value File.read(file_path_for(selected_sample))
|
132
132
|
}
|
133
|
+
|
134
|
+
@yscrollbar = scrollbar {
|
135
|
+
grid row: 0, column: 2
|
136
|
+
}
|
137
|
+
@code_text.yscrollbar @yscrollbar
|
138
|
+
|
139
|
+
@xscrollbar = scrollbar {
|
140
|
+
grid row: 1, column: 1, column_span: 2
|
141
|
+
}
|
142
|
+
@code_text.xscrollbar @xscrollbar
|
133
143
|
}
|
134
144
|
@root.open
|
135
145
|
end
|
@@ -47,7 +47,7 @@ class HelloButton
|
|
47
47
|
default 'active'
|
48
48
|
focus true
|
49
49
|
|
50
|
-
command {
|
50
|
+
on('command') {
|
51
51
|
self.count += 1
|
52
52
|
}
|
53
53
|
}
|
@@ -64,7 +64,7 @@ class HelloButton
|
|
64
64
|
button {
|
65
65
|
image File.expand_path('../../icons/glimmer.png', __dir__), subsample: 5
|
66
66
|
|
67
|
-
command {
|
67
|
+
on('command') {
|
68
68
|
message_box(title: 'Image Button', message: 'Image Button Clicked!')
|
69
69
|
}
|
70
70
|
}
|
@@ -81,10 +81,10 @@ class HelloButton
|
|
81
81
|
['center', 'top', 'bottom', 'left', 'right'].each do |compound_option|
|
82
82
|
button {
|
83
83
|
image File.expand_path('../../icons/glimmer.png', __dir__), subsample: 5
|
84
|
-
text
|
84
|
+
text "#{compound_option.capitalize} Image"
|
85
85
|
compound compound_option
|
86
86
|
|
87
|
-
command {
|
87
|
+
on('command') {
|
88
88
|
message_box(title: 'Text Image Button', message: 'Text Image Button Clicked!', detail: "(#{compound_option})")
|
89
89
|
}
|
90
90
|
}
|