glimmer-dsl-tk 0.0.11 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +265 -47
- data/VERSION +1 -1
- data/glimmer-dsl-tk.gemspec +0 -0
- data/lib/glimmer/dsl/tk/dsl.rb +1 -0
- data/lib/glimmer/dsl/tk/message_box_expression.rb +36 -0
- data/lib/glimmer/dsl/tk/shine_data_binding_expression.rb +43 -0
- data/lib/glimmer/tk/root_proxy.rb +2 -4
- data/lib/glimmer/tk/widget_proxy.rb +38 -15
- data/samples/hello/hello_button.rb +96 -0
- data/samples/hello/{hello_combo.rb → hello_combobox.rb} +4 -4
- data/samples/hello/hello_computed.rb +5 -5
- data/samples/hello/hello_list_multi_selection.rb +1 -1
- data/samples/hello/hello_list_single_selection.rb +1 -1
- data/samples/hello/hello_message_box.rb +94 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12e68b40c6fb5c056f778d8864b88a01adb69ee4c0fe4273cc007a7d8d589cb9
|
4
|
+
data.tar.gz: 16281eeb0be0b1556390c42504f82d879ae6e13f427875215454f8a5d8949706
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07ec8746537d220b0b768715f29f5796543f497c1054c55796b8a23ae0ac83c4007d545d378b3ac7896893f68a1a2f2d0b11a0bbd002254cddb5369d7d6a5653
|
7
|
+
data.tar.gz: aae794b82923901cd227d899fa914978e168fb8c35ff8433ccda048d7845e346aa9b74b001d91cc7779dcbe588cad46817fac48aa7c3ec3be1332ebf9ce80852
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.15
|
4
|
+
|
5
|
+
- Update Hello, Button! to demo all button attributes
|
6
|
+
- Support `button` `image` attribute (accepting image arguments: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule` to automatically process image)
|
7
|
+
- Update `root` `iconphoto` support to accept image arguments: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule` to automatically process image
|
8
|
+
- Support `button` `compound` attribute (`'center', 'top', 'bottom', 'left', 'right'`)
|
9
|
+
- Support `button` `default` attribute (`'active'` or `'normal'`)
|
10
|
+
|
11
|
+
## 0.0.14
|
12
|
+
|
13
|
+
- Hello, Button!
|
14
|
+
|
15
|
+
## 0.0.13
|
16
|
+
|
17
|
+
- Hello, Message Box!
|
18
|
+
- Support `message_box`
|
19
|
+
|
20
|
+
## 0.0.12
|
21
|
+
|
22
|
+
- Upgrade to glimmer 2.3.0
|
23
|
+
- Support Shine syntax for data-binding
|
24
|
+
- Update all data-binding samples to use Shine syntax for data-binding
|
25
|
+
|
3
26
|
## 0.0.11
|
4
27
|
|
5
28
|
- Add preliminary support for `treeview` (no data-binding) with `columns`, `show`, and `heading_configure` attributes/methods
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Tk 0.0.
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Tk 0.0.15
|
2
2
|
## MRI Ruby Desktop Development GUI Library
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-tk.svg)](http://badge.fury.io/rb/glimmer-dsl-tk)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-tk/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-tk?branch=master)
|
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [Tk](https://www.tcl.tk/) enables desktop development with [Glimmer](https://github.com/AndyObtiva/glimmer) in [Ruby](https://github.com/ruby/ruby).
|
11
11
|
|
12
|
-
[Tcl/Tk](https://www.tcl.tk/) has evolved into a practical desktop GUI toolkit due to gaining
|
12
|
+
[Tcl/Tk](https://www.tcl.tk/) has evolved into a practical desktop GUI toolkit due to gaining native looking themed widgets on Mac, Windows, and Linux in [Tk version 8.5](https://www.tcl.tk/software/tcltk/8.5.html#:~:text=Highlights%20of%20Tk%208.5&text=Font%20rendering%3A%20Now%20uses%20anti,and%20window%20layout%2C%20and%20more.).
|
13
13
|
|
14
14
|
Additionally, [Ruby](https://www.ruby-lang.org/en/) 3.0 Ractor (formerly known as [Guilds](https://olivierlacan.com/posts/concurrency-in-ruby-3-with-guilds/)) supports truly parallel multi-threading, making both [MRI](https://github.com/ruby/ruby) and [Tk](https://www.tcl.tk/) finally viable for support in [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development GUI Library) as an alternative to [JRuby on SWT](https://github.com/AndyObtiva/glimmer-dsl-swt).
|
15
15
|
|
@@ -29,7 +29,13 @@ The trade-off is that while [SWT](https://www.eclipse.org/swt/) provides a pleth
|
|
29
29
|
Glimmer code (from [samples/hello/hello_world.rb](samples/hello/hello_world.rb)):
|
30
30
|
|
31
31
|
```ruby
|
32
|
+
require 'glimmer-dsl-tk'
|
33
|
+
|
34
|
+
include Glimmer
|
35
|
+
|
32
36
|
root {
|
37
|
+
title 'Hello, World!'
|
38
|
+
|
33
39
|
label {
|
34
40
|
text 'Hello, World!'
|
35
41
|
}
|
@@ -46,7 +52,7 @@ Glimmer app:
|
|
46
52
|
|
47
53
|
![glimmer dsl tk screenshot sample hello world](images/glimmer-dsl-tk-screenshot-sample-hello-world.png)
|
48
54
|
|
49
|
-
NOTE: Glimmer DSL for Tk is in alpha mode. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
|
55
|
+
NOTE: Glimmer DSL for Tk is currently in early alpha mode (incomplete). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
|
50
56
|
|
51
57
|
Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
52
58
|
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
|
@@ -81,7 +87,7 @@ gem install glimmer-dsl-tk
|
|
81
87
|
|
82
88
|
Add the following to `Gemfile`:
|
83
89
|
```
|
84
|
-
gem 'glimmer-dsl-tk', '~> 0.0.
|
90
|
+
gem 'glimmer-dsl-tk', '~> 0.0.15'
|
85
91
|
```
|
86
92
|
|
87
93
|
And, then run:
|
@@ -167,6 +173,23 @@ root {
|
|
167
173
|
}.open
|
168
174
|
```
|
169
175
|
|
176
|
+
### Supported Widgets
|
177
|
+
|
178
|
+
keyword(args) | attributes | listeners / events / bindings / callbacks
|
179
|
+
------------- | ---------- | ---------
|
180
|
+
`button` | `text`, `image`, `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `default` (`'active', 'normal'`) | `command`
|
181
|
+
`entry` | `width`, `text` | None
|
182
|
+
`frame(text: )` | None | None
|
183
|
+
`label` | `text` | None
|
184
|
+
`list` | `selectmode`, `selection` | None
|
185
|
+
`message_box(type: , message: , detail: , title: , icon: , default: , parent: )` | None | None
|
186
|
+
`notebook` | None | None
|
187
|
+
`root` | `title`, `iconphoto` | None
|
188
|
+
|
189
|
+
#### Common Attributes
|
190
|
+
|
191
|
+
- `grid`
|
192
|
+
|
170
193
|
### Smart Defaults and Convensions
|
171
194
|
|
172
195
|
#### Grid Layout
|
@@ -211,7 +234,7 @@ Example:
|
|
211
234
|
entry {
|
212
235
|
grid column: 1, row: 2
|
213
236
|
width 15
|
214
|
-
text
|
237
|
+
text <=> [@contact, :year_of_birth]
|
215
238
|
}
|
216
239
|
```
|
217
240
|
|
@@ -219,9 +242,27 @@ More details can be found in the [Hello, Computed!](#hello-computed) sample belo
|
|
219
242
|
|
220
243
|
## Bidirectional Data-Binding
|
221
244
|
|
222
|
-
Glimmer supports bidirectional data-binding via the
|
245
|
+
Glimmer supports Shine syntax bidirectional data-binding via the `<=>` operator (read-write) and unidirectional data-binding via the `<=` operator (read-only), which takes a model and an attribute (the `bind` keyword may also be used as the old-style of data-binding).
|
246
|
+
|
247
|
+
### General Property Data-Binding
|
248
|
+
|
249
|
+
Example:
|
250
|
+
|
251
|
+
This assumes a `Person` model with a `country` attribute.
|
252
|
+
|
253
|
+
```ruby
|
254
|
+
label {
|
255
|
+
text <=> [person, :country]
|
256
|
+
}
|
257
|
+
```
|
258
|
+
|
259
|
+
That code binds the `textvariable` value of the `label` to the `country` property on the `person` model.
|
223
260
|
|
224
|
-
|
261
|
+
It automatically handles all the Tk plumbing behind the scenes.
|
262
|
+
|
263
|
+
More details can be found in the [Hello, Computed!](#hello-computed) sample below.
|
264
|
+
|
265
|
+
### Combobox Data-Binding
|
225
266
|
|
226
267
|
Example:
|
227
268
|
|
@@ -230,7 +271,7 @@ This assumes a `Person` model with a `country` attribute representing their curr
|
|
230
271
|
```ruby
|
231
272
|
combobox {
|
232
273
|
state 'readonly'
|
233
|
-
text
|
274
|
+
text <=> [person, :country]
|
234
275
|
}
|
235
276
|
```
|
236
277
|
|
@@ -239,7 +280,7 @@ It also binds the `text` selection of the `combobox` to the `country` property o
|
|
239
280
|
|
240
281
|
It automatically handles all the Tk plumbing behind the scenes, such as using `TkVariable` and setting `combobox` `values` from `person.country_options` by convention (attribute_name + "_options").
|
241
282
|
|
242
|
-
More details can be found in the [Hello,
|
283
|
+
More details can be found in the [Hello, Combobox!](#hello-combobox) sample below.
|
243
284
|
|
244
285
|
### List Single Selection Data-Binding
|
245
286
|
|
@@ -252,7 +293,7 @@ This assumes a `Person` model with a `country` attribute representing their curr
|
|
252
293
|
```ruby
|
253
294
|
list {
|
254
295
|
selectmode 'browse'
|
255
|
-
text
|
296
|
+
text <=> [person, :country]
|
256
297
|
}
|
257
298
|
```
|
258
299
|
|
@@ -273,7 +314,7 @@ This assumes a `Person` model with a `provinces` attribute representing their cu
|
|
273
314
|
|
274
315
|
```ruby
|
275
316
|
list {
|
276
|
-
text
|
317
|
+
text <=> [person, :provinces]
|
277
318
|
}
|
278
319
|
```
|
279
320
|
|
@@ -284,24 +325,6 @@ It automatically handles all the Tk plumbing behind the scenes.
|
|
284
325
|
|
285
326
|
More details can be found in the [Hello, List Multi Selection!](#hello-list-multi-selection) sample below.
|
286
327
|
|
287
|
-
### Label Data-Binding
|
288
|
-
|
289
|
-
Example:
|
290
|
-
|
291
|
-
This assumes a `Person` model with a `country` attribute.
|
292
|
-
|
293
|
-
```ruby
|
294
|
-
label {
|
295
|
-
text bind(person, :country)
|
296
|
-
}
|
297
|
-
```
|
298
|
-
|
299
|
-
That code binds the `textvariable` value of the `label` to the `country` property on the `person` model.
|
300
|
-
|
301
|
-
It automatically handles all the Tk plumbing behind the scenes.
|
302
|
-
|
303
|
-
More details can be found in the [Hello, Computed!](#hello-computed) sample below.
|
304
|
-
|
305
328
|
### Entry Data-Binding
|
306
329
|
|
307
330
|
Example:
|
@@ -310,7 +333,7 @@ This assumes a `Person` model with a `country` attribute.
|
|
310
333
|
|
311
334
|
```ruby
|
312
335
|
entry {
|
313
|
-
text
|
336
|
+
text <=> [person, :country]
|
314
337
|
}
|
315
338
|
```
|
316
339
|
|
@@ -337,7 +360,7 @@ Example:
|
|
337
360
|
|
338
361
|
This resets the person country.
|
339
362
|
|
340
|
-
More details can be found in the [Hello,
|
363
|
+
More details can be found in the [Hello, Combobox!](#hello-combobox) sample below.
|
341
364
|
|
342
365
|
## Samples
|
343
366
|
|
@@ -346,9 +369,13 @@ More details can be found in the [Hello, Combo!](#hello-combo) sample below.
|
|
346
369
|
Glimmer code (from [samples/hello/hello_world.rb](samples/hello/hello_world.rb)):
|
347
370
|
|
348
371
|
```ruby
|
372
|
+
require 'glimmer-dsl-tk'
|
373
|
+
|
349
374
|
include Glimmer
|
350
375
|
|
351
376
|
root {
|
377
|
+
title 'Hello, World!'
|
378
|
+
|
352
379
|
label {
|
353
380
|
text 'Hello, World!'
|
354
381
|
}
|
@@ -364,13 +391,111 @@ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_world'"
|
|
364
391
|
Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
365
392
|
|
366
393
|
```
|
367
|
-
ruby -
|
394
|
+
ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_world.rb
|
368
395
|
```
|
369
396
|
|
370
397
|
Glimmer app:
|
371
398
|
|
372
399
|
![glimmer dsl tk screenshot sample hello world](images/glimmer-dsl-tk-screenshot-sample-hello-world.png)
|
373
400
|
|
401
|
+
### Hello, Button!
|
402
|
+
|
403
|
+
Glimmer code (from [samples/hello/hello_button.rb](samples/hello/hello_button.rb)):
|
404
|
+
|
405
|
+
```ruby
|
406
|
+
require 'glimmer-dsl-tk'
|
407
|
+
|
408
|
+
class HelloButton
|
409
|
+
include Glimmer
|
410
|
+
|
411
|
+
attr_accessor :count
|
412
|
+
|
413
|
+
def initialize
|
414
|
+
@count = 0
|
415
|
+
end
|
416
|
+
|
417
|
+
def launch
|
418
|
+
root {
|
419
|
+
title 'Hello, Button!'
|
420
|
+
|
421
|
+
frame {
|
422
|
+
grid row: 0, column: 0
|
423
|
+
|
424
|
+
label {
|
425
|
+
grid pady: 15
|
426
|
+
text 'Text Button'
|
427
|
+
}
|
428
|
+
|
429
|
+
button {
|
430
|
+
text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
|
431
|
+
default 'active'
|
432
|
+
|
433
|
+
command {
|
434
|
+
self.count += 1
|
435
|
+
}
|
436
|
+
}
|
437
|
+
}
|
438
|
+
|
439
|
+
frame {
|
440
|
+
grid row: 0, column: 1
|
441
|
+
|
442
|
+
label {
|
443
|
+
grid pady: 15
|
444
|
+
text 'Image Button'
|
445
|
+
}
|
446
|
+
|
447
|
+
button {
|
448
|
+
image File.expand_path('../../icons/glimmer.png', __dir__), subsample: 5
|
449
|
+
|
450
|
+
command {
|
451
|
+
message_box(title: 'Image Button', message: 'Image Button Clicked!')
|
452
|
+
}
|
453
|
+
}
|
454
|
+
}
|
455
|
+
|
456
|
+
frame {
|
457
|
+
grid row: 0, column: 2
|
458
|
+
|
459
|
+
label {
|
460
|
+
grid pady: 15
|
461
|
+
text 'Text Image Buttons'
|
462
|
+
}
|
463
|
+
|
464
|
+
['center', 'top', 'bottom', 'left', 'right'].each do |compound_option|
|
465
|
+
button {
|
466
|
+
image File.expand_path('../../icons/glimmer.png', __dir__), subsample: 5
|
467
|
+
text 'Text Image Button'
|
468
|
+
compound compound_option
|
469
|
+
|
470
|
+
command {
|
471
|
+
message_box(title: 'Text Image Button', message: 'Text Image Button Clicked!', detail: "(#{compound_option})")
|
472
|
+
}
|
473
|
+
}
|
474
|
+
end
|
475
|
+
}
|
476
|
+
}.open
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
480
|
+
HelloButton.new.launch
|
481
|
+
```
|
482
|
+
|
483
|
+
Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
484
|
+
|
485
|
+
```
|
486
|
+
ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_button'"
|
487
|
+
```
|
488
|
+
|
489
|
+
Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
490
|
+
|
491
|
+
```
|
492
|
+
ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_button.rb
|
493
|
+
```
|
494
|
+
|
495
|
+
Glimmer app:
|
496
|
+
|
497
|
+
![glimmer dsl tk screenshot sample hello button](images/glimmer-dsl-tk-screenshot-sample-hello-button.png)
|
498
|
+
|
374
499
|
### Hello, Tab!
|
375
500
|
|
376
501
|
Glimmer code (from [samples/hello/hello_tab.rb](samples/hello/hello_tab.rb)):
|
@@ -414,18 +539,111 @@ Glimmer app:
|
|
414
539
|
![glimmer dsl tk screenshot sample hello tab English](images/glimmer-dsl-tk-screenshot-sample-hello-tab-english.png)
|
415
540
|
![glimmer dsl tk screenshot sample hello tab French](images/glimmer-dsl-tk-screenshot-sample-hello-tab-french.png)
|
416
541
|
|
417
|
-
### Hello,
|
542
|
+
### Hello, Message Box!
|
543
|
+
|
544
|
+
Glimmer code (from [samples/hello/hello_message_box.rb](samples/hello/hello_message_box.rb)):
|
545
|
+
|
546
|
+
```ruby
|
547
|
+
root { |r|
|
548
|
+
title 'Hello, Message Box!'
|
549
|
+
|
550
|
+
frame {
|
551
|
+
grid sticky: 'nsew', padx: 15, pady: 15
|
552
|
+
|
553
|
+
button {
|
554
|
+
text 'Please Click To Win a Surprise'
|
555
|
+
|
556
|
+
command {
|
557
|
+
# specifying parent ensures dialog shows up centered on top of window (instead of centered in display monitor)
|
558
|
+
@result_label.text = message_box(parent: r, title: 'Surprise', message: "Congratulations!\n\nYou won $1,000,000!") # type: 'ok' by default
|
559
|
+
}
|
560
|
+
}
|
561
|
+
|
562
|
+
button {
|
563
|
+
text 'Download Software Update'
|
564
|
+
|
565
|
+
command {
|
566
|
+
@result_label.text = message_box(type: 'okcancel', title: 'Software Update', message: "We will begin to download software update.")
|
567
|
+
}
|
568
|
+
}
|
569
|
+
|
570
|
+
button {
|
571
|
+
text 'Format Hard Drive'
|
572
|
+
|
573
|
+
command {
|
574
|
+
@result_label.text = message_box(type: 'yesno', icon: 'question', title: 'Format', message: "Would you like to format your hard drive?")
|
575
|
+
}
|
576
|
+
}
|
577
|
+
|
578
|
+
button {
|
579
|
+
text 'Submit Application'
|
580
|
+
|
581
|
+
command {
|
582
|
+
@result_label.text = message_box(type: 'yesnocancel', icon: 'question', title: 'Application', message: "Would you like to review application before submitting?")
|
583
|
+
}
|
584
|
+
}
|
585
|
+
|
586
|
+
button {
|
587
|
+
text 'Play Video'
|
588
|
+
|
589
|
+
command {
|
590
|
+
@result_label.text = message_box(type: 'retrycancel', icon: 'error', title: 'Video Replay', message: "Video has failed to play. Would you like to retry?")
|
591
|
+
}
|
592
|
+
}
|
593
|
+
|
594
|
+
button {
|
595
|
+
text 'Installation Completed'
|
596
|
+
|
597
|
+
command {
|
598
|
+
@result_label.text = message_box(type: 'abortretryignore', icon: 'warning', default: 'ignore', title: 'Failed To Install Extra Utilities', message: "Installation is complete, but extra utilities have failed to install. Would you like to retry installing extra utilities?", detail: 'Encountered network error in downloading extra utilities, resulting in failure to install them')
|
599
|
+
}
|
600
|
+
}
|
601
|
+
}
|
602
|
+
|
603
|
+
frame {
|
604
|
+
grid sticky: 'nsew', padx: 15, pady: 15
|
605
|
+
|
606
|
+
label {
|
607
|
+
grid row: 0, column: 0
|
608
|
+
text 'Result:'
|
609
|
+
}
|
610
|
+
|
611
|
+
@result_label = label {
|
612
|
+
grid row: 0, column: 1
|
613
|
+
}
|
614
|
+
}
|
615
|
+
}.open
|
616
|
+
```
|
617
|
+
|
618
|
+
Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
619
|
+
|
620
|
+
```
|
621
|
+
ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_tab'"
|
622
|
+
```
|
623
|
+
|
624
|
+
Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
625
|
+
|
626
|
+
```
|
627
|
+
ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_tab'"
|
628
|
+
```
|
629
|
+
|
630
|
+
Glimmer app:
|
631
|
+
|
632
|
+
![glimmer dsl tk screenshot sample hello message box](images/glimmer-dsl-tk-screenshot-sample-hello-message-box.png)
|
633
|
+
![glimmer dsl tk screenshot sample hello message box open](images/glimmer-dsl-tk-screenshot-sample-hello-message-box-open.png)
|
634
|
+
|
635
|
+
### Hello, Combobox!
|
418
636
|
|
419
|
-
Glimmer code (from [samples/hello/
|
637
|
+
Glimmer code (from [samples/hello/hello_combobox.rb](samples/hello/hello_combobox.rb)):
|
420
638
|
|
421
639
|
```ruby
|
422
640
|
# ... more code precedes
|
423
641
|
root {
|
424
|
-
title 'Hello,
|
642
|
+
title 'Hello, Combobox!'
|
425
643
|
|
426
644
|
combobox { |proxy|
|
427
645
|
state 'readonly'
|
428
|
-
text
|
646
|
+
text <=> [person, :country]
|
429
647
|
}
|
430
648
|
|
431
649
|
button { |proxy|
|
@@ -441,19 +659,19 @@ root {
|
|
441
659
|
Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
442
660
|
|
443
661
|
```
|
444
|
-
ruby -r glimmer-dsl-tk -e "require 'samples/hello/
|
662
|
+
ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_combobox'"
|
445
663
|
```
|
446
664
|
|
447
665
|
Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
448
666
|
|
449
667
|
```
|
450
|
-
ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/
|
668
|
+
ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_combobox'"
|
451
669
|
```
|
452
670
|
|
453
671
|
Glimmer app:
|
454
672
|
|
455
|
-
![glimmer dsl tk screenshot sample hello
|
456
|
-
![glimmer dsl tk screenshot sample hello
|
673
|
+
![glimmer dsl tk screenshot sample hello combobox](images/glimmer-dsl-tk-screenshot-sample-hello-combobox.png)
|
674
|
+
![glimmer dsl tk screenshot sample hello combobox dropdown](images/glimmer-dsl-tk-screenshot-sample-hello-combobox-dropdown.png)
|
457
675
|
|
458
676
|
### Hello, List Single Selection!
|
459
677
|
|
@@ -466,7 +684,7 @@ root {
|
|
466
684
|
|
467
685
|
list {
|
468
686
|
selectmode 'browse'
|
469
|
-
selection
|
687
|
+
selection <=> [person, :country]
|
470
688
|
}
|
471
689
|
|
472
690
|
button {
|
@@ -504,7 +722,7 @@ root {
|
|
504
722
|
title 'Hello, List Multi Selection!'
|
505
723
|
|
506
724
|
list {
|
507
|
-
selection
|
725
|
+
selection <=> [person, :provinces]
|
508
726
|
}
|
509
727
|
|
510
728
|
button {
|
@@ -551,7 +769,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
|
|
551
769
|
entry {
|
552
770
|
grid column: 1, row: 0
|
553
771
|
width 15
|
554
|
-
text
|
772
|
+
text <=> [@contact, :first_name]
|
555
773
|
}
|
556
774
|
|
557
775
|
label {
|
@@ -561,7 +779,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
|
|
561
779
|
entry {
|
562
780
|
grid column: 1, row: 1
|
563
781
|
width 15
|
564
|
-
text
|
782
|
+
text <=> [@contact, :last_name]
|
565
783
|
}
|
566
784
|
|
567
785
|
label {
|
@@ -571,7 +789,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
|
|
571
789
|
entry {
|
572
790
|
grid column: 1, row: 2
|
573
791
|
width 15
|
574
|
-
text
|
792
|
+
text <=> [@contact, :year_of_birth]
|
575
793
|
}
|
576
794
|
|
577
795
|
label {
|
@@ -580,7 +798,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
|
|
580
798
|
}
|
581
799
|
label {
|
582
800
|
grid column: 1, row: 3, sticky: 'w'
|
583
|
-
text
|
801
|
+
text <=> [@contact, :name, computed_by: [:first_name, :last_name]]
|
584
802
|
}
|
585
803
|
|
586
804
|
label {
|
@@ -589,7 +807,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
|
|
589
807
|
}
|
590
808
|
label {
|
591
809
|
grid column: 1, row: 4, sticky: 'w'
|
592
|
-
text
|
810
|
+
text <=> [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
|
593
811
|
}
|
594
812
|
}
|
595
813
|
}.open
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.15
|
data/glimmer-dsl-tk.gemspec
CHANGED
Binary file
|
data/lib/glimmer/dsl/tk/dsl.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
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/static_expression'
|
23
|
+
require 'glimmer/tk/root_proxy'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module DSL
|
27
|
+
module Tk
|
28
|
+
class MessageBoxExpression < StaticExpression
|
29
|
+
def interpret(parent, keyword, *args, &block)
|
30
|
+
args.first[:parent] = args.first[:parent].tk if args.first.is_a?(Hash) && args.first[:parent].is_a?(Glimmer::Tk::RootProxy)
|
31
|
+
::Tk::messageBox(*args)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Copyright (c) 2007-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/expression'
|
23
|
+
require 'glimmer/data_binding/model_binding'
|
24
|
+
require 'glimmer/data_binding/tk/widget_binding'
|
25
|
+
require 'glimmer/data_binding/shine'
|
26
|
+
|
27
|
+
module Glimmer
|
28
|
+
module DSL
|
29
|
+
module Tk
|
30
|
+
class ShineDataBindingExpression < Expression
|
31
|
+
def can_interpret?(parent, keyword, *args, &block)
|
32
|
+
args.size == 0 and
|
33
|
+
block.nil? and
|
34
|
+
(parent.respond_to?(:has_attribute?) and parent.has_attribute?(keyword))
|
35
|
+
end
|
36
|
+
|
37
|
+
def interpret(parent, keyword, *args, &block)
|
38
|
+
Glimmer::DataBinding::Shine.new(parent, keyword)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -40,14 +40,12 @@ module Glimmer
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def content(&block)
|
43
|
-
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::RootExpression.new, &block)
|
43
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::RootExpression.new, keyword, *args, &block)
|
44
44
|
end
|
45
45
|
|
46
46
|
def set_attribute(attribute, *args)
|
47
47
|
if attribute.to_s == 'iconphoto'
|
48
|
-
|
49
|
-
args[0] = ::TkPhotoImage.new(file: args.first)
|
50
|
-
end
|
48
|
+
args[0..-1] = [image_argument(args)]
|
51
49
|
super
|
52
50
|
else
|
53
51
|
super
|
@@ -25,20 +25,6 @@ module Glimmer
|
|
25
25
|
#
|
26
26
|
# Follows the Proxy Design Pattern
|
27
27
|
class WidgetProxy
|
28
|
-
attr_reader :parent_proxy, :tk, :args
|
29
|
-
|
30
|
-
DEFAULT_INITIALIZERS = {
|
31
|
-
'combobox' => lambda do |tk|
|
32
|
-
tk.textvariable = ::TkVariable.new
|
33
|
-
end,
|
34
|
-
'label' => lambda do |tk|
|
35
|
-
tk.textvariable = ::TkVariable.new
|
36
|
-
end,
|
37
|
-
'entry' => lambda do |tk|
|
38
|
-
tk.textvariable = ::TkVariable.new
|
39
|
-
end,
|
40
|
-
}
|
41
|
-
|
42
28
|
class << self
|
43
29
|
def create(keyword, parent, args)
|
44
30
|
widget_proxy_class(keyword).new(keyword, parent, args)
|
@@ -75,12 +61,27 @@ module Glimmer
|
|
75
61
|
end
|
76
62
|
end
|
77
63
|
|
64
|
+
attr_reader :parent_proxy, :tk, :args, :keyword
|
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
78
|
# Initializes a new Tk Widget
|
79
79
|
#
|
80
80
|
# Styles is a comma separate list of symbols representing Tk styles in lower case
|
81
81
|
def initialize(underscored_widget_name, parent_proxy, args)
|
82
82
|
@parent_proxy = parent_proxy
|
83
83
|
@args = args
|
84
|
+
@keyword = underscored_widget_name
|
84
85
|
tk_widget_class = self.class.tk_widget_class_for(underscored_widget_name)
|
85
86
|
@tk = tk_widget_class.new(@parent_proxy.tk, *args)
|
86
87
|
# a common widget initializer
|
@@ -156,6 +157,12 @@ module Glimmer
|
|
156
157
|
|
157
158
|
def widget_custom_attribute_mapping
|
158
159
|
@widget_custom_attribute_mapping ||= {
|
160
|
+
::Tk::Tile::TButton => {
|
161
|
+
'image' => {
|
162
|
+
getter: {name: 'image', invoker: lambda { |widget, args| @tk.textvariable&.value }},
|
163
|
+
setter: {name: 'image=', invoker: lambda { |widget, args| @tk['image'] = image_argument(args) }},
|
164
|
+
},
|
165
|
+
},
|
159
166
|
::Tk::Tile::TCombobox => {
|
160
167
|
'text' => {
|
161
168
|
getter: {name: 'text', invoker: lambda { |widget, args| @tk.textvariable&.value }},
|
@@ -209,6 +216,22 @@ module Glimmer
|
|
209
216
|
}
|
210
217
|
end
|
211
218
|
|
219
|
+
def image_argument(args)
|
220
|
+
if args.first.is_a?(::TkPhotoImage)
|
221
|
+
args.first
|
222
|
+
else
|
223
|
+
image_args = {}
|
224
|
+
image_args.merge!(file: args.first.to_s) if args.first.is_a?(String)
|
225
|
+
the_image = ::TkPhotoImage.new(image_args)
|
226
|
+
if args.last.is_a?(Hash)
|
227
|
+
processed_image = ::TkPhotoImage.new
|
228
|
+
processed_image.copy(the_image, args.last)
|
229
|
+
the_image = processed_image
|
230
|
+
end
|
231
|
+
the_image
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
212
235
|
def add_observer(observer, attribute)
|
213
236
|
attribute_listener_installers = @tk.class.ancestors.map {|ancestor| widget_attribute_listener_installers[ancestor]}.compact
|
214
237
|
widget_listener_installers = attribute_listener_installers.map{|installer| installer[attribute.to_s]}.compact if !attribute_listener_installers.empty?
|
@@ -216,7 +239,7 @@ module Glimmer
|
|
216
239
|
end
|
217
240
|
|
218
241
|
def content(&block)
|
219
|
-
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::WidgetExpression.new, &block)
|
242
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::WidgetExpression.new, keyword, *args, &block)
|
220
243
|
end
|
221
244
|
|
222
245
|
def method_missing(method, *args, &block)
|
@@ -0,0 +1,96 @@
|
|
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 HelloButton
|
25
|
+
include Glimmer
|
26
|
+
|
27
|
+
attr_accessor :count
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
@count = 0
|
31
|
+
end
|
32
|
+
|
33
|
+
def launch
|
34
|
+
root {
|
35
|
+
title 'Hello, Button!'
|
36
|
+
|
37
|
+
frame {
|
38
|
+
grid row: 0, column: 0
|
39
|
+
|
40
|
+
label {
|
41
|
+
grid pady: 15
|
42
|
+
text 'Text Button'
|
43
|
+
}
|
44
|
+
|
45
|
+
button {
|
46
|
+
text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
|
47
|
+
default 'active'
|
48
|
+
|
49
|
+
command {
|
50
|
+
self.count += 1
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
frame {
|
56
|
+
grid row: 0, column: 1
|
57
|
+
|
58
|
+
label {
|
59
|
+
grid pady: 15
|
60
|
+
text 'Image Button'
|
61
|
+
}
|
62
|
+
|
63
|
+
button {
|
64
|
+
image File.expand_path('../../icons/glimmer.png', __dir__), subsample: 5
|
65
|
+
|
66
|
+
command {
|
67
|
+
message_box(title: 'Image Button', message: 'Image Button Clicked!')
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
frame {
|
73
|
+
grid row: 0, column: 2
|
74
|
+
|
75
|
+
label {
|
76
|
+
grid pady: 15
|
77
|
+
text 'Text Image Buttons'
|
78
|
+
}
|
79
|
+
|
80
|
+
['center', 'top', 'bottom', 'left', 'right'].each do |compound_option|
|
81
|
+
button {
|
82
|
+
image File.expand_path('../../icons/glimmer.png', __dir__), subsample: 5
|
83
|
+
text 'Text Image Button'
|
84
|
+
compound compound_option
|
85
|
+
|
86
|
+
command {
|
87
|
+
message_box(title: 'Text Image Button', message: 'Text Image Button Clicked!', detail: "(#{compound_option})")
|
88
|
+
}
|
89
|
+
}
|
90
|
+
end
|
91
|
+
}
|
92
|
+
}.open
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
HelloButton.new.launch
|
@@ -34,18 +34,18 @@ class Person
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
class
|
37
|
+
class HelloCombobox
|
38
38
|
include Glimmer
|
39
39
|
|
40
40
|
def launch
|
41
41
|
person = Person.new
|
42
42
|
|
43
43
|
root {
|
44
|
-
title 'Hello,
|
44
|
+
title 'Hello, Combobox!'
|
45
45
|
|
46
46
|
combobox {
|
47
47
|
state 'readonly'
|
48
|
-
text
|
48
|
+
text <=> [person, :country]
|
49
49
|
}
|
50
50
|
|
51
51
|
button {
|
@@ -58,4 +58,4 @@ class HelloCombo
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
|
61
|
+
HelloCombobox.new.launch
|
@@ -48,7 +48,7 @@ class HelloComputed
|
|
48
48
|
entry {
|
49
49
|
grid column: 1, row: 0
|
50
50
|
width 15
|
51
|
-
text
|
51
|
+
text <=> [@contact, :first_name]
|
52
52
|
}
|
53
53
|
|
54
54
|
label {
|
@@ -58,7 +58,7 @@ class HelloComputed
|
|
58
58
|
entry {
|
59
59
|
grid column: 1, row: 1
|
60
60
|
width 15
|
61
|
-
text
|
61
|
+
text <=> [@contact, :last_name]
|
62
62
|
}
|
63
63
|
|
64
64
|
label {
|
@@ -68,7 +68,7 @@ class HelloComputed
|
|
68
68
|
entry {
|
69
69
|
grid column: 1, row: 2
|
70
70
|
width 15
|
71
|
-
text
|
71
|
+
text <=> [@contact, :year_of_birth]
|
72
72
|
}
|
73
73
|
|
74
74
|
label {
|
@@ -77,7 +77,7 @@ class HelloComputed
|
|
77
77
|
}
|
78
78
|
label {
|
79
79
|
grid column: 1, row: 3, sticky: 'w'
|
80
|
-
text
|
80
|
+
text <=> [@contact, :name, computed_by: [:first_name, :last_name]]
|
81
81
|
}
|
82
82
|
|
83
83
|
label {
|
@@ -86,7 +86,7 @@ class HelloComputed
|
|
86
86
|
}
|
87
87
|
label {
|
88
88
|
grid column: 1, row: 4, sticky: 'w'
|
89
|
-
text
|
89
|
+
text <=> [@contact, :age, on_write: :to_i, computed_by: :year_of_birth]
|
90
90
|
}
|
91
91
|
}
|
92
92
|
}.open
|
@@ -0,0 +1,94 @@
|
|
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, Message Box!'
|
28
|
+
|
29
|
+
frame {
|
30
|
+
grid sticky: 'nsew', padx: 15, pady: 15
|
31
|
+
|
32
|
+
button {
|
33
|
+
text 'Please Click To Win a Surprise'
|
34
|
+
|
35
|
+
command {
|
36
|
+
# specifying parent ensures dialog shows up centered on top of window (instead of centered in display monitor)
|
37
|
+
@result_label.text = message_box(parent: r, title: 'Surprise', message: "Congratulations!\n\nYou won $1,000,000!") # type: 'ok' by default
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
button {
|
42
|
+
text 'Download Software Update'
|
43
|
+
|
44
|
+
command {
|
45
|
+
@result_label.text = message_box(type: 'okcancel', title: 'Software Update', message: "We will begin to download software update.")
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
button {
|
50
|
+
text 'Format Hard Drive'
|
51
|
+
|
52
|
+
command {
|
53
|
+
@result_label.text = message_box(type: 'yesno', icon: 'question', title: 'Format', message: "Would you like to format your hard drive?")
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
button {
|
58
|
+
text 'Submit Application'
|
59
|
+
|
60
|
+
command {
|
61
|
+
@result_label.text = message_box(type: 'yesnocancel', icon: 'question', title: 'Application', message: "Would you like to review application before submitting?")
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
button {
|
66
|
+
text 'Play Video'
|
67
|
+
|
68
|
+
command {
|
69
|
+
@result_label.text = message_box(type: 'retrycancel', icon: 'error', title: 'Video Replay', message: "Video has failed to play. Would you like to retry?")
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
button {
|
74
|
+
text 'Installation Completed'
|
75
|
+
|
76
|
+
command {
|
77
|
+
@result_label.text = message_box(type: 'abortretryignore', icon: 'warning', default: 'ignore', title: 'Failed To Install Extra Utilities', message: "Installation is complete, but extra utilities have failed to install. Would you like to retry installing extra utilities?", detail: 'Encountered network error in downloading extra utilities, resulting in failure to install them')
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
frame {
|
83
|
+
grid sticky: 'nsew', padx: 15, pady: 15
|
84
|
+
|
85
|
+
label {
|
86
|
+
grid row: 0, column: 0
|
87
|
+
text 'Result:'
|
88
|
+
}
|
89
|
+
|
90
|
+
@result_label = label {
|
91
|
+
grid row: 0, column: 1
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}.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.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09
|
11
|
+
date: 2021-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -197,7 +197,9 @@ files:
|
|
197
197
|
- lib/glimmer/dsl/tk/data_binding_expression.rb
|
198
198
|
- lib/glimmer/dsl/tk/dsl.rb
|
199
199
|
- lib/glimmer/dsl/tk/list_selection_data_binding_expression.rb
|
200
|
+
- lib/glimmer/dsl/tk/message_box_expression.rb
|
200
201
|
- lib/glimmer/dsl/tk/root_expression.rb
|
202
|
+
- lib/glimmer/dsl/tk/shine_data_binding_expression.rb
|
201
203
|
- lib/glimmer/dsl/tk/widget_expression.rb
|
202
204
|
- lib/glimmer/tk/button_proxy.rb
|
203
205
|
- lib/glimmer/tk/entry_proxy.rb
|
@@ -208,11 +210,13 @@ files:
|
|
208
210
|
- lib/glimmer/tk/root_proxy.rb
|
209
211
|
- lib/glimmer/tk/treeview_proxy.rb
|
210
212
|
- lib/glimmer/tk/widget_proxy.rb
|
211
|
-
- samples/hello/
|
213
|
+
- samples/hello/hello_button.rb
|
214
|
+
- samples/hello/hello_combobox.rb
|
212
215
|
- samples/hello/hello_computed.rb
|
213
216
|
- samples/hello/hello_computed/contact.rb
|
214
217
|
- samples/hello/hello_list_multi_selection.rb
|
215
218
|
- samples/hello/hello_list_single_selection.rb
|
219
|
+
- samples/hello/hello_message_box.rb
|
216
220
|
- samples/hello/hello_tab.rb
|
217
221
|
- samples/hello/hello_world.rb
|
218
222
|
homepage: http://github.com/AndyObtiva/glimmer-dsl-tk
|
@@ -235,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
239
|
- !ruby/object:Gem::Version
|
236
240
|
version: '0'
|
237
241
|
requirements: []
|
238
|
-
rubygems_version: 3.2.
|
242
|
+
rubygems_version: 3.2.28
|
239
243
|
signing_key:
|
240
244
|
specification_version: 4
|
241
245
|
summary: Glimmer DSL for Tk
|