glimmer-dsl-tk 0.0.27 → 0.0.31

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.
@@ -25,14 +25,47 @@ class HelloText
25
25
  include Glimmer
26
26
 
27
27
  COLOR_OPTIONS = %w[black purple blue green orange yellow red white].map(&:capitalize)
28
- FOREGROUND_PROMPT = '<select foreground>'
29
- BACKGROUND_PROMPT = '<select background>'
28
+ FONT_FAMILY_OPTIONS = ::TkFont.families
29
+ FOREGROUND_PROMPT = '<foreground>'
30
+ BACKGROUND_PROMPT = '<background>'
31
+ FONT_FAMILY_PROMPT = '<font family>'
32
+ FONT_SIZE_PROMPT = '<font size>'
30
33
 
31
34
  def initialize
32
35
  @foreground = FOREGROUND_PROMPT
33
36
  @background = BACKGROUND_PROMPT
37
+ @font_family = FONT_FAMILY_PROMPT
38
+ @font_size = FONT_SIZE_PROMPT
39
+ @document = <<~MULTI_LINE_STRING
40
+ According to the National Post, a heavy metal-loving high school principal in Canada will be allowed to keep her job, days after a public campaign to oust her made headlines around the globe.
41
+
42
+ Parents at Eden High School in St. Catharines, Ontario launched a petition to remove principal Sharon Burns after discovering she's an IRON MAIDEN fan.
43
+
44
+ The petition, titled "Eden High School Principal, Sharon Burns, Needs to Be Transferred Immediately!" read, "We are deeply disturbed that the principal assigned to the school blatantly showed Satanic symbols and her allegiance to Satanic practices on her public social media platforms where all the students can see them under @edenprincipal (not her personal account)."
45
+
46
+ More than 500 people signed the petition to transfer Burns after she posted a picture of herself flashing the "devil horns" hand sign with a doll of the MAIDEN zombie mascot Eddie behind her as well as a personalized license plate reading "IRNMADEN" and a handwritten note that reads "Eddie 666" on a car's dashboard.
47
+
48
+
49
+ The number 666 is used to represent the devil, and is featured prominently in MAIDEN's artwork by the band, whose classic third album is titled "The Number Of The Beast".
50
+
51
+ The petition was later updated to state that the demand for her transfer is not because of her love for metal, but for "openly displaying her own handmade sign with the 666 clearly displayed on it".
52
+
53
+ The creator of the original petition wrote: "Sharon knows full well what she did was simply inappropriate, unnecessary and not professional but has yet to publicly admit so and is willing to allow people to believe a completely different story, making very real concerns seem petty."
54
+
55
+ Meanwhile, a counter-petition supporting Burns garnered over 20,000 signatures.
56
+
57
+ "It is ridiculous that a couple of parents judge her role as a principal only based on an Instagram post. (About liking the band IRON MAIDEN. That's it.) Eden High School is a public school. Not a Christian school," the petition titled "We need Mrs Burns" stated. "She has made Eden a safe space for so many people. She spreads nothing but love and kindness."
58
+
59
+ After the complaints were aired, the District School Board of Niagara spoke with Burns and the parents who launched the petition, and the issue is over as far as the board is concerned, Kim Sweeney, the board's chief communications officer, told the National Post. No disciplinary action or policy changes were needed.
60
+
61
+ "Our belief is that taste in music is subjective and we support that both students and staff enjoy a wide variety of genres," Sweeney said.
62
+
63
+ The original petition has since been removed.
64
+ MULTI_LINE_STRING
34
65
  end
35
66
 
67
+ attr_accessor :document, :find_text
68
+
36
69
  attr_accessor :foreground
37
70
 
38
71
  def foreground_options
@@ -45,15 +78,73 @@ class HelloText
45
78
  [BACKGROUND_PROMPT] + COLOR_OPTIONS
46
79
  end
47
80
 
