glimmer-dsl-tk 0.0.12 → 0.0.13
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.
- checksums.yaml +4 -4
- data/README.md +123 -13
- data/VERSION +1 -1
- data/glimmer-dsl-tk.gemspec +0 -0
- data/lib/glimmer/dsl/tk/message_box_expression.rb +36 -0
- data/samples/hello/{hello_combo.rb → hello_combobox.rb} +3 -3
- data/samples/hello/hello_message_box.rb +94 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dd8908007208ff366a6605b4193d5202c3b81994c9a39288f6f8b6f72c3ec95
|
4
|
+
data.tar.gz: 2a4651e42e10d7112d30823414f768d7c5607eaeb3a9e8de5b81af4adc932536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd1c4ccaa1d1ea01b07f627333bac1d2b50f2e4a7eb1abb04f8e267b547fd2874daa62ae244eae86264d0f1c0fec6f3b040325b45343b360b09c1008b2468f1b
|
7
|
+
data.tar.gz: 1b77271bdd9288256625d3528537033adbd07397c3348a29d60434142b56fe3928fa8128a5981815aa94e5f63eee95404d61497c0f93da5cb6ae3fe88be81f99
|
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.13
|
2
2
|
## MRI Ruby Desktop Development GUI Library
|
3
3
|
[](http://badge.fury.io/rb/glimmer-dsl-tk)
|
4
4
|
[](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
|
|
@@ -81,7 +81,7 @@ gem install glimmer-dsl-tk
|
|
81
81
|
|
82
82
|
Add the following to `Gemfile`:
|
83
83
|
```
|
84
|
-
gem 'glimmer-dsl-tk', '~> 0.0.
|
84
|
+
gem 'glimmer-dsl-tk', '~> 0.0.13'
|
85
85
|
```
|
86
86
|
|
87
87
|
And, then run:
|
@@ -167,6 +167,23 @@ root {
|
|
167
167
|
}.open
|
168
168
|
```
|
169
169
|
|
170
|
+
### Supported Widgets
|
171
|
+
|
172
|
+
keyword(args) | attributes | listeners/events
|
173
|
+
------------- | ---------- | ---------
|
174
|
+
`button` | `text` | `command`
|
175
|
+
`entry` | `width`, `text` | None
|
176
|
+
`frame(text: )` | None | None
|
177
|
+
`label` | `text` | None
|
178
|
+
`list` | `selectmode`, `selection` | None
|
179
|
+
`message_box(type: , message: , detail: , title: , icon: , default: , parent: )` | None | None
|
180
|
+
`notebook` | None | None
|
181
|
+
`root` | `title`, `iconphoto` | None
|
182
|
+
|
183
|
+
#### Common Attributes
|
184
|
+
|
185
|
+
- `grid`
|
186
|
+
|
170
187
|
### Smart Defaults and Convensions
|
171
188
|
|
172
189
|
#### Grid Layout
|
@@ -221,7 +238,7 @@ More details can be found in the [Hello, Computed!](#hello-computed) sample belo
|
|
221
238
|
|
222
239
|
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).
|
223
240
|
|
224
|
-
###
|
241
|
+
### Combobox Data-Binding
|
225
242
|
|
226
243
|
Example:
|
227
244
|
|
@@ -239,7 +256,7 @@ It also binds the `text` selection of the `combobox` to the `country` property o
|
|
239
256
|
|
240
257
|
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
258
|
|
242
|
-
More details can be found in the [Hello,
|
259
|
+
More details can be found in the [Hello, Combobox!](#hello-combobox) sample below.
|
243
260
|
|
244
261
|
### List Single Selection Data-Binding
|
245
262
|
|
@@ -337,7 +354,7 @@ Example:
|
|
337
354
|
|
338
355
|
This resets the person country.
|
339
356
|
|
340
|
-
More details can be found in the [Hello,
|
357
|
+
More details can be found in the [Hello, Combobox!](#hello-combobox) sample below.
|
341
358
|
|
342
359
|
## Samples
|
343
360
|
|
@@ -414,14 +431,107 @@ Glimmer app:
|
|
414
431
|

|
415
432
|

|
416
433
|
|
417
|
-
### Hello,
|
434
|
+
### Hello, Message Box!
|
435
|
+
|
436
|
+
Glimmer code (from [samples/hello/hello_message_box.rb](samples/hello/hello_message_box.rb)):
|
437
|
+
|
438
|
+
```ruby
|
439
|
+
root { |r|
|
440
|
+
title 'Hello, Message Box!'
|
441
|
+
|
442
|
+
frame {
|
443
|
+
grid sticky: 'nsew', padx: 15, pady: 15
|
444
|
+
|
445
|
+
button {
|
446
|
+
text 'Please Click To Win a Surprise'
|
447
|
+
|
448
|
+
command {
|
449
|
+
# specifying parent ensures dialog shows up centered on top of window (instead of centered in display monitor)
|
450
|
+
@result_label.text = message_box(parent: r, title: 'Surprise', message: "Congratulations!\n\nYou won $1,000,000!") # type: 'ok' by default
|
451
|
+
}
|
452
|
+
}
|
453
|
+
|
454
|
+
button {
|
455
|
+
text 'Download Software Update'
|
456
|
+
|
457
|
+
command {
|
458
|
+
@result_label.text = message_box(type: 'okcancel', title: 'Software Update', message: "We will begin to download software update.")
|
459
|
+
}
|
460
|
+
}
|
461
|
+
|
462
|
+
button {
|
463
|
+
text 'Format Hard Drive'
|
464
|
+
|
465
|
+
command {
|
466
|
+
@result_label.text = message_box(type: 'yesno', icon: 'question', title: 'Format', message: "Would you like to format your hard drive?")
|
467
|
+
}
|
468
|
+
}
|
469
|
+
|
470
|
+
button {
|
471
|
+
text 'Submit Application'
|
472
|
+
|
473
|
+
command {
|
474
|
+
@result_label.text = message_box(type: 'yesnocancel', icon: 'question', title: 'Application', message: "Would you like to review application before submitting?")
|
475
|
+
}
|
476
|
+
}
|
477
|
+
|
478
|
+
button {
|
479
|
+
text 'Play Video'
|
480
|
+
|
481
|
+
command {
|
482
|
+
@result_label.text = message_box(type: 'retrycancel', icon: 'error', title: 'Video Replay', message: "Video has failed to play. Would you like to retry?")
|
483
|
+
}
|
484
|
+
}
|
485
|
+
|
486
|
+
button {
|
487
|
+
text 'Installation Completed'
|
488
|
+
|
489
|
+
command {
|
490
|
+
@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')
|
491
|
+
}
|
492
|
+
}
|
493
|
+
}
|
494
|
+
|
495
|
+
frame {
|
496
|
+
grid sticky: 'nsew', padx: 15, pady: 15
|
497
|
+
|
498
|
+
label {
|
499
|
+
grid row: 0, column: 0
|
500
|
+
text 'Result:'
|
501
|
+
}
|
502
|
+
|
503
|
+
@result_label = label {
|
504
|
+
grid row: 0, column: 1
|
505
|
+
}
|
506
|
+
}
|
507
|
+
}.open
|
508
|
+
```
|
509
|
+
|
510
|
+
Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
511
|
+
|
512
|
+
```
|
513
|
+
ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_tab'"
|
514
|
+
```
|
515
|
+
|
516
|
+
Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
517
|
+
|
518
|
+
```
|
519
|
+
ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_tab'"
|
520
|
+
```
|
521
|
+
|
522
|
+
Glimmer app:
|
523
|
+
|
524
|
+

|
525
|
+

|
526
|
+
|
527
|
+
### Hello, Combobox!
|
418
528
|
|
419
|
-
Glimmer code (from [samples/hello/
|
529
|
+
Glimmer code (from [samples/hello/hello_combobox.rb](samples/hello/hello_combobox.rb)):
|
420
530
|
|
421
531
|
```ruby
|
422
532
|
# ... more code precedes
|
423
533
|
root {
|
424
|
-
title 'Hello,
|
534
|
+
title 'Hello, Combobox!'
|
425
535
|
|
426
536
|
combobox { |proxy|
|
427
537
|
state 'readonly'
|
@@ -441,19 +551,19 @@ root {
|
|
441
551
|
Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
442
552
|
|
443
553
|
```
|
444
|
-
ruby -r glimmer-dsl-tk -e "require 'samples/hello/
|
554
|
+
ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_combobox'"
|
445
555
|
```
|
446
556
|
|
447
557
|
Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
448
558
|
|
449
559
|
```
|
450
|
-
ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/
|
560
|
+
ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_combobox'"
|
451
561
|
```
|
452
562
|
|
453
563
|
Glimmer app:
|
454
564
|
|
455
|
-

|
566
|
+

|
457
567
|
|
458
568
|
### Hello, List Single Selection!
|
459
569
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.13
|
data/glimmer-dsl-tk.gemspec
CHANGED
Binary file
|
@@ -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
|
@@ -34,14 +34,14 @@ 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'
|
@@ -58,4 +58,4 @@ class HelloCombo
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
|
61
|
+
HelloCombobox.new.launch
|
@@ -0,0 +1,94 @@
|
|
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-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,7 +1,7 @@
|
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
@@ -197,6 +197,7 @@ 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
|
201
202
|
- lib/glimmer/dsl/tk/shine_data_binding_expression.rb
|
202
203
|
- lib/glimmer/dsl/tk/widget_expression.rb
|
@@ -209,11 +210,12 @@ files:
|
|
209
210
|
- lib/glimmer/tk/root_proxy.rb
|
210
211
|
- lib/glimmer/tk/treeview_proxy.rb
|
211
212
|
- lib/glimmer/tk/widget_proxy.rb
|
212
|
-
- samples/hello/
|
213
|
+
- samples/hello/hello_combobox.rb
|
213
214
|
- samples/hello/hello_computed.rb
|
214
215
|
- samples/hello/hello_computed/contact.rb
|
215
216
|
- samples/hello/hello_list_multi_selection.rb
|
216
217
|
- samples/hello/hello_list_single_selection.rb
|
218
|
+
- samples/hello/hello_message_box.rb
|
217
219
|
- samples/hello/hello_tab.rb
|
218
220
|
- samples/hello/hello_world.rb
|
219
221
|
homepage: http://github.com/AndyObtiva/glimmer-dsl-tk
|