glimmer-dsl-tk 0.0.34 → 0.0.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +464 -21
- data/VERSION +1 -1
- data/bin/girb_runner.rb +1 -1
- data/glimmer-dsl-tk.gemspec +0 -0
- data/lib/glimmer/dsl/tk/widget_expression.rb +1 -1
- data/lib/glimmer/tk/menu_item_proxy.rb +144 -0
- data/lib/glimmer/tk/menu_proxy.rb +48 -0
- data/lib/glimmer/tk/root_proxy.rb +1 -16
- data/lib/glimmer/tk/text_proxy.rb +25 -37
- data/lib/glimmer/tk/toplevel_proxy.rb +40 -0
- data/lib/glimmer/tk/widget_proxy.rb +18 -8
- data/lib/glimmer-dsl-tk.rb +4 -0
- data/samples/elaborate/meta_sample.rb +1 -1
- data/samples/hello/hello_checkbutton.rb +1 -1
- data/samples/hello/hello_menu_bar.rb +183 -0
- data/samples/hello/hello_text.rb +9 -9
- data/samples/hello/hello_toplevel.rb +178 -0
- metadata +6 -2
data/samples/hello/hello_text.rb
CHANGED
@@ -109,28 +109,28 @@ class HelloText
|
|
109
109
|
|
110
110
|
column_index = -1
|
111
111
|
|
112
|
-
combobox {
|
112
|
+
combobox { |cb|
|
113
113
|
grid row: 1, column: column_index += 1, column_weight: 1
|
114
114
|
readonly true
|
115
|
-
text <=> [self, :font_family, after_write: ->(value) { @text.toggle_selection_font_format('family', value == FONT_FAMILY_PROMPT ? 'Courier New' : value) }]
|
115
|
+
text <=> [self, :font_family, after_write: ->(value) { @text.toggle_selection_font_format('family', value == FONT_FAMILY_PROMPT ? 'Courier New' : value, focus: 100) }]
|
116
116
|
}
|
117
117
|
|
118
118
|
combobox {
|
119
119
|
grid row: 1, column: column_index += 1, column_weight: 1
|
120
120
|
readonly true
|
121
|
-
text <=> [self, :font_size, after_write: ->(value) { @text.toggle_selection_font_format('size', value == FONT_SIZE_PROMPT ? 13 : value) }]
|
121
|
+
text <=> [self, :font_size, after_write: ->(value) { @text.toggle_selection_font_format('size', value == FONT_SIZE_PROMPT ? 13 : value, focus: 100) }]
|
122
122
|
}
|
123
123
|
|
124
124
|
combobox {
|
125
125
|
grid row: 1, column: column_index += 1, column_weight: 1
|
126
126
|
readonly true
|
127
|
-
text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value) }]
|
127
|
+
text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value, focus: 100) }]
|
128
128
|
}
|
129
129
|
|
130
130
|
combobox {
|
131
131
|
grid row: 1, column: column_index += 1, column_weight: 1
|
132
132
|
readonly true
|
133
|
-
text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'white' : value) }]
|
133
|
+
text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'white' : value, focus: 100) }]
|
134
134
|
}
|
135
135
|
|
136
136
|
separator {
|
@@ -286,10 +286,6 @@ class HelloText
|
|
286
286
|
undo true
|
287
287
|
value <=> [self, :document]
|
288
288
|
|
289
|
-
on('KeyPress') do |event|
|
290
|
-
show_find_dialog if (event.keysym == 'f') && ((OS.mac? && event.state == 8) || (!OS.mac? && event.state == 4))
|
291
|
-
end
|
292
|
-
|
293
289
|
on('InsertMarkMoved') do
|
294
290
|
self.font_family = @text.applied_font_format_value('family')
|
295
291
|
self.font_size = @text.applied_font_format_value('size')
|
@@ -302,6 +298,10 @@ class HelloText
|
|
302
298
|
@justify_center_button.default = @text.applied_format_value('justify') == 'center' ? 'active' : 'normal'
|
303
299
|
@justify_right_button.default = @text.applied_format_value('justify') == 'right' ? 'active' : 'normal'
|
304
300
|
end
|
301
|
+
|
302
|
+
on('KeyPress') do |event|
|
303
|
+
show_find_dialog if (event.keysym == 'f') && ((OS.mac? && event.state == 8) || (!OS.mac? && event.state == 4))
|
304
|
+
end
|
305
305
|
}
|
306
306
|
}
|
307
307
|
@root.open
|
@@ -0,0 +1,178 @@
|
|
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
|
+
def toplevel_content
|
27
|
+
frame {
|
28
|
+
label {
|
29
|
+
text "This is a fully custom toplevel, meaning you can add any widgets here!\nYou can press the ESCAPE button on the keyboard to close."
|
30
|
+
}
|
31
|
+
separator
|
32
|
+
checkbutton {
|
33
|
+
text 'This is a checkbutton'
|
34
|
+
}
|
35
|
+
radiobutton {
|
36
|
+
text 'This is a radiobutton'
|
37
|
+
}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
root { |root_window|
|
42
|
+
title 'Hello, Toplevel!'
|
43
|
+
|
44
|
+
button {
|
45
|
+
text 'Nested Window'
|
46
|
+
|
47
|
+
on('command') do
|
48
|
+
toplevel(root_window) {
|
49
|
+
title 'Custom Window'
|
50
|
+
escapable true
|
51
|
+
x 150
|
52
|
+
y 180
|
53
|
+
width 500
|
54
|
+
height 200
|
55
|
+
minsize 500, 100
|
56
|
+
maxsize 1000, 300
|
57
|
+
|
58
|
+
toplevel_content
|
59
|
+
}
|
60
|
+
end
|
61
|
+
}
|
62
|
+
|
63
|
+
button {
|
64
|
+
text 'Transparent Window'
|
65
|
+
|
66
|
+
on('command') do
|
67
|
+
toplevel(root_window) {
|
68
|
+
title 'Transparent Window'
|
69
|
+
escapable true
|
70
|
+
alpha 0.85
|
71
|
+
width 250
|
72
|
+
height 100
|
73
|
+
resizable false, false # not resizable horizontally or vertically
|
74
|
+
|
75
|
+
frame {
|
76
|
+
label {
|
77
|
+
text "This is a transparent window\nYou can hit ESCAPE to close."
|
78
|
+
anchor 'center'
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
end
|
83
|
+
}
|
84
|
+
|
85
|
+
button {
|
86
|
+
text 'Fullscreen Window'
|
87
|
+
|
88
|
+
on('command') do
|
89
|
+
toplevel(root_window) {
|
90
|
+
title 'Fullscreen Window'
|
91
|
+
escapable true
|
92
|
+
fullscreen true
|
93
|
+
|
94
|
+
frame {
|
95
|
+
label {
|
96
|
+
text "This is a fullscreen window\nYou can hit ESCAPE to close."
|
97
|
+
anchor 'center'
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
end
|
102
|
+
}
|
103
|
+
|
104
|
+
if OS.mac?
|
105
|
+
# Mac has special support for mac styles in Tk `toplevel`
|
106
|
+
# `mac_style` first argument (`mac_class`) and second argument (`mac_attribute_list`) can be chosen from this page: https://wiki.tcl-lang.org/page/MacWindowStyle
|
107
|
+
|
108
|
+
button {
|
109
|
+
text 'Mac Plain (No-Button-Modeless) Window'
|
110
|
+
|
111
|
+
on('command') do
|
112
|
+
toplevel(root_window) { |t|
|
113
|
+
title 'Mac Plain (No-Button-Modeless) Window'
|
114
|
+
escapable true
|
115
|
+
mac_style 'plain'
|
116
|
+
|
117
|
+
toplevel_content
|
118
|
+
}
|
119
|
+
end
|
120
|
+
}
|
121
|
+
|
122
|
+
button {
|
123
|
+
text 'Mac Floating (Close-Button-Modeless) Window'
|
124
|
+
|
125
|
+
on('command') do
|
126
|
+
toplevel(root_window) { |t|
|
127
|
+
title 'Mac Floating (Close-Button-Modeless) Window'
|
128
|
+
escapable true
|
129
|
+
mac_style 'floating'
|
130
|
+
|
131
|
+
toplevel_content
|
132
|
+
}
|
133
|
+
end
|
134
|
+
}
|
135
|
+
|
136
|
+
button {
|
137
|
+
text 'Mac Document (All-Button-Modeless) Window'
|
138
|
+
|
139
|
+
on('command') do
|
140
|
+
toplevel(root_window) { |t|
|
141
|
+
title 'Mac Document (All-Button-Modeless) Window'
|
142
|
+
escapable true
|
143
|
+
mac_style 'document'
|
144
|
+
|
145
|
+
toplevel_content
|
146
|
+
}
|
147
|
+
end
|
148
|
+
}
|
149
|
+
|
150
|
+
button {
|
151
|
+
text 'Mac Utility (Close-Button-Modal) Dialog'
|
152
|
+
|
153
|
+
on('command') do
|
154
|
+
toplevel(root_window) { |t|
|
155
|
+
title 'Mac Utility (Close-Button-Modal) Dialog'
|
156
|
+
escapable true
|
157
|
+
mac_style 'utility'
|
158
|
+
|
159
|
+
toplevel_content
|
160
|
+
}
|
161
|
+
end
|
162
|
+
}
|
163
|
+
|
164
|
+
button {
|
165
|
+
text 'Mac Utility with Attribute List (All-Button-Modal) Dialog'
|
166
|
+
|
167
|
+
on('command') do
|
168
|
+
toplevel(root_window) { |t|
|
169
|
+
title 'Mac Utility with Attribute List (All-Button-Modal) Dialog'
|
170
|
+
escapable true
|
171
|
+
mac_style 'utility', 'closeBox collapseBox resizable horizontalZoom verticalZoom sideTitlebar'
|
172
|
+
|
173
|
+
toplevel_content
|
174
|
+
}
|
175
|
+
end
|
176
|
+
}
|
177
|
+
end
|
178
|
+
}.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.38
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -235,6 +235,8 @@ files:
|
|
235
235
|
- lib/glimmer/tk/frame_proxy.rb
|
236
236
|
- lib/glimmer/tk/label_proxy.rb
|
237
237
|
- lib/glimmer/tk/list_proxy.rb
|
238
|
+
- lib/glimmer/tk/menu_item_proxy.rb
|
239
|
+
- lib/glimmer/tk/menu_proxy.rb
|
238
240
|
- lib/glimmer/tk/notebook_proxy.rb
|
239
241
|
- lib/glimmer/tk/radiobutton_proxy.rb
|
240
242
|
- lib/glimmer/tk/root_proxy.rb
|
@@ -258,6 +260,7 @@ files:
|
|
258
260
|
- samples/hello/hello_label.rb
|
259
261
|
- samples/hello/hello_list_multi_selection.rb
|
260
262
|
- samples/hello/hello_list_single_selection.rb
|
263
|
+
- samples/hello/hello_menu_bar.rb
|
261
264
|
- samples/hello/hello_message_box.rb
|
262
265
|
- samples/hello/hello_notebook.rb
|
263
266
|
- samples/hello/hello_radiobutton.rb
|
@@ -265,6 +268,7 @@ files:
|
|
265
268
|
- samples/hello/hello_separator.rb
|
266
269
|
- samples/hello/hello_spinbox.rb
|
267
270
|
- samples/hello/hello_text.rb
|
271
|
+
- samples/hello/hello_toplevel.rb
|
268
272
|
- samples/hello/hello_world.rb
|
269
273
|
- samples/hello/images/align-center.png
|
270
274
|
- samples/hello/images/align-left.png
|