81
+ attr_accessor :font_family
82
+
83
+ def font_family_options
84
+ [FONT_FAMILY_PROMPT] + FONT_FAMILY_OPTIONS
85
+ end
86
+
87
+ attr_accessor :font_size
88
+
89
+ def font_size_options
90
+ [FONT_SIZE_PROMPT] + (9..64).to_a.map(&:to_s)
91
+ end
92
+
93
+ def find
94
+ text_index = @text.search(/#{find_text}/i, @text.tag_ranges('sel')&.first&.last || @text.index('insert'))
95
+ unless text_index.to_s.empty?
96
+ @text.tag_remove('sel', '1.0', 'end')
97
+ @text.tag_add('sel', text_index, "#{text_index} + #{find_text.size} chars")
98
+ end
99
+ end
100
+
48
101
  def launch
49
- root {
102
+ root { |r|
50
103
  title 'Hello, Text!'
104
+ width 1280
105
+ height 800
51
106
 
52
107
  frame {
53
108
  grid row: 0, column: 0
54
109
 
110
+ label {
111
+ grid row: 0, column: 0, columnspan: 17
112
+ text 'Select a region of text and then apply formatting from the toolbar'
113
+ }
114
+
115
+ column_index = -1
116
+
117
+ combobox {
118
+ grid row: 1, column: column_index += 1, column_weight: 1
119
+ readonly true
120
+ text <=> [self, :font_family, after_write: ->(value) { @text.toggle_selection_font_format('family', value == FONT_FAMILY_PROMPT ? 'Courier New' : value) }]
121
+ }
122
+
123
+ combobox {
124
+ grid row: 1, column: column_index += 1, column_weight: 1
125
+ readonly true
126
+ text <=> [self, :font_size, after_write: ->(value) { @text.toggle_selection_font_format('size', value == FONT_SIZE_PROMPT ? 13 : value) }]
127
+ }
128
+
129
+ combobox {
130
+ grid row: 1, column: column_index += 1, column_weight: 1
131
+ readonly true
132
+ text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value) }]
133
+ }
134
+
135
+ combobox {
136
+ grid row: 1, column: column_index += 1, column_weight: 1
137
+ readonly true
138
+ text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'white' : value) }]
139
+ }
140
+
141
+ separator {
142
+ grid row: 1, column: column_index += 1, column_weight: 0
143
+ orient 'vertical'
144
+ }
145
+
55
146
  button {
56
- grid row: 0, column: 0, column_weight: 0
147
+ grid row: 1, column: column_index += 1, column_weight: 0
57
148
  text 'B'
58
149
  style font: {weight: 'bold'}
59
150
 
@@ -63,7 +154,7 @@ class HelloText
63
154
  }
64
155
 
65
156
  button {
66
- grid row: 0, column: 1, column_weight: 0
157
+ grid row: 1, column: column_index += 1, column_weight: 0
67
158
  text 'I'
68
159
  style font: {slant: 'italic'}
69
160
 
@@ -73,7 +164,7 @@ class HelloText
73
164
  }
74
165
 
75
166
  button {
76
- grid row: 0, column: 2, column_weight: 0
167
+ grid row: 1, column: column_index += 1, column_weight: 0
77
168
  text 'U'
78
169
  style font: {underline: true}
79
170
 
@@ -82,48 +173,156 @@ class HelloText
82
173
  end
83
174
  }
84
175
 
85
- combobox {
86
- grid row: 0, column: 4, column_weight: 1
87
- readonly true
88
- text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value) }]
176
+ separator {
177
+ grid row: 1, column: column_index += 1, column_weight: 0
178
+ orient 'vertical'
89
179
  }
90
180
 
