glimmer-dsl-tk 0.0.51 → 0.0.55
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/LICENSE.txt +1 -1
- data/README.md +316 -32
- data/VERSION +1 -1
- data/bin/girb +1 -1
- data/bin/girb_runner.rb +1 -1
- data/glimmer-dsl-tk.gemspec +0 -0
- data/lib/glimmer/data_binding/tk/list_selection_binding.rb +1 -1
- data/lib/glimmer/data_binding/tk/one_time_observer.rb +1 -1
- data/lib/glimmer/data_binding/tk/widget_binding.rb +1 -1
- data/lib/glimmer/dsl/tk/attribute_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/bind_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/block_attribute_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/built_in_dialog_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/dsl.rb +1 -1
- data/lib/glimmer/dsl/tk/format_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/list_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/message_box_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/on_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/root_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/shine_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/widget_expression.rb +1 -1
- data/lib/glimmer/tk/checkbutton_proxy.rb +1 -1
- data/lib/glimmer/tk/combobox_proxy.rb +1 -1
- data/lib/glimmer/tk/drag_and_drop_event.rb +21 -0
- data/lib/glimmer/tk/draggable_and_droppable.rb +1 -1
- data/lib/glimmer/tk/entry_proxy.rb +1 -1
- data/lib/glimmer/tk/frame_proxy.rb +1 -1
- data/lib/glimmer/tk/label_proxy.rb +1 -1
- data/lib/glimmer/tk/labelframe_proxy.rb +39 -0
- data/lib/glimmer/tk/lbl_proxy.rb +1 -1
- data/lib/glimmer/tk/list_proxy.rb +1 -1
- data/lib/glimmer/tk/menu_item_proxy.rb +10 -2
- data/lib/glimmer/tk/menu_proxy.rb +1 -1
- data/lib/glimmer/tk/notebook_proxy.rb +1 -1
- data/lib/glimmer/tk/os.rb +1 -1
- data/lib/glimmer/tk/radiobutton_proxy.rb +1 -1
- data/lib/glimmer/tk/root_proxy.rb +1 -1
- data/lib/glimmer/tk/scale_proxy.rb +48 -0
- data/lib/glimmer/tk/scrollbar_frame_proxy.rb +1 -1
- data/lib/glimmer/tk/spinbox_proxy.rb +1 -1
- data/lib/glimmer/tk/text_proxy.rb +1 -1
- data/lib/glimmer/tk/text_variable_owner.rb +1 -1
- data/lib/glimmer/tk/toplevel_proxy.rb +2 -2
- data/lib/glimmer/tk/treeview_proxy.rb +1 -1
- data/lib/glimmer/tk/variable_owner.rb +1 -1
- data/lib/glimmer/tk/widget.rb +1 -1
- data/lib/glimmer/tk/widget_proxy.rb +21 -3
- data/lib/glimmer-dsl-tk.rb +1 -1
- data/samples/elaborate/meta_sample.rb +1 -1
- data/samples/hello/hello_built_in_dialog.rb +1 -1
- data/samples/hello/hello_button.rb +1 -1
- data/samples/hello/hello_checkbutton.rb +1 -1
- data/samples/hello/hello_combobox.rb +1 -2
- data/samples/hello/hello_computed.rb +1 -1
- data/samples/hello/hello_contextual_menu.rb +1 -1
- data/samples/hello/hello_drag_and_drop.rb +1 -1
- data/samples/hello/hello_entry.rb +1 -1
- data/samples/hello/hello_frame.rb +1 -1
- data/samples/hello/hello_label.rb +1 -1
- data/samples/hello/hello_labelframe.rb +161 -0
- data/samples/hello/hello_list_multi_selection.rb +1 -1
- data/samples/hello/hello_list_single_selection.rb +1 -1
- data/samples/hello/hello_menu_bar.rb +5 -2
- data/samples/hello/hello_message_box.rb +1 -1
- data/samples/hello/hello_notebook.rb +1 -1
- data/samples/hello/hello_radiobutton.rb +1 -1
- data/samples/hello/hello_root.rb +1 -1
- data/samples/hello/hello_scale.rb +53 -0
- data/samples/hello/hello_scrollbar.rb +1 -1
- data/samples/hello/hello_scrollbar_frame.rb +1 -1
- data/samples/hello/hello_separator.rb +1 -1
- data/samples/hello/hello_spinbox.rb +1 -1
- data/samples/hello/hello_text.rb +1 -1
- data/samples/hello/hello_toplevel.rb +1 -1
- data/samples/hello/hello_world.rb +1 -1
- metadata +9 -5
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2020-2022 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
|
+
|
1
22
|
module Glimmer
|
2
23
|
module Tk
|
3
24
|
DragAndDropEvent = Struct.new(:source, :target, :tooltip, :x_root, :y_root, :data, :drop_accepted) do
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 2020-2022 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
|
+
require 'glimmer/tk/notebook_proxy'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module Tk
|
27
|
+
# Proxy for Tk::Tile::Labelframe
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class LabelframeProxy < WidgetProxy
|
31
|
+
private
|
32
|
+
|
33
|
+
def initialize_defaults
|
34
|
+
super
|
35
|
+
self.padding = 15
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/glimmer/tk/lbl_proxy.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2020-
|
1
|
+
# Copyright (c) 2020-2022 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -43,6 +43,7 @@ module Glimmer
|
|
43
43
|
def initialize(underscored_widget_name, parent_proxy, args, &block)
|
44
44
|
@options = args.last.is_a?(Hash) ? args.last : {}
|
45
45
|
@label = @options[:label]
|
46
|
+
@label ||= 'About' if args.first == :about
|
46
47
|
super
|
47
48
|
end
|
48
49
|
|
@@ -61,10 +62,17 @@ module Glimmer
|
|
61
62
|
def accelerator_event
|
62
63
|
accelerator_parts = @accelerator.split('+')
|
63
64
|
accelerator_parts.map do |accelerator_part|
|
64
|
-
ACCELERATOR_MODIFIER_EVENT_MAP[accelerator_part.capitalize] ||
|
65
|
+
ACCELERATOR_MODIFIER_EVENT_MAP[accelerator_part.capitalize] ||
|
66
|
+
(accelerator_part.size == 1 && accelerator_part.downcase) ||
|
67
|
+
(function_key?(accelerator_part) && accelerator_part.upcase) ||
|
68
|
+
accelerator_part
|
65
69
|
end.join('-')
|
66
70
|
end
|
67
71
|
|
72
|
+
def function_key?(string)
|
73
|
+
string.downcase.match(/^f\d+$/)
|
74
|
+
end
|
75
|
+
|
68
76
|
def label=(value)
|
69
77
|
@last_label = @label
|
70
78
|
@label = value
|
data/lib/glimmer/tk/os.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Copyright (c) 2020-2022 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
|
+
require 'glimmer/tk/variable_owner'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module Tk
|
27
|
+
# Proxy for Tk::Tile::TScale
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class ScaleProxy < WidgetProxy
|
31
|
+
include VariableOwner
|
32
|
+
|
33
|
+
def command_block=(proc)
|
34
|
+
tk.command(proc)
|
35
|
+
end
|
36
|
+
|
37
|
+
def handle_listener(listener_name, &listener)
|
38
|
+
case listener_name.to_s.downcase
|
39
|
+
when 'command', 'change'
|
40
|
+
command(&listener)
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2020-
|
1
|
+
# Copyright (c) 2020-2022 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -29,7 +29,7 @@ module Glimmer
|
|
29
29
|
class ToplevelProxy < WidgetProxy
|
30
30
|
REGEX_GEOMETRY = /[x+-]/
|
31
31
|
DEFAULT_WIDTH = 190
|
32
|
-
DEFAULT_HEIGHT =
|
32
|
+
DEFAULT_HEIGHT = 0
|
33
33
|
|
34
34
|
attr_reader :tk
|
35
35
|
attr_accessor :escapable
|
data/lib/glimmer/tk/widget.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2020-
|
1
|
+
# Copyright (c) 2020-2022 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -369,6 +369,12 @@ module Glimmer
|
|
369
369
|
setter: {name: 'text=', invoker: lambda { |widget, args| @tk.textvariable&.value = args.first }},
|
370
370
|
},
|
371
371
|
},
|
372
|
+
::Tk::Tile::TScale => {
|
373
|
+
'variable' => {
|
374
|
+
getter: {name: 'variable', invoker: lambda { |widget, args| @tk.variable&.value }},
|
375
|
+
setter: {name: 'variable=', invoker: lambda { |widget, args| @tk.variable&.value = args.first }},
|
376
|
+
},
|
377
|
+
},
|
372
378
|
::Tk::Root => {
|
373
379
|
'text' => {
|
374
380
|
getter: {name: 'text', invoker: lambda { |widget, args| @tk.title }},
|
@@ -393,8 +399,13 @@ module Glimmer
|
|
393
399
|
if observer.is_a?(Glimmer::DataBinding::ModelBinding)
|
394
400
|
model = observer.model
|
395
401
|
options_model_property = observer.property_name + '_options'
|
396
|
-
|
397
|
-
|
402
|
+
if model.respond_to?(options_model_property)
|
403
|
+
options_observer = Glimmer::DataBinding::Observer.proc do
|
404
|
+
@tk.values = model.send(options_model_property)
|
405
|
+
end
|
406
|
+
options_observer.observe(model, options_model_property)
|
407
|
+
options_observer.call
|
408
|
+
end
|
398
409
|
end
|
399
410
|
@tk.bind('<ComboboxSelected>') {
|
400
411
|
observer.call(@tk.textvariable.value)
|
@@ -423,6 +434,13 @@ module Glimmer
|
|
423
434
|
}
|
424
435
|
end,
|
425
436
|
},
|
437
|
+
::Tk::Tile::TScale => {
|
438
|
+
'variable' => lambda do |observer|
|
439
|
+
@tk.command {
|
440
|
+
observer.call(@tk.variable&.value)
|
441
|
+
}
|
442
|
+
end,
|
443
|
+
},
|
426
444
|
::Tk::Text => {
|
427
445
|
'value' => lambda do |observer|
|
428
446
|
handle_listener('modified') do
|
data/lib/glimmer-dsl-tk.rb
CHANGED
@@ -0,0 +1,161 @@
|
|
1
|
+
# Copyright (c) 2020-2022 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 {
|
27
|
+
title 'Hello, Labelframe!'
|
28
|
+
|
29
|
+
labelframe {
|
30
|
+
grid column: 0, row: 0, padx: 10, pady: 10
|
31
|
+
text 'Name:'
|
32
|
+
# labelanchor 'nw' # Default. Other options: 'n', 'ne', 'en', 'e', 'es', 'se', 's', 'sw', 'ws', 'w', 'wn'
|
33
|
+
|
34
|
+
label {
|
35
|
+
grid column: 0, row: 0, sticky: 'w'
|
36
|
+
text 'First Name:'
|
37
|
+
}
|
38
|
+
entry {
|
39
|
+
grid column: 1, row: 0
|
40
|
+
width 15
|
41
|
+
}
|
42
|
+
|
43
|
+
label {
|
44
|
+
grid column: 0, row: 1, sticky: 'w'
|
45
|
+
text 'Last Name:'
|
46
|
+
}
|
47
|
+
entry {
|
48
|
+
grid column: 1, row: 1
|
49
|
+
width 15
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
labelframe {
|
54
|
+
grid column: 0, row: 1, padx: 10, pady: 10
|
55
|
+
text 'Address:'
|
56
|
+
|
57
|
+
label {
|
58
|
+
grid column: 0, row: 0, sticky: 'w'
|
59
|
+
text 'Street:'
|
60
|
+
}
|
61
|
+
entry {
|
62
|
+
grid column: 1, row: 0
|
63
|
+
width 15
|
64
|
+
}
|
65
|
+
|
66
|
+
label {
|
67
|
+
grid column: 0, row: 1, sticky: 'w'
|
68
|
+
text 'City:'
|
69
|
+
}
|
70
|
+
entry {
|
71
|
+
grid column: 1, row: 1
|
72
|
+
width 15
|
73
|
+
}
|
74
|
+
|
75
|
+
label {
|
76
|
+
grid column: 0, row: 2, sticky: 'w'
|
77
|
+
text 'State:'
|
78
|
+
}
|
79
|
+
entry {
|
80
|
+
grid column: 1, row: 2
|
81
|
+
width 15
|
82
|
+
}
|
83
|
+
|
84
|
+
label {
|
85
|
+
grid column: 0, row: 3, sticky: 'w'
|
86
|
+
text 'Zip:'
|
87
|
+
}
|
88
|
+
entry {
|
89
|
+
grid column: 1, row: 3
|
90
|
+
width 15
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
labelframe {
|
95
|
+
grid column: 1, row: 0, rowspan: 2, padx: 10, pady: 10
|
96
|
+
text 'Medical Info:'
|
97
|
+
|
98
|
+
label {
|
99
|
+
grid column: 0, row: 0, sticky: 'w'
|
100
|
+
text 'Family Doctor:'
|
101
|
+
}
|
102
|
+
entry {
|
103
|
+
grid column: 1, row: 0
|
104
|
+
width 15
|
105
|
+
}
|
106
|
+
|
107
|
+
label {
|
108
|
+
grid column: 0, row: 1, sticky: 'w'
|
109
|
+
text 'Chronic Conditions:'
|
110
|
+
}
|
111
|
+
entry {
|
112
|
+
grid column: 1, row: 1
|
113
|
+
width 15
|
114
|
+
}
|
115
|
+
|
116
|
+
label {
|
117
|
+
grid column: 0, row: 2, sticky: 'w'
|
118
|
+
text 'Past Surgeries:'
|
119
|
+
}
|
120
|
+
entry {
|
121
|
+
grid column: 1, row: 2
|
122
|
+
width 15
|
123
|
+
}
|
124
|
+
|
125
|
+
label {
|
126
|
+
grid column: 0, row: 3, sticky: 'w'
|
127
|
+
text 'Health Insurance Info:'
|
128
|
+
}
|
129
|
+
entry {
|
130
|
+
grid column: 1, row: 3
|
131
|
+
width 15
|
132
|
+
}
|
133
|
+
|
134
|
+
label {
|
135
|
+
grid column: 0, row: 4, sticky: 'w'
|
136
|
+
text 'Dental Insurance Info:'
|
137
|
+
}
|
138
|
+
entry {
|
139
|
+
grid column: 1, row: 4
|
140
|
+
width 15
|
141
|
+
}
|
142
|
+
|
143
|
+
label {
|
144
|
+
grid column: 0, row: 5, sticky: 'w'
|
145
|
+
text 'Diet:'
|
146
|
+
}
|
147
|
+
entry {
|
148
|
+
grid column: 1, row: 5
|
149
|
+
width 15
|
150
|
+
}
|
151
|
+
|
152
|
+
label {
|
153
|
+
grid column: 0, row: 6, sticky: 'w'
|
154
|
+
text 'Exercise:'
|
155
|
+
}
|
156
|
+
entry {
|
157
|
+
grid column: 1, row: 6
|
158
|
+
width 15
|
159
|
+
}
|
160
|
+
}
|
161
|
+
}.open
|