glimmer-dsl-tk 0.0.18 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/README.md +429 -21
- data/VERSION +1 -1
- data/glimmer-dsl-tk.gemspec +0 -0
- data/lib/glimmer/dsl/tk/message_box_expression.rb +4 -1
- data/lib/glimmer/dsl/tk/on_expression.rb +35 -0
- data/lib/glimmer/dsl/tk/widget_expression.rb +0 -7
- data/lib/glimmer/tk/button_proxy.rb +2 -3
- data/lib/glimmer/tk/checkbutton_proxy.rb +36 -0
- data/lib/glimmer/tk/combobox_proxy.rb +34 -0
- data/lib/glimmer/tk/commandable.rb +42 -0
- data/lib/glimmer/tk/entry_proxy.rb +3 -0
- data/lib/glimmer/tk/frame_proxy.rb +1 -0
- data/lib/glimmer/tk/label_proxy.rb +3 -0
- data/lib/glimmer/tk/notebook_proxy.rb +3 -8
- data/lib/glimmer/tk/radiobutton_proxy.rb +46 -0
- data/lib/glimmer/tk/root_proxy.rb +122 -2
- data/lib/glimmer/tk/text_variable_owner.rb +31 -0
- data/lib/glimmer/tk/variable_owner.rb +31 -0
- data/lib/glimmer/tk/widget_proxy.rb +102 -23
- data/lib/glimmer-dsl-tk.rb +1 -0
- data/samples/hello/hello_checkbutton.rb +131 -0
- data/samples/hello/hello_notebook.rb +1 -1
- data/samples/hello/hello_radiobutton.rb +87 -0
- data/samples/hello/hello_root.rb +48 -0
- metadata +45 -15
@@ -26,8 +26,8 @@ module Glimmer
|
|
26
26
|
# Follows the Proxy Design Pattern
|
27
27
|
class WidgetProxy
|
28
28
|
class << self
|
29
|
-
def create(keyword, parent, args)
|
30
|
-
widget_proxy_class(keyword).new(keyword, parent, args)
|
29
|
+
def create(keyword, parent, args, &block)
|
30
|
+
widget_proxy_class(keyword).new(keyword, parent, args, &block)
|
31
31
|
end
|
32
32
|
|
33
33
|
def widget_proxy_class(keyword)
|
@@ -61,38 +61,31 @@ module Glimmer
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
attr_reader :parent_proxy, :tk, :args, :keyword
|
64
|
+
attr_reader :parent_proxy, :tk, :args, :keyword, :children
|
65
65
|
|
66
|
-
DEFAULT_INITIALIZERS = {
|
67
|
-
'combobox' => lambda do |tk|
|
68
|
-
tk.textvariable = ::TkVariable.new
|
69
|
-
end,
|
70
|
-
'label' => lambda do |tk|
|
71
|
-
tk.textvariable = ::TkVariable.new
|
72
|
-
end,
|
73
|
-
'entry' => lambda do |tk|
|
74
|
-
tk.textvariable = ::TkVariable.new
|
75
|
-
end,
|
76
|
-
}
|
77
|
-
|
78
66
|
# Initializes a new Tk Widget
|
79
67
|
#
|
80
68
|
# Styles is a comma separate list of symbols representing Tk styles in lower case
|
81
|
-
def initialize(underscored_widget_name, parent_proxy, args)
|
69
|
+
def initialize(underscored_widget_name, parent_proxy, args, &block)
|
82
70
|
@parent_proxy = parent_proxy
|
83
71
|
@args = args
|
84
72
|
@keyword = underscored_widget_name
|
73
|
+
@block = block
|
85
74
|
tk_widget_class = self.class.tk_widget_class_for(underscored_widget_name)
|
86
75
|
@tk = tk_widget_class.new(@parent_proxy.tk, *args)
|
87
76
|
# a common widget initializer
|
88
|
-
|
89
|
-
DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@tk)
|
77
|
+
initialize_defaults
|
90
78
|
@parent_proxy.post_initialize_child(self)
|
79
|
+
post_add_content if @block.nil?
|
80
|
+
end
|
81
|
+
|
82
|
+
def children
|
83
|
+
@children ||= []
|
91
84
|
end
|
92
85
|
|
93
86
|
# Subclasses may override to perform post initialization work on an added child
|
94
87
|
def post_initialize_child(child)
|
95
|
-
|
88
|
+
children << child
|
96
89
|
end
|
97
90
|
|
98
91
|
# Subclasses may override to perform post add_content work
|
@@ -140,11 +133,17 @@ module Glimmer
|
|
140
133
|
end
|
141
134
|
end
|
142
135
|
|
136
|
+
def has_attributes_attribute?(attribute)
|
137
|
+
attribute = attribute.sub(/\?$/, '').sub(/=$/, '')
|
138
|
+
@tk.respond_to?(:attributes) && @tk.attributes.keys.include?(attribute.to_s)
|
139
|
+
end
|
140
|
+
|
143
141
|
def has_attribute?(attribute, *args)
|
144
142
|
(widget_custom_attribute_mapping[tk.class] and widget_custom_attribute_mapping[tk.class][attribute.to_s]) or
|
145
143
|
tk_widget_has_attribute_setter?(attribute) or
|
146
144
|
tk_widget_has_attribute_getter_setter?(attribute) or
|
147
145
|
has_state?(attribute) or
|
146
|
+
has_attributes_attribute?(attribute) or
|
148
147
|
respond_to?(attribute_setter(attribute), args)
|
149
148
|
end
|
150
149
|
|
@@ -153,7 +152,13 @@ module Glimmer
|
|
153
152
|
if widget_custom_attribute
|
154
153
|
widget_custom_attribute[:setter][:invoker].call(@tk, args)
|
155
154
|
elsif tk_widget_has_attribute_setter?(attribute)
|
156
|
-
|
155
|
+
unless args.size == 1 && @tk.send(attribute) == args.first
|
156
|
+
if args.size == 1
|
157
|
+
@tk.send(attribute_setter(attribute), *args)
|
158
|
+
else
|
159
|
+
@tk.send(attribute_setter(attribute), args)
|
160
|
+
end
|
161
|
+
end
|
157
162
|
elsif tk_widget_has_attribute_getter_setter?(attribute)
|
158
163
|
@tk.send(attribute, *args)
|
159
164
|
elsif has_state?(attribute)
|
@@ -163,6 +168,9 @@ module Glimmer
|
|
163
168
|
else
|
164
169
|
@tk.tile_state("!#{attribute}")
|
165
170
|
end
|
171
|
+
elsif has_attributes_attribute?(attribute)
|
172
|
+
attribute = attribute.sub(/=$/, '')
|
173
|
+
@tk.attributes(attribute, args.first)
|
166
174
|
else
|
167
175
|
send(attribute_setter(attribute), args)
|
168
176
|
end
|
@@ -176,6 +184,10 @@ module Glimmer
|
|
176
184
|
@tk.send(attribute)
|
177
185
|
elsif has_state?(attribute)
|
178
186
|
@tk.tile_instate(attribute.sub(/\?$/, ''))
|
187
|
+
elsif has_attributes_attribute?(attribute)
|
188
|
+
result = @tk.attributes[attribute.sub(/\?$/, '')]
|
189
|
+
result = result == 1 if result.is_a?(Integer)
|
190
|
+
result
|
179
191
|
else
|
180
192
|
send(attribute)
|
181
193
|
end
|
@@ -186,6 +198,7 @@ module Glimmer
|
|
186
198
|
end
|
187
199
|
|
188
200
|
def widget_custom_attribute_mapping
|
201
|
+
# TODO consider extracting to modules/subclasses
|
189
202
|
@widget_custom_attribute_mapping ||= {
|
190
203
|
::Tk::Tile::TButton => {
|
191
204
|
'image' => {
|
@@ -193,6 +206,30 @@ module Glimmer
|
|
193
206
|
setter: {name: 'image=', invoker: lambda { |widget, args| @tk.image = image_argument(args) }},
|
194
207
|
},
|
195
208
|
},
|
209
|
+
::Tk::Tile::TCheckbutton => {
|
210
|
+
'image' => {
|
211
|
+
getter: {name: 'image', invoker: lambda { |widget, args| @tk.image }},
|
212
|
+
setter: {name: 'image=', invoker: lambda { |widget, args| @tk.image = image_argument(args) }},
|
213
|
+
},
|
214
|
+
'variable' => {
|
215
|
+
getter: {name: 'variable', invoker: lambda { |widget, args| @tk.variable&.value.to_s == @tk.onvalue.to_s }},
|
216
|
+
setter: {name: 'variable=', invoker: lambda { |widget, args| @tk.variable&.value = args.first.is_a?(Integer) ? args.first : (args.first ? 1 : 0) }},
|
217
|
+
},
|
218
|
+
},
|
219
|
+
::Tk::Tile::TRadiobutton => {
|
220
|
+
'image' => {
|
221
|
+
getter: {name: 'image', invoker: lambda { |widget, args| @tk.image }},
|
222
|
+
setter: {name: 'image=', invoker: lambda { |widget, args| @tk.image = image_argument(args) }},
|
223
|
+
},
|
224
|
+
'text' => {
|
225
|
+
getter: {name: 'text', invoker: lambda { |widget, args| @tk.text }},
|
226
|
+
setter: {name: 'text=', invoker: lambda { |widget, args| @tk.value = @tk.text = args.first }},
|
227
|
+
},
|
228
|
+
'variable' => {
|
229
|
+
getter: {name: 'variable', invoker: lambda { |widget, args| @tk.variable&.value == @tk.value }},
|
230
|
+
setter: {name: 'variable=', invoker: lambda { |widget, args| @tk.variable&.value = args.first ? @tk.value : @tk.variable&.value }},
|
231
|
+
},
|
232
|
+
},
|
196
233
|
::Tk::Tile::TCombobox => {
|
197
234
|
'text' => {
|
198
235
|
getter: {name: 'text', invoker: lambda { |widget, args| @tk.textvariable&.value }},
|
@@ -215,11 +252,25 @@ module Glimmer
|
|
215
252
|
setter: {name: 'text=', invoker: lambda { |widget, args| @tk.textvariable&.value = args.first unless @text_variable_edit }},
|
216
253
|
},
|
217
254
|
},
|
255
|
+
::Tk::Root => {
|
256
|
+
'text' => {
|
257
|
+
getter: {name: 'text', invoker: lambda { |widget, args| @tk.title }},
|
258
|
+
setter: {name: 'text=', invoker: lambda { |widget, args| @tk.title = args.first }},
|
259
|
+
},
|
260
|
+
},
|
218
261
|
}
|
219
262
|
end
|
220
263
|
|
221
264
|
def widget_attribute_listener_installers
|
265
|
+
# TODO consider extracting to modules/subclasses
|
222
266
|
@tk_widget_attribute_listener_installers ||= {
|
267
|
+
::Tk::Tile::TCheckbutton => {
|
268
|
+
'variable' => lambda do |observer|
|
269
|
+
@tk.command {
|
270
|
+
observer.call(@tk.variable.value.to_s == @tk.onvalue.to_s)
|
271
|
+
}
|
272
|
+
end,
|
273
|
+
},
|
223
274
|
::Tk::Tile::TCombobox => {
|
224
275
|
'text' => lambda do |observer|
|
225
276
|
if observer.is_a?(Glimmer::DataBinding::ModelBinding)
|
@@ -247,6 +298,14 @@ module Glimmer
|
|
247
298
|
}
|
248
299
|
end,
|
249
300
|
},
|
301
|
+
::Tk::Tile::TRadiobutton => {
|
302
|
+
'variable' => lambda do |observer|
|
303
|
+
@tk.command {
|
304
|
+
pd @tk.variable.value, @tk.value
|
305
|
+
observer.call(@tk.variable.value == @tk.value)
|
306
|
+
}
|
307
|
+
end,
|
308
|
+
},
|
250
309
|
}
|
251
310
|
end
|
252
311
|
|
@@ -271,16 +330,28 @@ module Glimmer
|
|
271
330
|
widget_listener_installers = attribute_listener_installers.map{|installer| installer[attribute.to_s]}.compact if !attribute_listener_installers.empty?
|
272
331
|
widget_listener_installers.to_a.first&.call(observer)
|
273
332
|
end
|
274
|
-
|
333
|
+
|
334
|
+
def handle_listener(listener_name, &listener)
|
335
|
+
listener_name = listener_name.to_s
|
336
|
+
begin
|
337
|
+
@tk.bind(listener_name, &listener)
|
338
|
+
rescue => e
|
339
|
+
Glimmer::Config.logger.debug {e.full_message}
|
340
|
+
listener_name = "<#{listener_name}" if !listener_name.start_with?('<')
|
341
|
+
listener_name = "#{listener_name}>" if !listener_name.end_with?('>')
|
342
|
+
@tk.bind(listener_name, &listener)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
275
346
|
def content(&block)
|
276
347
|
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::WidgetExpression.new, keyword, *args, &block)
|
277
348
|
end
|
278
349
|
|
279
350
|
def method_missing(method, *args, &block)
|
280
351
|
method = method.to_s
|
281
|
-
if args.empty? && block.nil? && ((widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][method]) || has_state?(method))
|
352
|
+
if args.empty? && block.nil? && ((widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][method]) || has_state?(method) || has_attributes_attribute?(method))
|
282
353
|
get_attribute(method)
|
283
|
-
elsif method.end_with?('=') && block.nil? && ((widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][method.sub(/=$/, '')]) || has_state?(method))
|
354
|
+
elsif method.end_with?('=') && block.nil? && ((widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][method.sub(/=$/, '')]) || has_state?(method) || has_attributes_attribute?(method))
|
284
355
|
set_attribute(method.sub(/=$/, ''), *args)
|
285
356
|
else
|
286
357
|
tk.send(method, *args, &block)
|
@@ -294,6 +365,14 @@ module Glimmer
|
|
294
365
|
super ||
|
295
366
|
tk.respond_to?(method, *args, &block)
|
296
367
|
end
|
368
|
+
|
369
|
+
private
|
370
|
+
|
371
|
+
def initialize_defaults
|
372
|
+
@tk.grid unless @tk.is_a?(::Tk::Toplevel)
|
373
|
+
end
|
297
374
|
end
|
298
375
|
end
|
299
376
|
end
|
377
|
+
|
378
|
+
Dir[File.expand_path('./*_proxy.rb', __dir__)].each {|f| require f}
|
data/lib/glimmer-dsl-tk.rb
CHANGED
@@ -0,0 +1,131 @@
|
|
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-dsl-tk'
|
23
|
+
|
24
|
+
class HelloCheckbutton
|
25
|
+
class Person
|
26
|
+
attr_accessor :skiing, :snowboarding, :snowmobiling, :snowshoeing, :snow_activities, :snow_activities_alternate
|
27
|
+
|
28
|
+
def initialize
|
29
|
+
reset_activities!
|
30
|
+
individual_observer = Glimmer::DataBinding::Observer.proc do
|
31
|
+
unless @updating_group
|
32
|
+
@updating_individual = true
|
33
|
+
if skiing && snowboarding && snowmobiling && snowshoeing
|
34
|
+
self.snow_activities = true
|
35
|
+
self.snow_activities_alternate = false
|
36
|
+
elsif skiing || snowboarding || snowmobiling || snowshoeing
|
37
|
+
self.snow_activities = true
|
38
|
+
self.snow_activities_alternate = true
|
39
|
+
else
|
40
|
+
self.snow_activities = false
|
41
|
+
self.snow_activities_alternate = false
|
42
|
+
end
|
43
|
+
@updating_individual = false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
individual_observer.observe(self, :skiing)
|
47
|
+
individual_observer.observe(self, :snowboarding)
|
48
|
+
individual_observer.observe(self, :snowmobiling)
|
49
|
+
individual_observer.observe(self, :snowshoeing)
|
50
|
+
|
51
|
+
group_observer = Glimmer::DataBinding::Observer.proc do
|
52
|
+
unless @updating_individual
|
53
|
+
@updating_group = true
|
54
|
+
self.skiing = self.snow_activities
|
55
|
+
self.snowboarding = self.snow_activities
|
56
|
+
self.snowmobiling = self.snow_activities
|
57
|
+
self.snowshoeing = self.snow_activities
|
58
|
+
@updating_group = false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
group_observer.observe(self, :snow_activities)
|
62
|
+
end
|
63
|
+
|
64
|
+
def reset_activities!
|
65
|
+
self.snow_activities = true
|
66
|
+
self.snow_activities_alternate = true
|
67
|
+
self.skiing = false
|
68
|
+
self.snowboarding = true
|
69
|
+
self.snowmobiling = false
|
70
|
+
self.snowshoeing = false
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
include Glimmer
|
75
|
+
|
76
|
+
def initialize
|
77
|
+
@person = Person.new
|
78
|
+
end
|
79
|
+
|
80
|
+
def launch
|
81
|
+
root {
|
82
|
+
title 'Hello, Checkbutton!'
|
83
|
+
background '#ececec' if OS.mac?
|
84
|
+
|
85
|
+
label {
|
86
|
+
text 'Check all snow activities you are interested in:'
|
87
|
+
font 'caption'
|
88
|
+
}
|
89
|
+
|
90
|
+
frame {
|
91
|
+
checkbutton {
|
92
|
+
text 'Snow Activities'
|
93
|
+
variable <=> [@person, :snow_activities]
|
94
|
+
alternate <=> [@person, :snow_activities_alternate] # binds half-checked state
|
95
|
+
}
|
96
|
+
|
97
|
+
frame {
|
98
|
+
checkbutton {
|
99
|
+
text 'Skiing'
|
100
|
+
variable <=> [@person, :skiing]
|
101
|
+
}
|
102
|
+
|
103
|
+
checkbutton {
|
104
|
+
text 'Snowboarding'
|
105
|
+
variable <=> [@person, :snowboarding]
|
106
|
+
}
|
107
|
+
|
108
|
+
checkbutton {
|
109
|
+
text 'Snowmobiling'
|
110
|
+
variable <=> [@person, :snowmobiling]
|
111
|
+
}
|
112
|
+
|
113
|
+
checkbutton {
|
114
|
+
text 'Snowshoeing'
|
115
|
+
variable <=> [@person, :snowshoeing]
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
button {
|
121
|
+
text 'Reset Activities'
|
122
|
+
|
123
|
+
command do
|
124
|
+
@person.reset_activities!
|
125
|
+
end
|
126
|
+
}
|
127
|
+
}.open
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
HelloCheckbutton.new.launch
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'glimmer-dsl-tk'
|
2
|
+
|
3
|
+
class HelloRadiobutton
|
4
|
+
class Person
|
5
|
+
attr_accessor :male, :female, :child, :teen, :adult, :senior
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
reset!
|
9
|
+
end
|
10
|
+
|
11
|
+
def reset!
|
12
|
+
self.male = true
|
13
|
+
self.female = nil
|
14
|
+
self.child = nil
|
15
|
+
self.teen = nil
|
16
|
+
self.adult = true
|
17
|
+
self.senior = nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
include Glimmer
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@person = Person.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def launch
|
28
|
+
root {
|
29
|
+
title 'Hello, Radio!'
|
30
|
+
background '#ececec' if OS.mac?
|
31
|
+
|
32
|
+
label {
|
33
|
+
text 'Gender:'
|
34
|
+
font 'caption'
|
35
|
+
}
|
36
|
+
|
37
|
+
frame {
|
38
|
+
radiobutton {
|
39
|
+
text 'Male'
|
40
|
+
variable <=> [@person, :male]
|
41
|
+
}
|
42
|
+
|
43
|
+
radiobutton {
|
44
|
+
text 'Female'
|
45
|
+
variable <=> [@person, :female]
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
label {
|
50
|
+
text 'Age Group:'
|
51
|
+
font 'caption'
|
52
|
+
}
|
53
|
+
|
54
|
+
frame {
|
55
|
+
radiobutton {
|
56
|
+
text 'Child'
|
57
|
+
variable <=> [@person, :child]
|
58
|
+
}
|
59
|
+
|
60
|
+
radiobutton {
|
61
|
+
text 'Teen'
|
62
|
+
variable <=> [@person, :teen]
|
63
|
+
}
|
64
|
+
|
65
|
+
radiobutton {
|
66
|
+
text 'Adult'
|
67
|
+
variable <=> [@person, :adult]
|
68
|
+
}
|
69
|
+
|
70
|
+
radiobutton {
|
71
|
+
text 'Senior'
|
72
|
+
variable <=> [@person, :senior]
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
button {
|
77
|
+
text 'Reset'
|
78
|
+
|
79
|
+
command do
|
80
|
+
@person.reset!
|
81
|
+
end
|
82
|
+
}
|
83
|
+
}.open
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
HelloRadiobutton.new.launch
|
@@ -0,0 +1,48 @@
|
|
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-dsl-tk'
|
23
|
+
|
24
|
+
include Glimmer
|
25
|
+
|
26
|
+
root { |r|
|
27
|
+
title 'Hello, Root!'
|
28
|
+
iconphoto File.expand_path('../../icons/glimmer.png', __dir__)
|
29
|
+
width 400
|
30
|
+
height 200
|
31
|
+
x -150
|
32
|
+
y 300
|
33
|
+
resizable true # same as `resizable true, true`, meaning cannot resize horizontally and vertically
|
34
|
+
minsize 200, 100
|
35
|
+
maxsize 600, 400
|
36
|
+
background 'lightgrey'
|
37
|
+
alpha 0.85 # on the mac, you can set `transparent true` as well
|
38
|
+
topmost true
|
39
|
+
|
40
|
+
on('OPEN_WINDOW') do # custom event that runs right after Tk.mainloop
|
41
|
+
message_box(parent: r, title: 'Hi', message: 'Hi')
|
42
|
+
end
|
43
|
+
|
44
|
+
on('DELETE_WINDOW') do |event| # alias for WM_DELETE_WINDOW protocol event
|
45
|
+
message_box(parent: r, title: 'Bye', message: 'Bye')
|
46
|
+
exit(0)
|
47
|
+
end
|
48
|
+
}.open
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-tk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -39,47 +39,53 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.13.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: os
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 1.0.0
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.0.0
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
57
|
+
version: 1.0.0
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.0.0
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
62
|
+
name: tk
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
type: :
|
67
|
+
version: 0.4.0
|
68
|
+
type: :runtime
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
74
|
+
version: 0.4.0
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
76
|
+
name: rspec
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
79
|
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
81
|
+
version: 3.5.0
|
76
82
|
type: :development
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
86
|
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
88
|
+
version: 3.5.0
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: bundler
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,6 +148,20 @@ dependencies:
|
|
142
148
|
- - '='
|
143
149
|
- !ruby/object:Gem::Version
|
144
150
|
version: 0.8.23
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: json
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - '='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 2.5.1
|
158
|
+
type: :development
|
159
|
+
prerelease: false
|
160
|
+
version_requirements: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - '='
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: 2.5.1
|
145
165
|
- !ruby/object:Gem::Dependency
|
146
166
|
name: simplecov
|
147
167
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,19 +218,27 @@ files:
|
|
198
218
|
- lib/glimmer/dsl/tk/dsl.rb
|
199
219
|
- lib/glimmer/dsl/tk/list_selection_data_binding_expression.rb
|
200
220
|
- lib/glimmer/dsl/tk/message_box_expression.rb
|
221
|
+
- lib/glimmer/dsl/tk/on_expression.rb
|
201
222
|
- lib/glimmer/dsl/tk/root_expression.rb
|
202
223
|
- lib/glimmer/dsl/tk/shine_data_binding_expression.rb
|
203
224
|
- lib/glimmer/dsl/tk/widget_expression.rb
|
204
225
|
- lib/glimmer/tk/button_proxy.rb
|
226
|
+
- lib/glimmer/tk/checkbutton_proxy.rb
|
227
|
+
- lib/glimmer/tk/combobox_proxy.rb
|
228
|
+
- lib/glimmer/tk/commandable.rb
|
205
229
|
- lib/glimmer/tk/entry_proxy.rb
|
206
230
|
- lib/glimmer/tk/frame_proxy.rb
|
207
231
|
- lib/glimmer/tk/label_proxy.rb
|
208
232
|
- lib/glimmer/tk/list_proxy.rb
|
209
233
|
- lib/glimmer/tk/notebook_proxy.rb
|
234
|
+
- lib/glimmer/tk/radiobutton_proxy.rb
|
210
235
|
- lib/glimmer/tk/root_proxy.rb
|
236
|
+
- lib/glimmer/tk/text_variable_owner.rb
|
211
237
|
- lib/glimmer/tk/treeview_proxy.rb
|
238
|
+
- lib/glimmer/tk/variable_owner.rb
|
212
239
|
- lib/glimmer/tk/widget_proxy.rb
|
213
240
|
- samples/hello/hello_button.rb
|
241
|
+
- samples/hello/hello_checkbutton.rb
|
214
242
|
- samples/hello/hello_combobox.rb
|
215
243
|
- samples/hello/hello_computed.rb
|
216
244
|
- samples/hello/hello_computed/contact.rb
|
@@ -220,6 +248,8 @@ files:
|
|
220
248
|
- samples/hello/hello_list_single_selection.rb
|
221
249
|
- samples/hello/hello_message_box.rb
|
222
250
|
- samples/hello/hello_notebook.rb
|
251
|
+
- samples/hello/hello_radiobutton.rb
|
252
|
+
- samples/hello/hello_root.rb
|
223
253
|
- samples/hello/hello_world.rb
|
224
254
|
- samples/hello/images/denmark.png
|
225
255
|
- samples/hello/images/finland.png
|
@@ -250,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
280
|
- !ruby/object:Gem::Version
|
251
281
|
version: '0'
|
252
282
|
requirements: []
|
253
|
-
rubygems_version: 3.2.
|
283
|
+
rubygems_version: 3.2.22
|
254
284
|
signing_key:
|
255
285
|
specification_version: 4
|
256
286
|
summary: Glimmer DSL for Tk
|