glimmer-dsl-tk 0.0.55 → 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: c60d4ed3e0d36df11f12decc435cc03357dfb96ec95720e7bb830b527a473f9f
4
- data.tar.gz: 1d33536b8b2e2c5700c8d3c320b28afc7b4c6d9eb976ce8d210cae94d7b731d5
3
+ metadata.gz: cf96d61575c30434197c7edfe2bfb6e6fd9fb84c70c18c0e924d688418351315
4
+ data.tar.gz: eaa003fd150d7fac2e85196e477714ea7df87d7a4651e44c0a909b8c566085c3
5
5
  SHA512:
6
- metadata.gz: fc9fffd9cfdc6f75b57bcec0bb2851efe21fbfc6b46376db9350f552e29930c0f452c84654aa74a2fe4cd06e757a5470be265f533479e0a37feb8795ce473d52
7
- data.tar.gz: 8425516afcb5698463cd23ee20b34570772bf084b29f393a8cc12302f3c3cde95c9d90671d06d4e9be7f5ae953a8d582d8c6d183d2ae55f3d1d09ea5470d320e
6
+ metadata.gz: 9451fadd605400721e4fd02a601e2720a2e4a41daa28aa0fa69b32f43ae1334de5ecde54ed2cd7d0f13bebdcdfe666daa4391c585fbea24302556eec8389f8af
7
+ data.tar.gz: c9e1ad3acd64c17b7642500ed7764c8f3be955de5a5a34d9cd482ac65a23aaba613396d6b14cfaddcd1537d63df6c3e810e723cd48c46bbcb318b00e4b5bc1ed
data/CHANGELOG.md CHANGED
@@ -1,13 +1,28 @@
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
+
9
+ ## 0.0.57
10
+
11
+ - Hello, Theme! sample
12
+
13
+ ## 0.0.56
14
+
15
+ - Hello, Progressbar! sample
16
+ - Upgrade to glimmer 2.7.3
17
+
3
18
  ## 0.0.55
4
19
 
5
- - Hello, Scale!
20
+ - Hello, Scale! sample
6
21
  - `scale` `variable` data-binding
7
22
 
8
23
  ## 0.0.54
9
24
 
10
- - Hello, Labelframe!
25
+ - Hello, Labelframe! sample
11
26
  - Add default padding to `labelframe`
12
27
 
13
28
  ## 0.0.53
