glimmer-dsl-tk 0.0.54 → 0.0.55
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/CHANGELOG.md +5 -0
- data/README.md +81 -2
- data/VERSION +1 -1
- data/glimmer-dsl-tk.gemspec +0 -0
- data/lib/glimmer/tk/scale_proxy.rb +48 -0
- data/lib/glimmer/tk/widget_proxy.rb +13 -0
- data/samples/hello/hello_scale.rb +53 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c60d4ed3e0d36df11f12decc435cc03357dfb96ec95720e7bb830b527a473f9f
|
4
|
+
data.tar.gz: 1d33536b8b2e2c5700c8d3c320b28afc7b4c6d9eb976ce8d210cae94d7b731d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc9fffd9cfdc6f75b57bcec0bb2851efe21fbfc6b46376db9350f552e29930c0f452c84654aa74a2fe4cd06e757a5470be265f533479e0a37feb8795ce473d52
|
7
|
+
data.tar.gz: 8425516afcb5698463cd23ee20b34570772bf084b29f393a8cc12302f3c3cde95c9d90671d06d4e9be7f5ae953a8d582d8c6d183d2ae55f3d1d09ea5470d320e
|
data/CHANGELOG.md
CHANGED
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.55
|
2
2
|
## MRI Ruby Desktop Development GUI Library
|
3
3
|
[](http://badge.fury.io/rb/glimmer-dsl-tk)
|
4
4
|
[](https://github.com/AndyObtiva/glimmer-dsl-tk/actions/workflows/ruby.yml)
|
@@ -100,6 +100,7 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
|
|
100
100
|
- [List Multi Selection Data-Binding](#list-multi-selection-data-binding)
|
101
101
|
- [Entry Data-Binding](#entry-data-binding)
|
102
102
|
- [Text Data-Binding](#text-data-binding)
|
103
|
+
- [Scale Data-Binding](#scale-data-binding)
|
103
104
|
- [Spinbox Data-Binding](#spinbox-data-binding)
|
104
105
|
- [Checkbutton Data-Binding](#checkbutton-data-binding)
|
105
106
|
- [Radiobutton Data-Binding](#radiobutton-data-binding)
|
@@ -132,6 +133,7 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
|
|
132
133
|
- [Hello, Menu Bar!](#hello-menu-bar)
|
133
134
|
- [Hello, Contextual Menu!](#hello-contextual-menu)
|
134
135
|
- [Hello, Labelframe!](#hello-labelframe)
|
136
|
+
- [Hello, Scale!](#hello-scale)
|
135
137
|
- [Applications](#applications)
|
136
138
|
- [Glimmer Tk Calculator](#glimmer-tk-calculator)
|
137
139
|
- [Y3network Ruby UI](#y3network-ruby-ui)
|
@@ -191,7 +193,7 @@ gem install glimmer-dsl-tk
|
|
191
193
|
|
192
194
|
Add the following to `Gemfile`:
|
193
195
|
```
|
194
|
-
gem 'glimmer-dsl-tk', '0.0.
|
196
|
+
gem 'glimmer-dsl-tk', '0.0.55'
|
195
197
|
```
|
196
198
|
|
197
199
|
And, then run:
|
@@ -768,6 +770,28 @@ It automatically handles all the Tk plumbing behind the scenes.
|
|
768
770
|
|
769
771
|
More details can be found in [Hello, Text!](#hello-text) sample below.
|
770
772
|
|
773
|
+
### Scale Data-Binding
|
774
|
+
|
775
|
+
Example:
|
776
|
+
|
777
|
+
This assumes a `Person` model with an `age` attribute.
|
778
|
+
|
779
|
+
```ruby
|
780
|
+
spinbox {
|
781
|
+
orient 'horizontal' # can be 'vertical' too
|
782
|
+
length 200
|
783
|
+
from 0.0
|
784
|
+
to 100.0
|
785
|
+
variable <=> [person, :age, on_write: ->(val) {val.to_i}]
|
786
|
+
}
|
787
|
+
```
|
788
|
+
|
789
|
+
That code binds the `variable` value of the `scale` to the `age` attribute on the `person` model.
|
790
|
+
|
791
|
+
It automatically handles all the Tk plumbing behind the scenes.
|
792
|
+
|
793
|
+
More details can be found in [Hello, Scale!](#hello-scale) sample below.
|
794
|
+
|
771
795
|
### Spinbox Data-Binding
|
772
796
|
|
773
797
|
Example:
|
@@ -3894,6 +3918,61 @@ Glimmer app:
|
|
3894
3918
|
|
3895
3919
|

|
3896
3920
|
|
3921
|
+
### Hello, Scale!
|
3922
|
+
|
3923
|
+
Glimmer code (from [samples/hello/hello_scale.rb](samples/hello/hello_scale.rb)):
|
3924
|
+
|
3925
|
+
```ruby
|
3926
|
+
require 'glimmer-dsl-tk'
|
3927
|
+
|
3928
|
+
class HelloScale
|
3929
|
+
include Glimmer
|
3930
|
+
|
3931
|
+
attr_accessor :scale_value
|
3932
|
+
|
3933
|
+
def initialize
|
3934
|
+
self.scale_value = 50
|
3935
|
+
end
|
3936
|
+
|
3937
|
+
def launch
|
3938
|
+
root {
|
3939
|
+
text 'Hello, Scale!'
|
3940
|
+
|
3941
|
+
label {
|
3942
|
+
anchor 'center'
|
3943
|
+
text <= [self, :scale_value]
|
3944
|
+
}
|
3945
|
+
|
3946
|
+
scale {
|
3947
|
+
orient 'horizontal'
|
3948
|
+
length 200
|
3949
|
+
from 0.0
|
3950
|
+
to 100.0
|
3951
|
+
variable <=> [self, :scale_value, on_write: ->(val) {val.to_i}]
|
3952
|
+
}
|
3953
|
+
}.open
|
3954
|
+
end
|
3955
|
+
end
|
3956
|
+
|
3957
|
+
HelloScale.new.launch
|
3958
|
+
```
|
3959
|
+
|
3960
|
+
Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
3961
|
+
|
3962
|
+
```
|
3963
|
+
ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_scale'"
|
3964
|
+
```
|
3965
|
+
|
3966
|
+
Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
3967
|
+
|
3968
|
+
```
|
3969
|
+
ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_scale.rb
|
3970
|
+
```
|
3971
|
+
|
3972
|
+
Glimmer app:
|
3973
|
+
|
3974
|
+

|
3975
|
+
|
3897
3976
|
## Applications
|
3898
3977
|
|
3899
3978
|
### Glimmer Tk Calculator
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.55
|
data/glimmer-dsl-tk.gemspec
CHANGED
Binary file
|
@@ -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
|
@@ -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 }},
|
@@ -428,6 +434,13 @@ module Glimmer
|
|
428
434
|
}
|
429
435
|
end,
|
430
436
|
},
|
437
|
+
::Tk::Tile::TScale => {
|
438
|
+
'variable' => lambda do |observer|
|
439
|
+
@tk.command {
|
440
|
+
observer.call(@tk.variable&.value)
|
441
|
+
}
|
442
|
+
end,
|
443
|
+
},
|
431
444
|
::Tk::Text => {
|
432
445
|
'value' => lambda do |observer|
|
433
446
|
handle_listener('modified') do
|
@@ -0,0 +1,53 @@
|
|
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
|
+
class HelloScale
|
25
|
+
include Glimmer
|
26
|
+
|
27
|
+
attr_accessor :scale_value
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
self.scale_value = 50
|
31
|
+
end
|
32
|
+
|
33
|
+
def launch
|
34
|
+
root {
|
35
|
+
text 'Hello, Scale!'
|
36
|
+
|
37
|
+
label {
|
38
|
+
anchor 'center'
|
39
|
+
text <= [self, :scale_value]
|
40
|
+
}
|
41
|
+
|
42
|
+
scale {
|
43
|
+
orient 'horizontal' # can be 'vertical' too
|
44
|
+
length 200
|
45
|
+
from 0.0
|
46
|
+
to 100.0
|
47
|
+
variable <=> [self, :scale_value, on_write: ->(val) {val.to_i}]
|
48
|
+
}
|
49
|
+
}.open
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
HelloScale.new.launch
|
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.55
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
@@ -222,6 +222,7 @@ files:
|
|
222
222
|
- lib/glimmer/tk/os.rb
|
223
223
|
- lib/glimmer/tk/radiobutton_proxy.rb
|
224
224
|
- lib/glimmer/tk/root_proxy.rb
|
225
|
+
- lib/glimmer/tk/scale_proxy.rb
|
225
226
|
- lib/glimmer/tk/scrollbar_frame_proxy.rb
|
226
227
|
- lib/glimmer/tk/spinbox_proxy.rb
|
227
228
|
- lib/glimmer/tk/text_proxy.rb
|
@@ -251,6 +252,7 @@ files:
|
|
251
252
|
- samples/hello/hello_notebook.rb
|
252
253
|
- samples/hello/hello_radiobutton.rb
|
253
254
|
- samples/hello/hello_root.rb
|
255
|
+
- samples/hello/hello_scale.rb
|
254
256
|
- samples/hello/hello_scrollbar.rb
|
255
257
|
- samples/hello/hello_scrollbar_frame.rb
|
256
258
|
- samples/hello/hello_separator.rb
|