91
- combobox {
92
- grid row: 0, column: 5, column_weight: 1
93
- readonly true
94
- text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'black' : value) }]
95
- }
96
- }
97
-
98
- @text = text {
99
- grid row: 1, column: 0, row_weight: 1
100
- wrap 'word'
101
- text <<~MULTI_LINE_STRING
102
- According to the National Post, a heavy metal-loving high school principal in Canada will be allowed to keep her job, days after a public campaign to oust her made headlines around the globe.
103
-
104
- Parents at Eden High School in St. Catharines, Ontario launched a petition to remove principal Sharon Burns after discovering she's an IRON MAIDEN fan.
105
-
106
- The petition, titled "Eden High School Principal, Sharon Burns, Needs to Be Transferred Immediately!" read, "We are deeply disturbed that the principal assigned to the school blatantly showed Satanic symbols and her allegiance to Satanic practices on her public social media platforms where all the students can see them under @edenprincipal (not her personal account)."
107
-
108
- More than 500 people signed the petition to transfer Burns after she posted a picture of herself flashing the "devil horns" hand sign with a doll of the MAIDEN zombie mascot Eddie behind her as well as a personalized license plate reading "IRNMADEN" and a handwritten note that reads "Eddie 666" on a car's dashboard.
181
+ button {
182
+ grid row: 1, column: column_index += 1, column_weight: 0
183
+ image File.expand_path("images/cut.png", __dir__), subsample: 32
109
184
 
185
+ on('command') do
186
+ @text.text_cut
187
+ end
188
+ }
189
+
190
+ button {
191
+ grid row: 1, column: column_index += 1, column_weight: 0
192
+ image File.expand_path("images/copy.png", __dir__), subsample: 32
110
193
 
111
- The number 666 is used to represent the devil, and is featured prominently in MAIDEN's artwork by the band, whose classic third album is titled "The Number Of The Beast".
194
+ on('command') do
195
+ @text.text_copy
196
+ end
197
+ }
198
+
199
+ button {
200
+ grid row: 1, column: column_index += 1, column_weight: 0
201
+ image File.expand_path("images/paste.png", __dir__), subsample: 32
112
202
 
113
- The petition was later updated to state that the demand for her transfer is not because of her love for metal, but for "openly displaying her own handmade sign with the 666 clearly displayed on it".
203
+ on('command') do
204
+ @text.text_paste
205
+ end
206
+ }
207
+
208
+ separator {
209
+ grid row: 1, column: column_index += 1, column_weight: 0
210
+ orient 'vertical'
211
+ }
212
+
213
+ button {
214
+ grid row: 1, column: column_index += 1, column_weight: 0
215
+ image File.expand_path("images/align-left.png", __dir__), subsample: 32
114
216
 
115
- The creator of the original petition wrote: "Sharon knows full well what she did was simply inappropriate, unnecessary and not professional but has yet to publicly admit so and is willing to allow people to believe a completely different story, making very real concerns seem petty."
217
+ on('command') do
218
+ @text.add_selection_format('justify', 'left')
219
+ end
220
+ }
221
+
222
+ button {
223
+ grid row: 1, column: column_index += 1, column_weight: 0
224
+ image File.expand_path("images/align-center.png", __dir__), subsample: 32
116
225
 
117
- Meanwhile, a counter-petition supporting Burns garnered over 20,000 signatures.
226
+ on('command') do
227
+ @text.add_selection_format('justify', 'center')
228
+ end
229
+ }
230
+
231
+ button {
232
+ grid row: 1, column: column_index += 1, column_weight: 0
233
+ image File.expand_path("images/align-right.png", __dir__), subsample: 32
118
234
 
119
- "It is ridiculous that a couple of parents judge her role as a principal only based on an Instagram post. (About liking the band IRON MAIDEN. That's it.) Eden High School is a public school. Not a Christian school," the petition titled "We need Mrs Burns" stated. "She has made Eden a safe space for so many people. She spreads nothing but love and kindness."
235
+ on('command') do
236
+ @text.add_selection_format('justify', 'right')
237
+ end
238
+ }
239
+
240
+ separator {
241
+ grid row: 1, column: column_index += 1, column_weight: 0
242
+ orient 'vertical'
243
+ }
244
+
245
+ button {
246
+ grid row: 1, column: column_index += 1, column_weight: 0
247
+ image File.expand_path("images/undo.png", __dir__), subsample: 32
120
248
 
121
- After the complaints were aired, the District School Board of Niagara spoke with Burns and the parents who launched the petition, and the issue is over as far as the board is concerned, Kim Sweeney, the board's chief communications officer, told the National Post. No disciplinary action or policy changes were needed.
249
+ on('command') do
250
+ @text.edit_undo
251
+ end
252
+ }
253
+
254
+ button {
255
+ grid row: 1, column: column_index += 1, column_weight: 0
256
+ image File.expand_path("images/redo.png", __dir__), subsample: 32
122
257
 
123
- "Our belief is that taste in music is subjective and we support that both students and staff enjoy a wide variety of genres," Sweeney said.
258
+ on('command') do
259
+ @text.edit_redo
260
+ end
261
+ }
262
+
263
+ separator {
264
+ grid row: 1, column: column_index += 1, column_weight: 0
265
+ orient 'vertical'
266
+ }
267
+
268
+ button {
269
+ grid row: 1, column: column_index += 1, column_weight: 0
270
+ image File.expand_path("images/picture.png", __dir__), subsample: 32
124
271
 
125
- The original petition has since been removed.
126
- MULTI_LINE_STRING
272
+ on('command') do
273
+ @text.get_open_file_to_insert_image
274
+ end
275
+ }
276
+ }
277
+
278
+ @text = text {
279
+ grid row: 1, column: 0, row_weight: 1
280
+ wrap 'word'
281
+ undo true
282
+ value <=> [self, :document]
283
+
284
+ on('KeyPress') do |event|
285
+ if event.state == 8 && event.char == 'f'
286
+ toplevel(r) { |tl|
287
+ title 'Find'
288
+
289
+ label {
290
+ text 'Text:'
291
+ }
292
+ entry { |e|
293
+ focus true
294
+ text <=> [
295
+ self,
296
+ :find_text,
297
+ after_write: lambda do
298
+ text_index = @text.search(/#{find_text}/i, 'insert')
299
+ unless text_index.to_s.empty?
300
+ @text.tag_remove('sel', '1.0', 'end')
301
+ @text.tag_add('sel', text_index, "#{text_index} + #{find_text.size} chars")
302
+ end
303
+ end
304
+ ]
305
+
306
+ on('KeyPress') do |event|
307
+ if event.keysym == 'Return'
308
+ find
309
+ elsif event.keysym == 'Escape'
310
+ tl.grab_release
311
+ tl.destroy
312
+ end
313
+ end
314
+ }
315
+ button {
316
+ text 'Find'
317
+ default 'active'
318
+
319
+ on('command') do
320
+ find
321
+ end
322
+ }
323
+ }
324
+ end
325
+ end
127
326
  }
128
327
  }.open