data/README.md CHANGED
@@ -1,5 +1,5 @@
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
- ## MRI Ruby Desktop Development GUI Library
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
+ ## 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)
5
5
  [![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)
@@ -57,7 +57,7 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
57
57
  [Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)](https://github.com/AndyObtiva/glimmer-dsl-swt) | Mac / Windows / Linux | Yes | Yes (Canvas Shape DSL) | Very Mature / Scaffolding / Native Executable Packaging / Custom Widgets | Slow JRuby Startup Time / Heavy Memory Footprint | Java / JRuby
58
58
  [Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)](https://github.com/AndyObtiva/glimmer-dsl-opal) | All Web Browsers | No | Yes (Canvas Shape DSL) | Simpler than All JavaScript Technologies / Auto-Webify Desktop Apps | Setup Process / Incomplete Alpha | Rails
59
59
  [Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-libui) | Mac / Windows / Linux | Yes | Yes (Area API) | Fast Startup Time / Light Memory Footprint | LibUI is an Incomplete Mid-Alpha Only | None Other Than MRI Ruby
60
- [Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-tk) | Mac / Windows / Linux | Some Native-Themed Widgets (Not Truly Native) | Yes (Canvas) | Fast Startup Time / Light Memory Footprint | Complicated setup / Widgets Do Not Look Truly Native, Espcially on Linux | ActiveTcl / MRI Ruby
60
+ [Glimmer DSL for Tk (Ruby Tk Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-tk) | Mac / Windows / Linux | Some Native-Themed Widgets (Not Truly Native) | Yes (Canvas) | Fast Startup Time / Light Memory Footprint | Complicated setup / Widgets Do Not Look Truly Native, Espcially on Linux | ActiveTcl / MRI Ruby
61
61
  [Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-gtk) | Mac / Windows / Linux | Only on Linux | Yes (Cairo) | Complete Access to GNOME Features on Linux (Forte) | Not Native on Mac and Windows | None Other Than MRI Ruby on Linux / Brew Packages on Mac / MSYS & MING Toolchains on Windows / MRI Ruby
62
62
  [Glimmer DSL for FX (FOX Toolkit Ruby Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-fx) | Mac (requires XQuartz) / Windows / Linux | No | Yes (Canvas) | No Prerequisites on Windows (Forte Since Binaries Are Included Out of The Box) | Widgets Do Not Look Native / Mac Usage Obtrusively Starts XQuartz | None Other Than MRI Ruby on Windows / XQuarts on Mac / MRI Ruby
63
63
  [Glimmer DSL for JFX (JRuby JavaFX Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-jfx) | Mac / Windows / Linux | No | Yes (javafx.scene.shape and javafx.scene.canvas) | Rich in Custom Widgets | Slow JRuby Startup Time / Heavy Memory Footprint / Widgets Do Not Look Native | Java / JRuby / JavaFX SDK
@@ -134,6 +134,8 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
134
134
  - [Hello, Contextual Menu!](#hello-contextual-menu)
135
135
  - [Hello, Labelframe!](#hello-labelframe)
136
136
  - [Hello, Scale!](#hello-scale)
137
+ - [Hello, Progressbar!](#hello-progressbar)
138
+ - [Hello, Theme!](#hello-theme)
137
139
  - [Applications](#applications)
138
140
  - [Glimmer Tk Calculator](#glimmer-tk-calculator)
139
141
  - [Y3network Ruby UI](#y3network-ruby-ui)
@@ -193,7 +195,7 @@ gem install glimmer-dsl-tk
193
195
 
194
196
  Add the following to `Gemfile`:
195
197
  ```
196
- gem 'glimmer-dsl-tk', '0.0.55'
198
+ gem 'glimmer-dsl-tk', '0.0.58'
197
199
  ```
198
200
 
199
201
  And, then run:
@@ -792,6 +794,28 @@ It automatically handles all the Tk plumbing behind the scenes.
792
794
 
793
795
  More details can be found in [Hello, Scale!](#hello-scale) sample below.
794
796
 
797
+ ### Progressbar Data-Binding
798
+
799
+ Example:
800
+
801
+ This assumes a `Worker` model with a `progress_value` attribute.
802
+
803
+ ```ruby
804
+ progressbar {
805
+ orient 'horizontal' # can be vertical too
806
+ length 200
807
+ mode 'determinate'
808
+ maximum 100
809
+ value <= [worker, :progress_value]
810
+ }
811
+ ```
812
+
813
+ That code binds the value of the `progressbar` to the `progress_value` attribute on the `worker` model.
814
+
815
+ It automatically handles all the Tk plumbing behind the scenes.
816
+
817
+ More details can be found in [Hello, Progressbar!](#hello-progressbar) sample below.
818
+
795
819
  ### Spinbox Data-Binding
796
820
 
797
821
  Example:
@@ -3973,6 +3997,265 @@ Glimmer app:
3973
3997
 
3974
3998
  ![glimmer dsl tk screenshot sample hello scale](images/glimmer-dsl-tk-screenshot-sample-hello-scale.png)
3975
3999
 
4000
+ ### Hello, Progressbar!
4001
+
4002
+ Glimmer code (from [samples/hello/hello_progressbar.rb](samples/hello/hello_progressbar.rb)):
4003
+
4004
+ ```ruby
4005
+ require 'glimmer-dsl-tk'
4006
+
4007
+ class HelloProgressbar
4008
+ include Glimmer
4009
+
4010
+ attr_accessor :progress_value, :maximum_value, :delay_value
4011
+
4012
+ def initialize
4013
+ self.progress_value = 0
4014
+ self.maximum_value = 100
4015
+ self.delay_value = 0.01
4016
+
4017
+ Thread.new do
4018
+ loop do
4019
+ self.progress_value = (self.progress_value.to_i + 1) % (maximum_value.to_i + 1)
4020
+ sleep(delay_value) # yields to main thread
4021
+ end
4022
+ end
4023
+ end
4024
+
4025
+ def launch
4026
+ root {
4027
+ text 'Hello, Progressbar!'
4028
+
4029
+ progressbar {
4030
+ grid row: 0, column: 0, columnspan: 3
4031
+ orient 'horizontal'
4032
+ length 200
4033
+ mode 'indeterminate'
4034
+ maximum <= [self, :maximum_value]
4035
+ value <= [self, :progress_value]
4036
+ }
4037
+
4038
+ label {
4039
+ grid row: 1, column: 0
4040
+ text 'Value'
4041
+ }
4042
+
4043
+ label {
4044
+ grid row: 1, column: 1
4045
+ text 'Maximum'
4046
+ }
4047
+
4048
+ label {
4049
+ grid row: 1, column: 2
4050
+ text 'Delay in Seconds'
4051
+ }
4052
+
4053
+ spinbox {
4054
+ grid row: 2, column: 0
4055
+ from 0.0
4056
+ to 100.0
4057
+ increment 1.0
4058
+ format '%0f'
4059
+ text <=> [self, :progress_value, on_read: :to_i, on_write: :to_i]
4060
+ }
4061
+
4062
+ spinbox {
4063
+ grid row: 2, column: 1
4064
+ from 1.0
4065
+ to 100.0
4066
+ increment 1.0
4067
+ format '%0f'
4068
+ text <=> [self, :maximum_value, on_read: :to_i, on_write: :to_i]
4069
+ }
4070
+
4071
+ spinbox {
4072
+ grid row: 2, column: 2
4073
+ from 0.01
4074
+ to 1.0
4075
+ increment 0.1
4076
+ format '%0.2f'
4077
+ text <=> [self, :delay_value, on_write: ->(val) {[val.to_f, 1.0].min}]
4078
+ }
4079
+
4080
+ progressbar {
4081
+ grid row: 3, column: 0, columnspan: 3
4082
+ orient 'horizontal'
4083
+ length 200
4084
+ mode 'determinate'
4085
+ maximum <= [self, :maximum_value]
4086
+ value <= [self, :progress_value]
4087
+ }
4088
+
4089
+ progressbar {
4090
+ grid row: 4, column: 0, columnspan: 3
4091
+ orient 'vertical'
4092
+ length 200
4093
+ mode 'determinate'
4094
+ maximum <= [self, :maximum_value]
4095
+ value <= [self, :progress_value]
4096
+ }
4097
+ }.open
4098
+ end
4099
+ end
4100
+
4101
+ HelloProgressbar.new.launch
4102
+ ```
4103
+
4104
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
4105
+
4106
+ ```
4107
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_progressbar'"
4108
+ ```
4109
+
4110
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
4111
+
4112
+ ```
4113
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_progressbar.rb
4114
+ ```
4115
+
4116
+ Glimmer app:
4117
+
4118
+ ![glimmer dsl tk screenshot sample hello progressbar](images/glimmer-dsl-tk-screenshot-sample-hello-progressbar.png)
4119
+
4120
+ ![glimmer dsl tk screenshot sample hello progressbar gif](images/glimmer-dsl-tk-screenshot-sample-hello-progressbar.gif)
4121
+
4122
+ ### Hello, Theme!
4123
+
4124
+ Glimmer code (from [samples/hello/hello_theme.rb](samples/hello/hello_theme.rb)):
4125
+
4126
+ ```ruby
4127
+ require 'glimmer-dsl-tk'
4128
+
4129
+ class HelloTheme
4130
+ include Glimmer
4131
+
4132
+ def launch
4133
+ root {
4134
+ title 'Hello, Theme!'
4135
+
4136
+ labelframe {
4137
+ text 'Theme'
4138
+
4139
+ combobox { |cb|
4140
+ readonly true
4141
+ values ::Tk::Tile::Style.theme_names
4142
+ text 'aqua'
4143
+
4144
+ on('<ComboboxSelected>') do
4145
+ ::Tk::Tile::Style.theme_use cb.tk.textvariable.value
4146
+ end
4147
+ }
4148
+ }
4149
+
4150
+ labelframe {
4151
+ text 'Widgets'
4152
+
4153
+ notebook {
4154
+ frame(text: 'One') {
4155
+ label {
4156
+ text 'label'
4157
+ }
4158
+
4159
+ entry {
4160
+ text 'entry'
4161
+ }
4162
+
4163
+ entry {
4164
+ text 'password'
4165
+ show '*'
4166
+ }
4167
+
4168
+ spinbox {
4169
+ text '100'
4170
+ }
4171
+ }
4172
+
4173
+ frame(text: 'Two') {
4174
+ button {
4175
+ text 'button'
4176
+ }
4177
+
4178
+ checkbutton {
4179
+ text 'checkbutton'
4180
+ }
4181
+
4182
+ radiobutton {
4183
+ text 'radiobutton'
4184
+ }
4185
+ }
4186
+
4187
+ frame(text: 'Three') {
4188
+ scale {
4189
+ orient 'horizontal'
4190
+ length 200
4191
+ from 0.0
4192
+ to 100.0
4193
+ value 50
4194
+ }
4195
+
4196
+ progressbar {
4197
+ orient 'horizontal'
4198
+ length 200
4199
+ mode 'determinate'
4200
+ maximum 100
4201
+ value 50
4202
+ }
4203
+
4204
+ progressbar {
4205
+ orient 'vertical'
4206
+ length 100
4207
+ mode 'determinate'
4208
+ maximum 100
4209
+ value 50
4210
+ }
4211
+ }
4212
+ }
4213
+ }
4214
+ }.open
4215
+ end
4216
+ end
4217
+
4218
+ HelloTheme.new.launch
4219
+ ```
4220
+
4221
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
4222
+
4223
+ ```
4224
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_theme'"
4225
+ ```
4226
+
4227
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
4228
+
4229
+ ```
4230
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_theme.rb
4231
+ ```
4232
+
4233
+ Glimmer app:
4234
+
4235
+ Aqua Theme Tab One
4236
+
4237
+ ![glimmer dsl tk screenshot sample hello theme aqua 1](images/glimmer-dsl-tk-screenshot-sample-hello-theme-aqua-tab-one.png)
4238
+
4239
+ Aqua Theme Tab Two
4240
+
4241
+ ![glimmer dsl tk screenshot sample hello theme aqua 2](images/glimmer-dsl-tk-screenshot-sample-hello-theme-aqua-tab-two.png)
4242
+
4243
+ Aqua Theme Tab Three
4244
+
4245
+ ![glimmer dsl tk screenshot sample hello theme aqua 3](images/glimmer-dsl-tk-screenshot-sample-hello-theme-aqua-tab-three.png)
4246
+
4247
+ Clam Theme Tab One
4248
+
4249
+ ![glimmer dsl tk screenshot sample hello theme clam 1](images/glimmer-dsl-tk-screenshot-sample-hello-theme-clam-tab-one.png)
4250
+
4251
+ Clam Theme Tab Two
4252
+
4253
+ ![glimmer dsl tk screenshot sample hello theme clam 2](images/glimmer-dsl-tk-screenshot-sample-hello-theme-clam-tab-two.png)
4254
+
4255
+ Clam Theme Tab Three
4256
+
4257
+ ![glimmer dsl tk screenshot sample hello theme clam 3](images/glimmer-dsl-tk-screenshot-sample-hello-theme-clam-tab-three.png)
4258
+
3976
4259
  ## Applications
3977
4260
 
3978
4261
  ### Glimmer Tk Calculator
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.55
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 {
@@ -0,0 +1,118 @@
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 HelloProgressbar
25
+ include Glimmer
26
+
27
+ attr_accessor :progress_value, :maximum_value, :delay_value
28
+
29
+ def initialize
30
+ self.progress_value = 0
31
+ self.maximum_value = 100
32
+ self.delay_value = 0.01
33
+
34
+ Thread.new do
35
+ loop do
36
+ self.progress_value = (self.progress_value.to_i + 1) % (maximum_value.to_i + 1)
37
+ sleep(delay_value) # yields to main thread
38
+ end
39
+ end
40
+ end
41
+
42
+ def launch
43
+ root {
44
+ text 'Hello, Progressbar!'
45
+
46
+ progressbar {
47
+ grid row: 0, column: 0, columnspan: 3
48
+ orient 'horizontal'
49
+ length 200
50
+ mode 'indeterminate'
51
+ maximum <= [self, :maximum_value]
52
+ value <= [self, :progress_value]
53
+ }
54
+
55
+ label {
56
+ grid row: 1, column: 0
57
+ text 'Value'
58
+ }
59
+
60
+ label {
61
+ grid row: 1, column: 1
62
+ text 'Maximum'
63
+ }
64
+
65
+ label {
66
+ grid row: 1, column: 2
67
+ text 'Delay in Seconds'
68
+ }
69
+
70
+ spinbox {
71
+ grid row: 2, column: 0
72
+ from 0.0
73
+ to 100.0
74
+ increment 1.0
75
+ format '%0f'
76
+ text <=> [self, :progress_value, on_read: :to_i, on_write: :to_i]
77
+ }
78
+
79
+ spinbox {
80
+ grid row: 2, column: 1
81
+ from 1.0
82
+ to 100.0
83
+ increment 1.0
84
+ format '%0f'
85
+ text <=> [self, :maximum_value, on_read: :to_i, on_write: :to_i]
86
+ }
87
+
88
+ spinbox {
89
+ grid row: 2, column: 2
90
+ from 0.01
91
+ to 1.0
92
+ increment 0.1
93
+ format '%0.2f'
94
+ text <=> [self, :delay_value, on_write: ->(val) {[val.to_f, 1.0].min}]
95
+ }
96
+
97
+ progressbar {
98
+ grid row: 3, column: 0, columnspan: 3
99
+ orient 'horizontal'
100
+ length 200
101
+ mode 'determinate'
102
+ maximum <= [self, :maximum_value]
103
+ value <= [self, :progress_value]
104
+ }
105
+
106
+ progressbar {
107
+ grid row: 4, column: 0, columnspan: 3
108
+ orient 'vertical'
109
+ length 200
110
+ mode 'determinate'
111
+ maximum <= [self, :maximum_value]
112
+ value <= [self, :progress_value]
113
+ }
114
+ }.open
115
+ end
116
+ end
117
+
118
+ HelloProgressbar.new.launch
@@ -44,7 +44,7 @@ class HelloScale
44
44
  length 200
45
45
  from 0.0
46
46
  to 100.0
47
- variable <=> [self, :scale_value, on_write: ->(val) {val.to_i}]
47
+ variable <=> [self, :scale_value, on_write: :to_i]
48
48
  }
49
49
  }.open
50
50
  end
@@ -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.55
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-02-20 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
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.6.0
19
+ version: 2.7.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.6.0
26
+ version: 2.7.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: puts_debuggerer
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -250,6 +251,7 @@ files:
250
251
  - samples/hello/hello_menu_bar.rb
251
252
  - samples/hello/hello_message_box.rb
252
253
  - samples/hello/hello_notebook.rb
254
+ - samples/hello/hello_progressbar.rb
253
255
  - samples/hello/hello_radiobutton.rb
254
256
  - samples/hello/hello_root.rb
255
257
  - samples/hello/hello_scale.rb
@@ -258,6 +260,7 @@ files:
258
260
  - samples/hello/hello_separator.rb
259
261
  - samples/hello/hello_spinbox.rb
260
262
  - samples/hello/hello_text.rb
263
+ - samples/hello/hello_theme.rb
261
264
  - samples/hello/hello_toplevel.rb
262
265
  - samples/hello/hello_world.rb
263
266
  - samples/hello/images/align-center.png