glimmer-dsl-tk 0.0.56 → 0.0.59

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 951b8e62423c7092e9d3d34c25ea583cab0e5195b84f2553a47f36bcce2703c3
4
- data.tar.gz: 35017367771d0668aa955d0edc9776fb5d5072ffdd1b63519f920d1edc73b70f
3
+ metadata.gz: 26c20e8d681d57d11f540136ad94fd26a4f7ab51a5663eba95599dd5fa1589fe
4
+ data.tar.gz: 6f70dd20a48487e0c73135790b24e38f8080fa376cda20f1da2c8db83cb78d4c
5
5
  SHA512:
6
- metadata.gz: 78bd1d1296b43903d306daa043cbaa21f4b898703c43021387c32ed4e96019ebcff3690ac2a6e70e810ea7ccc70181df3ccefb5412e9fcebaecd9c762f14c511
7
- data.tar.gz: 3aa1e66860f386a919a63c141023d20baba0e7aaff885560d9433a817baa9e930eed812242f2a203775254eabbb4f50fb29ab905f40223a0697c7600c58c9e02
6
+ metadata.gz: 97fc2a77f286aec0cef3f0733aa1642415a0cf5ae420ea7713344b4b9f0de676d96fbb40b6cdba8d5a3338f8340a6b94ef3e6497043b86cd154258d66e320616
7
+ data.tar.gz: d48746949f04d68643d6493cab85c04bc7951da0fcbced1c7f13ab9a968d3bab6e452b8c804b2b012ab6b662c8092e87c0bea4386a214b2ccd494a94e46b6299
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.59
4
+
5
+ - Auto-Default to `validate 'key'` on an `entry` when defining `validatecommand {}`, `on('validate') {}`, `invalidcommand {}`, `on('invalid') {}`
6
+
7
+ ## 0.0.58
8
+
9
+ - Support `@tk.textvariable.trace('write')` kind of variable tracing via `on_var(trace_operation) {}` listeners (e.g. `on_textvariable('write') {}`)
10
+ - Use `on_textvariable` in `samples/hello/hello_entry.rb`
11
+ - Improve validation text in `samples/hello/hello_entry.rb` to say "... not a valid phone!"
12
+
13
+ ## 0.0.57
14
+
15
+ - Hello, Theme! sample
16
+
3
17
  ## 0.0.56
4
18
 