129
328
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
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.27
4
+ version: 0.0.31
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-21 00:00:00.000000000 Z
11
+ date: 2021-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.1.2
19
+ version: 2.4.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.1.2
26
+ version: 2.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: puts_debuggerer
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -211,10 +211,12 @@ files:
211
211
  - icons/glimmer.png
212
212
  - lib/glimmer-dsl-tk.rb
213
213
  - lib/glimmer/data_binding/tk/list_selection_binding.rb
214
+ - lib/glimmer/data_binding/tk/one_time_observer.rb
214
215
  - lib/glimmer/data_binding/tk/widget_binding.rb
215
216
  - lib/glimmer/dsl/tk/attribute_expression.rb
216
217
  - lib/glimmer/dsl/tk/bind_expression.rb
217
218
  - lib/glimmer/dsl/tk/block_attribute_expression.rb
219
+ - lib/glimmer/dsl/tk/built_in_dialog_expression.rb
218
220
  - lib/glimmer/dsl/tk/data_binding_expression.rb
219
221
  - lib/glimmer/dsl/tk/dsl.rb
220
222
  - lib/glimmer/dsl/tk/format_expression.rb
@@ -228,6 +230,7 @@ files:
228
230
  - lib/glimmer/tk/checkbutton_proxy.rb
229
231
  - lib/glimmer/tk/combobox_proxy.rb
230
232
  - lib/glimmer/tk/commandable.rb
233
+ - lib/glimmer/tk/drag_and_drop_extension.rb
231
234
  - lib/glimmer/tk/entry_proxy.rb
232
235
  - lib/glimmer/tk/frame_proxy.rb
233
236
  - lib/glimmer/tk/label_proxy.rb
@@ -238,15 +241,18 @@ files:
238
241
  - lib/glimmer/tk/spinbox_proxy.rb
239
242
  - lib/glimmer/tk/text_proxy.rb
240
243
  - lib/glimmer/tk/text_variable_owner.rb
244
+ - lib/glimmer/tk/toplevel_proxy.rb
241
245
  - lib/glimmer/tk/treeview_proxy.rb
242
246
  - lib/glimmer/tk/variable_owner.rb
243
247
  - lib/glimmer/tk/widget_proxy.rb
244
248
  - samples/elaborate/meta_sample.rb
249
+ - samples/hello/hello_built_in_dialog.rb
245
250
  - samples/hello/hello_button.rb
246
251
  - samples/hello/hello_checkbutton.rb
247
252
  - samples/hello/hello_combobox.rb
248
253
  - samples/hello/hello_computed.rb
249
254
  - samples/hello/hello_computed/contact.rb
255
+ - samples/hello/hello_drag_and_drop.rb
250
256
  - samples/hello/hello_entry.rb
251
257
  - samples/hello/hello_frame.rb
252
258
  - samples/hello/hello_label.rb
@@ -256,9 +262,15 @@ files:
256
262
  - samples/hello/hello_notebook.rb
257
263
  - samples/hello/hello_radiobutton.rb
258
264
  - samples/hello/hello_root.rb
265
+ - samples/hello/hello_separator.rb
259
266
  - samples/hello/hello_spinbox.rb
260
267
  - samples/hello/hello_text.rb
261
268
  - samples/hello/hello_world.rb
269
+ - samples/hello/images/align-center.png
270
+ - samples/hello/images/align-left.png
271
+ - samples/hello/images/align-right.png
272
+ - samples/hello/images/copy.png
273
+ - samples/hello/images/cut.png
262
274
  - samples/hello/images/denmark.png
263
275
  - samples/hello/images/finland.png
264
276
  - samples/hello/images/france.png
@@ -267,6 +279,11 @@ files:
267
279
  - samples/hello/images/mexico.png
268
280
  - samples/hello/images/netherlands.png
269
281
  - samples/hello/images/norway.png
282
+ - samples/hello/images/paste.png
283
+ - samples/hello/images/picture.png
284
+ - samples/hello/images/redo.png
285
+ - samples/hello/images/search.png
286
+ - samples/hello/images/undo.png
270
287
  - samples/hello/images/usa.png
271
288
  homepage: http://github.com/AndyObtiva/glimmer-dsl-tk
272
289
  licenses:
@@ -288,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
305
  - !ruby/object:Gem::Version
289
306
  version: '0'
290
307
  requirements: []
291
- rubygems_version: 3.2.29
308
+ rubygems_version: 3.2.22
292
309
  signing_key:
293
310
  specification_version: 4
294
311
  summary: Glimmer DSL for Tk