glimmer-dsl-tk 0.0.57 → 0.0.58

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e0e1ed1843f904d42892c7fe2546383717da65d7cfd0690b1b66101a5b68576
4
- data.tar.gz: af96af00f8b06606ac584ab14d5d8d360977a58ec354053a0826edc470c0d57f
3
+ metadata.gz: cf96d61575c30434197c7edfe2bfb6e6fd9fb84c70c18c0e924d688418351315
4
+ data.tar.gz: eaa003fd150d7fac2e85196e477714ea7df87d7a4651e44c0a909b8c566085c3
5
5
  SHA512:
6
- metadata.gz: '01787afce29bc0b1d4656b8ab646f0eb4501a8b8feb23979ad99970f6e5d6bb75d5945bb0b9a9a91cdb34f36d6bdf9226ec3e3aa60368206cd98b40daa2cd0a1'
7
- data.tar.gz: 677f8d13ab20b7857c613167d1d21eed0dec3f1b19a8b29ba4b4cec49545186446c2c9bacbaf9e0741c16ceb2d20e60136c482dc6e78783d8b1d435ed4239be8
6
+ metadata.gz: 9451fadd605400721e4fd02a601e2720a2e4a41daa28aa0fa69b32f43ae1334de5ecde54ed2cd7d0f13bebdcdfe666daa4391c585fbea24302556eec8389f8af
7
+ data.tar.gz: c9e1ad3acd64c17b7642500ed7764c8f3be955de5a5a34d9cd482ac65a23aaba613396d6b14cfaddcd1537d63df6c3e810e723cd48c46bbcb318b00e4b5bc1ed
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.58
4
+
5
+ - Support `@tk.textvariable.trace('write')` kind of variable tracing via `on_var(trace_operation) {}` listeners (e.g. `on_textvariable('write') {}`)
6
+ - Use `on_textvariable` in `samples/hello/hello_entry.rb`
7
+ - Improve validation text in `samples/hello/hello_entry.rb` to say "... not a valid phone!"
8
+
3
9
  ## 0.0.57
4
10
 
5
11
  - Hello, Theme! sample
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.57
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.58
2
2
  ## Ruby Tk 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
  [![Ruby](https://github.com/AndyObtiva/glimmer-dsl-tk/actions/workflows/ruby.yml/badge.svg)](https://github.com/AndyObtiva/glimmer-dsl-tk/actions/workflows/ruby.yml)
@@ -195,7 +195,7 @@ gem install glimmer-dsl-tk
195
195
 
196
196
  Add the following to `Gemfile`:
197
197
  ```
198
- gem 'glimmer-dsl-tk', '0.0.57'
198
+ gem 'glimmer-dsl-tk', '0.0.58'
199
199
  ```
200
200
 
201
201
  And, then run:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.57
1
+ 0.0.58
Binary file
@@ -37,6 +37,7 @@ module Glimmer
37
37
  Tk,
38
38
  %w[
39
39
  list_selection_data_binding
40
+ variable_listener
40
41
  data_binding
41
42
  attribute
42
43
  shine_data_binding
@@ -0,0 +1,41 @@
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/expression'
23
+ require 'glimmer/tk/widget_proxy'
24
+
25
+ module Glimmer
26
+ module DSL
27
+ module Tk
28
+ class VariableListenerExpression < Expression
29
+ def can_interpret?(parent, keyword, *args, &block)
30
+ parent.is_a?(Glimmer::Tk::WidgetProxy) && keyword.match(/^on_.*/) && textual?(args.first)
31
+ end
32
+
33
+ def interpret(parent, keyword, *args, &block)
34
+ variable_name = keyword.sub(/^on_/, '')
35
+ operation = args.first.to_s
36
+ parent.tk.send(variable_name).trace(operation, &block)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -36,12 +36,13 @@ class HelloEntry
36
36
  def launch
37
37
  root {
38
38
  title 'Hello, Entry!'
39
-
39
+ minsize 230, 0
40
+
40
41
  label {
41
42
  grid sticky: 'ew'
42
43
  text 'default entry'
43
44
  }
44
- entry {
45
+ entry { |the_entry|
45
46
  grid sticky: 'ew'
46
47
  text <=> [self, :default]
47
48
  }
@@ -60,7 +61,7 @@ class HelloEntry
60
61
  grid sticky: 'ew'
61
62
  text 'entry with event handlers'
62
63
  }
63
- entry {
64
+ entry { |the_entry|
64
65
  grid sticky: 'ew'
65
66
  text <=> [self, :telephone]
66
67
  validate 'key'
@@ -72,7 +73,7 @@ class HelloEntry
72
73
 
73
74
  ## this event kicks in just after the text variable is validated and before it is modified
74
75
  on('invalid') do |validate_args|
75
- @validated_entry_label.text = "#{validate_args.value} is not valid!"
76
+ @validated_entry_label.text = "#{validate_args.value} is not a valid phone!"
76
77
  @validated_entry_label.foreground = 'red'
77
78
  end
78
79
 
@@ -82,6 +83,13 @@ class HelloEntry
82
83
  @validated_entry_label.text = 'entry with event handlers'
83
84
  @validated_entry_label.foreground = nil
84
85
  end
86
+
87
+ ## this is similar to on('change') (which is Glimmer-specific), but more low level at the Tk level
88
+ ## it is the equivalent of calling: the_entry.tk.textvariable.trace('write') { puts "..." }
89
+ ## More at: https://tkdocs.com/tutorial/widgets.html#entry and https://tcl.tk/man/tcl8.6/TclCmd/trace.htm#M14
90
+ on_textvariable('write') do
91
+ puts "\"#{the_entry.text}\" has been written to entry!"
92
+ end
85
93
  }
86
94
 
87
95
  label {
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.57
4
+ version: 0.0.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-28 00:00:00.000000000 Z
11
+ date: 2022-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -205,6 +205,7 @@ files:
205
205
  - lib/glimmer/dsl/tk/on_expression.rb
206
206
  - lib/glimmer/dsl/tk/root_expression.rb
207
207
  - lib/glimmer/dsl/tk/shine_data_binding_expression.rb
208
+ - lib/glimmer/dsl/tk/variable_listener_expression.rb
208
209
  - lib/glimmer/dsl/tk/widget_expression.rb
209
210
  - lib/glimmer/tk/checkbutton_proxy.rb
210
211
  - lib/glimmer/tk/combobox_proxy.rb