5
19
  - Hello, Progressbar! 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.56
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.59
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)
@@ -135,6 +135,7 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
135
135
  - [Hello, Labelframe!](#hello-labelframe)
136
136
  - [Hello, Scale!](#hello-scale)
137
137
  - [Hello, Progressbar!](#hello-progressbar)
138
+ - [Hello, Theme!](#hello-theme)
138
139
  - [Applications](#applications)
139
140
  - [Glimmer Tk Calculator](#glimmer-tk-calculator)
140
141
  - [Y3network Ruby UI](#y3network-ruby-ui)
@@ -194,7 +195,7 @@ gem install glimmer-dsl-tk
194
195
 
195
196
  Add the following to `Gemfile`:
196
197
  ```
197
- gem 'glimmer-dsl-tk', '0.0.56'
198
+ gem 'glimmer-dsl-tk', '0.0.59'
198
199
  ```
199
200
 
200
201
  And, then run:
@@ -2180,12 +2181,13 @@ class HelloEntry
2180
2181
  def launch
2181
2182
  root {
2182
2183
  title 'Hello, Entry!'
2183
-
2184
+ minsize 230, 0
2185
+
2184
2186
  label {
2185
2187
  grid sticky: 'ew'
2186
2188
  text 'default entry'
2187
2189
  }
2188
- entry {
2190
+ entry { |the_entry|
2189
2191
  grid sticky: 'ew'
2190
2192
  text <=> [self, :default]
2191
2193
  }
@@ -2204,11 +2206,14 @@ class HelloEntry
2204
2206
  grid sticky: 'ew'
2205
2207
  text 'entry with event handlers'
2206
2208
  }
2207
- entry {
2209
+ entry { |the_entry|
2208
2210
  grid sticky: 'ew'
2209
2211
  text <=> [self, :telephone]
2210
- validate 'key'
2211
2212
 
2213
+ # validate 'key' # default when on('validate') or on('invalid') is specified
2214
+ ## Validation happens on key change by default when validation listeners are specified
2215
+ ## (other accepted values: 'none', 'focus', 'focusin', 'focusout', 'key', or 'all')
2216
+
2212
2217
  ## this event kicks in just after the user typed and before modifying the text variable
2213
2218
  on('validate') do |new_text_variable|
2214
2219
  telephone?(new_text_variable.value)
@@ -2216,7 +2221,7 @@ class HelloEntry
2216
2221
 
2217
2222
  ## this event kicks in just after the text variable is validated and before it is modified
2218
2223
  on('invalid') do |validate_args|
2219
- @validated_entry_label.text = "#{validate_args.string} is not valid!"
2224
+ @validated_entry_label.text = "#{validate_args.value} is not a valid phone!"
2220
2225
  @validated_entry_label.foreground = 'red'
2221
2226
  end
2222
2227
 
@@ -2226,6 +2231,13 @@ class HelloEntry
2226
2231
  @validated_entry_label.text = 'entry with event handlers'
2227
2232
  @validated_entry_label.foreground = nil
2228
2233
  end
2234
+
2235
+ ## this is similar to on('change') (which is Glimmer-specific), but more low level at the Tk level
2236
+ ## it is the equivalent of calling: the_entry.tk.textvariable.trace('write') { puts "..." }
2237
+ ## More at: https://tkdocs.com/tutorial/widgets.html#entry and https://tcl.tk/man/tcl8.6/TclCmd/trace.htm#M14
2238
+ on_textvariable('write') do
2239
+ puts "\"#{the_entry.text}\" has been written to entry!"
2240
+ end
2229
2241
  }
2230
2242
 
2231
2243
  label {
@@ -4118,6 +4130,143 @@ Glimmer app:
4118
4130
 
4119
4131
  ![glimmer dsl tk screenshot sample hello progressbar gif](images/glimmer-dsl-tk-screenshot-sample-hello-progressbar.gif)
4120
4132
 
4133
+ ### Hello, Theme!
4134
+
4135
+ Glimmer code (from [samples/hello/hello_theme.rb](samples/hello/hello_theme.rb)):
4136
+
4137
+ ```ruby
4138
+ require 'glimmer-dsl-tk'
4139
+
4140
+ class HelloTheme
4141
+ include Glimmer
4142
+
4143
+ def launch
4144
+ root {
4145
+ title 'Hello, Theme!'
4146
+
4147
+ labelframe {
4148
+ text 'Theme'
4149
+
4150
+ combobox { |cb|
4151
+ readonly true
4152
+ values ::Tk::Tile::Style.theme_names
4153
+ text 'aqua'
4154
+
4155
+ on('<ComboboxSelected>') do
4156
+ ::Tk::Tile::Style.theme_use cb.tk.textvariable.value
4157
+ end
4158
+ }
4159
+ }
4160
+
4161
+ labelframe {
4162
+ text 'Widgets'
4163
+
4164
+ notebook {
4165
+ frame(text: 'One') {
4166
+ label {
4167
+ text 'label'
4168
+ }
4169
+
4170
+ entry {
4171
+ text 'entry'
4172
+ }
4173
+
4174
+ entry {
4175
+ text 'password'
4176
+ show '*'
4177
+ }
4178
+
4179
+ spinbox {
4180
+ text '100'
4181
+ }
4182
+ }
4183
+
4184
+ frame(text: 'Two') {
4185
+ button {
4186
+ text 'button'
4187
+ }
4188
+
4189
+ checkbutton {
4190
+ text 'checkbutton'
4191
+ }
4192
+
4193
+ radiobutton {
4194
+ text 'radiobutton'
4195
+ }
4196
+ }
4197
+
4198
+ frame(text: 'Three') {
4199
+ scale {
4200
+ orient 'horizontal'
4201
+ length 200
4202
+ from 0.0
4203
+ to 100.0
4204
+ value 50
4205
+ }
4206
+
4207
+ progressbar {
4208
+ orient 'horizontal'
4209
+ length 200
4210
+ mode 'determinate'
4211
+ maximum 100
4212
+ value 50
4213
+ }
4214
+
4215
+ progressbar {
4216
+ orient 'vertical'
4217
+ length 100
4218
+ mode 'determinate'
4219
+ maximum 100
4220
+ value 50
4221
+ }
4222
+ }
4223
+ }
4224
+ }
4225
+ }.open
4226
+ end
4227
+ end
4228
+
4229
+ HelloTheme.new.launch
4230
+ ```
4231
+
4232
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
4233
+
4234
+ ```
4235
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_theme'"
4236
+ ```
4237
+
4238
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
4239
+
4240
+ ```
4241
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_theme.rb
4242
+ ```
4243
+
4244
+ Glimmer app:
4245
+
4246
+ Aqua Theme Tab One
4247
+
4248
+ ![glimmer dsl tk screenshot sample hello theme aqua 1](images/glimmer-dsl-tk-screenshot-sample-hello-theme-aqua-tab-one.png)
4249
+
4250
+ Aqua Theme Tab Two
4251
+
4252
+ ![glimmer dsl tk screenshot sample hello theme aqua 2](images/glimmer-dsl-tk-screenshot-sample-hello-theme-aqua-tab-two.png)
4253
+
4254
+ Aqua Theme Tab Three
4255
+
4256
+ ![glimmer dsl tk screenshot sample hello theme aqua 3](images/glimmer-dsl-tk-screenshot-sample-hello-theme-aqua-tab-three.png)
4257
+
4258
+ Clam Theme Tab One
4259
+
4260
+ ![glimmer dsl tk screenshot sample hello theme clam 1](images/glimmer-dsl-tk-screenshot-sample-hello-theme-clam-tab-one.png)
4261
+
4262
+ Clam Theme Tab Two
4263
+
4264
+ ![glimmer dsl tk screenshot sample hello theme clam 2](images/glimmer-dsl-tk-screenshot-sample-hello-theme-clam-tab-two.png)
4265
+
4266
+ Clam Theme Tab Three
4267
+
4268
+ ![glimmer dsl tk screenshot sample hello theme clam 3](images/glimmer-dsl-tk-screenshot-sample-hello-theme-clam-tab-three.png)
4269
+
4121
4270
  ## Applications
4122
4271
 
4123
4272
  ### Glimmer Tk Calculator
@@ -4136,9 +4285,9 @@ https://github.com/ancorgs/y3network-ruby-ui
4136
4285
 
4137
4286
  This is a Graphical User Interface for the famous [cryptopunks Ruby gem](https://github.com/cryptopunksnotdead/cryptopunks/tree/master/cryptopunks).
4138
4287
 
4139
- https://github.com/cryptopunksnotdead/cryptopunks-gui
4288
+ https://github.com/cryptopunksnotdead/cryptopunks/tree/master/cryptopunks-gui
4140
4289
 
4141
- ![CryptoPunks GUI Screenshot](https://raw.githubusercontent.com/cryptopunksnotdead/cryptopunks-gui/master/screenshots/cryptopunks-gui-screenshot.png)
4290
+ ![CryptoPunks GUI Screenshot](https://raw.githubusercontent.com/cryptopunksnotdead/cryptopunks/master/cryptopunks-gui/screenshots/cryptopunks-gui-screenshot.png)
4142
4291
 
4143
4292
  ### Circule
4144
4293
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.56
1
+ 0.0.59
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
@@ -31,13 +31,24 @@ module Glimmer
31
31
  include TextVariableOwner
32
32
 
33
33
  def validatecommand_block=(proc)
34
+ self.validate = 'key' unless validate
34
35
  tk.validatecommand(proc)
35
36
  end
36
37
 
37
38
  def invalidcommand_block=(proc)
39
+ self.validate = 'key' unless validate
38
40
  tk.invalidcommand(proc)
39
41
  end
40
42
 
43
+ def validate
44
+ @validate
45
+ end
46
+
47
+ def validate=(value)
48
+ @validate = value
49
+ @tk.validate(value)
50
+ end
51
+
41
52
  def handle_listener(listener_name, &listener)
42
53
  case listener_name.to_s.downcase
43
54
  when 'change', 'changed', 'modified'
@@ -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,11 +61,14 @@ 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
- validate 'key'
67
67
 
68
+ # validate 'key' # default when on('validate') or on('invalid') is specified
69
+ ## Validation happens on key change by default when validation listeners are specified
70
+ ## (other accepted values: 'none', 'focus', 'focusin', 'focusout', 'key', or 'all')
71
+
68
72
  ## this event kicks in just after the user typed and before modifying the text variable
69
73
  on('validate') do |new_text_variable|
70
74
  telephone?(new_text_variable.value)
@@ -72,7 +76,7 @@ class HelloEntry
72
76
 
73
77
  ## this event kicks in just after the text variable is validated and before it is modified
74
78
  on('invalid') do |validate_args|
75
- @validated_entry_label.text = "#{validate_args.value} is not valid!"
79
+ @validated_entry_label.text = "#{validate_args.value} is not a valid phone!"
76
80
  @validated_entry_label.foreground = 'red'
77
81
  end
78
82
 
@@ -82,6 +86,13 @@ class HelloEntry
82
86
  @validated_entry_label.text = 'entry with event handlers'
83
87
  @validated_entry_label.foreground = nil
84
88
  end
89
+
90
+ ## this is similar to on('change') (which is Glimmer-specific), but more low level at the Tk level
91
+ ## it is the equivalent of calling: the_entry.tk.textvariable.trace('write') { puts "..." }
92
+ ## More at: https://tkdocs.com/tutorial/widgets.html#entry and https://tcl.tk/man/tcl8.6/TclCmd/trace.htm#M14
93
+ on_textvariable('write') do
94
+ puts "\"#{the_entry.text}\" has been written to entry!"
95
+ end
85
96
  }
86
97
 
87
98
  label {
@@ -0,0 +1,113 @@
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 HelloTheme
25
+ include Glimmer
26
+
27
+ def launch
28
+ root {
29
+ title 'Hello, Theme!'
30
+
31
+ labelframe {
32
+ text 'Theme'
33
+
34
+ combobox { |cb|
35
+ readonly true
36
+ values ::Tk::Tile::Style.theme_names
37
+ text 'aqua'
38
+
39
+ on('<ComboboxSelected>') do
40
+ ::Tk::Tile::Style.theme_use cb.tk.textvariable.value
41
+ end
42
+ }
43
+ }
44
+
45
+ labelframe {
46
+ text 'Widgets'
47
+
48
+ notebook {
49
+ frame(text: 'One') {
50
+ label {
51
+ text 'label'
52
+ }
53
+
54
+ entry {
55
+ text 'entry'
56
+ }
57
+
58
+ entry {
59
+ text 'password'
60
+ show '*'
61
+ }
62
+
63
+ spinbox {
64
+ text '100'
65
+ }
66
+ }
67
+
68
+ frame(text: 'Two') {
69
+ button {
70
+ text 'button'
71
+ }
72
+
73
+ checkbutton {
74
+ text 'checkbutton'
75
+ }
76
+
77
+ radiobutton {
78
+ text 'radiobutton'
79
+ }
80
+ }
81
+
82
+ frame(text: 'Three') {
83
+ scale {
84
+ orient 'horizontal'
85
+ length 200
86
+ from 0.0
87
+ to 100.0
88
+ value 50
89
+ }
90
+
91
+ progressbar {
92
+ orient 'horizontal'
93
+ length 200
94
+ mode 'determinate'
95
+ maximum 100
96
+ value 50
97
+ }
98
+
99
+ progressbar {
100
+ orient 'vertical'
101
+ length 100
102
+ mode 'determinate'
103
+ maximum 100
104
+ value 50
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }.open
110
+ end
111
+ end
112
+
113
+ HelloTheme.new.launch
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.56
4
+ version: 0.0.59
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-26 00:00:00.000000000 Z
11
+ date: 2022-05-21 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
@@ -259,6 +260,7 @@ files:
259
260
  - samples/hello/hello_separator.rb
260
261
  - samples/hello/hello_spinbox.rb
261
262
  - samples/hello/hello_text.rb
263
+ - samples/hello/hello_theme.rb
262
264
  - samples/hello/hello_toplevel.rb
263
265
  - samples/hello/hello_world.rb
264
266
  - samples/hello/images/align-center.png