glimmer-dsl-tk 0.0.53 → 0.0.56

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: 4bc998830956c028c331da19e9238e69fe15198a0c2741af217cd15cae8fceb8
4
- data.tar.gz: '040971d080dae49ebcb201631802566bcb415ddcd72ca623d6cca350c4587058'
3
+ metadata.gz: 951b8e62423c7092e9d3d34c25ea583cab0e5195b84f2553a47f36bcce2703c3
4
+ data.tar.gz: 35017367771d0668aa955d0edc9776fb5d5072ffdd1b63519f920d1edc73b70f
5
5
  SHA512:
6
- metadata.gz: a573287857c8f89fb58226dc6c8f1c1629f5a7f7c2dac59952e3459738ba582b89539cc1365a8ebe0134d0c132e62757677fb438480a20b93f25c346846b20f8
7
- data.tar.gz: 404e13705e7354d5e0bb2ae15993c7b17d09e77cb7161e111ab5dc908bbe18523501dffc041ff7ce69a71fb70db8d1cca8ef306fbab26f9d07faa2e5933eca53
6
+ metadata.gz: 78bd1d1296b43903d306daa043cbaa21f4b898703c43021387c32ed4e96019ebcff3690ac2a6e70e810ea7ccc70181df3ccefb5412e9fcebaecd9c762f14c511
7
+ data.tar.gz: 3aa1e66860f386a919a63c141023d20baba0e7aaff885560d9433a817baa9e930eed812242f2a203775254eabbb4f50fb29ab905f40223a0697c7600c58c9e02
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.56
4
+
5
+ - Hello, Progressbar! sample
6
+ - Upgrade to glimmer 2.7.3
7
+
8
+ ## 0.0.55
9
+
10
+ - Hello, Scale! sample
11
+ - `scale` `variable` data-binding
12
+
13
+ ## 0.0.54
14
+
15
+ - Hello, Labelframe! sample
16
+ - Add default padding to `labelframe`
17
+
3
18
  ## 0.0.53
4
19
 
5
20
  - Support menu item accelerators that include or end with function keys (e.g. `'Alt+F4'`)
data/README.md CHANGED
@@ -1,13 +1,11 @@
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.53
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.56
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)
6
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/ce2853efdbecf6ebdc73/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-tk/maintainability)
7
7
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
8
 
9
- **[Contributors Wanted! (Submit a Glimmer App Sample to Get Started)](CONTRIBUTING.md)**
10
-
11
9
  [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).
12
10
 
13
11
  [Tcl/Tk](https://www.tcl.tk/) has recently improved by 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.). 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).
@@ -53,13 +51,19 @@ Glimmer app:
53
51
 
54
52
  NOTE: Glimmer DSL for Tk is currently in early alpha mode (only about 44% complete). If you want it developed faster, then [open an issue report](https://github.com/AndyObtiva/glimmer-dsl-tk/issues/new). I have completed some features much faster before due to [issue reports](https://github.com/AndyObtiva/glimmer-dsl-tk/issues) and [pull requests](https://github.com/AndyObtiva/glimmer-dsl-tk/pulls). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
55
53
 
56
- Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems you might be interested in:
57
- - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
58
- - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
59
- - [glimmer-dsl-libui](https://github.com/AndyObtiva/glimmer-dsl-libui): Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)
60
- - [glimmer-dsl-gtk](https://github.com/AndyObtiva/glimmer-dsl-gtk): Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library)
61
- - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
62
- - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
54
+ **[Glimmer](https://rubygems.org/gems/glimmer) DSL Comparison Table:**
55
+ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
56
+ ----|-----------|---------|------------------|------|------|--------
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
+ [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
+ [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 (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
+ [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
+ [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
+ [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
64
+ [Glimmer DSL for Swing (JRuby Swing Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-swing) | Mac / Windows / Linux | No | Yes (Java2D) | Very Mature | Slow JRuby Startup Time / Heavy Memory Footprint / Widgets Do Not Look Native | Java / JRuby
65
+ [Glimmer DSL for XML (& HTML)](https://github.com/AndyObtiva/glimmer-dsl-xml) | All Web Browsers | No | Yes (SVG) | Programmable / Lighter-weight Than Actual XML | XML Elements Are Sometimes Not Well-Named (Many Types of Input) | None
66
+ [Glimmer DSL for CSS](https://github.com/AndyObtiva/glimmer-dsl-css) | All Web Browsers | No | Yes | Programmable | CSS Is Over-Engineered / Too Many Features To Learn | None
63
67
 
64
68
  ## Table of Contents
65
69
 
@@ -96,6 +100,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems you might be int
96
100
  - [List Multi Selection Data-Binding](#list-multi-selection-data-binding)
97
101
  - [Entry Data-Binding](#entry-data-binding)
98
102
  - [Text Data-Binding](#text-data-binding)
103
+ - [Scale Data-Binding](#scale-data-binding)
99
104
  - [Spinbox Data-Binding](#spinbox-data-binding)
100
105
  - [Checkbutton Data-Binding](#checkbutton-data-binding)
101
106
  - [Radiobutton Data-Binding](#radiobutton-data-binding)
@@ -127,6 +132,9 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems you might be int
127
132
  - [Hello, Scrollbar Frame!](#hello-scrollbar-frame)
128
133
  - [Hello, Menu Bar!](#hello-menu-bar)
129
134
  - [Hello, Contextual Menu!](#hello-contextual-menu)
135
+ - [Hello, Labelframe!](#hello-labelframe)
136
+ - [Hello, Scale!](#hello-scale)
137
+ - [Hello, Progressbar!](#hello-progressbar)
130
138
  - [Applications](#applications)
131
139
  - [Glimmer Tk Calculator](#glimmer-tk-calculator)
132
140
  - [Y3network Ruby UI](#y3network-ruby-ui)
@@ -186,7 +194,7 @@ gem install glimmer-dsl-tk
186
194
 
187
195
  Add the following to `Gemfile`:
188
196
  ```
189
- gem 'glimmer-dsl-tk', '0.0.53'
197
+ gem 'glimmer-dsl-tk', '0.0.56'
190
198
  ```
191
199
 
192
200
  And, then run:
@@ -763,6 +771,50 @@ It automatically handles all the Tk plumbing behind the scenes.
763
771
 
764
772
  More details can be found in [Hello, Text!](#hello-text) sample below.
765
773
 
774
+ ### Scale Data-Binding
775
+
776
+ Example:
777
+
778
+ This assumes a `Person` model with an `age` attribute.
779
+
780
+ ```ruby
781
+ spinbox {
782
+ orient 'horizontal' # can be 'vertical' too
783
+ length 200
784
+ from 0.0
785
+ to 100.0
786
+ variable <=> [person, :age, on_write: ->(val) {val.to_i}]
787
+ }
788
+ ```
789
+
790
+ That code binds the `variable` value of the `scale` to the `age` attribute on the `person` model.
791
+
792
+ It automatically handles all the Tk plumbing behind the scenes.
793
+
794
+ More details can be found in [Hello, Scale!](#hello-scale) sample below.
795
+
796
+ ### Progressbar Data-Binding
797
+
798
+ Example:
799
+
800
+ This assumes a `Worker` model with a `progress_value` attribute.
801
+
802
+ ```ruby
803
+ progressbar {
804
+ orient 'horizontal' # can be vertical too
805
+ length 200
806
+ mode 'determinate'
807
+ maximum 100
808
+ value <= [worker, :progress_value]
809
+ }
810
+ ```
811
+
812
+ That code binds the value of the `progressbar` to the `progress_value` attribute on the `worker` model.
813
+
814
+ It automatically handles all the Tk plumbing behind the scenes.
815
+
816
+ More details can be found in [Hello, Progressbar!](#hello-progressbar) sample below.
817
+
766
818
  ### Spinbox Data-Binding
767
819
 
768
820
  Example:
@@ -3726,6 +3778,346 @@ Glimmer app:
3726
3778
 
3727
3779
  ![glimmer dsl tk screenshot sample hello contextual-menu](images/glimmer-dsl-tk-screenshot-sample-hello-contextual-menu.png)
3728
3780
 
3781
+ ### Hello, Labelframe!
3782
+
3783
+ Glimmer code (from [samples/hello/hello_labelframe.rb](samples/hello/hello_labelframe.rb)):
3784
+
3785
+ ```ruby
3786
+ require 'glimmer-dsl-tk'
3787
+
3788
+ include Glimmer
3789
+
3790
+ root {
3791
+ title 'Hello, Labelframe!'
3792
+
3793
+ labelframe {
3794
+ grid column: 0, row: 0, padx: 10, pady: 10
3795
+ text 'Name:'
3796
+ # labelanchor 'nw' # Default. Other options: 'n', 'ne', 'en', 'e', 'es', 'se', 's', 'sw', 'ws', 'w', 'wn'
3797
+
3798
+ label {
3799
+ grid column: 0, row: 0, sticky: 'w'
3800
+ text 'First Name:'
3801
+ }
3802
+ entry {
3803
+ grid column: 1, row: 0
3804
+ width 15
3805
+ }
3806
+
3807
+ label {
3808
+ grid column: 0, row: 1, sticky: 'w'
3809
+ text 'Last Name:'
3810
+ }
3811
+ entry {
3812
+ grid column: 1, row: 1
3813
+ width 15
3814
+ }
3815
+ }
3816
+
3817
+ labelframe {
3818
+ grid column: 0, row: 1, padx: 10, pady: 10
3819
+ text 'Address:'
3820
+
3821
+ label {
3822
+ grid column: 0, row: 0, sticky: 'w'
3823
+ text 'Street:'
3824
+ }
3825
+ entry {
3826
+ grid column: 1, row: 0
3827
+ width 15
3828
+ }
3829
+
3830
+ label {
3831
+ grid column: 0, row: 1, sticky: 'w'
3832
+ text 'City:'
3833
+ }
3834
+ entry {
3835
+ grid column: 1, row: 1
3836
+ width 15
3837
+ }
3838
+
3839
+ label {
3840
+ grid column: 0, row: 2, sticky: 'w'
3841
+ text 'State:'
3842
+ }
3843
+ entry {
3844
+ grid column: 1, row: 2
3845
+ width 15
3846
+ }
3847
+
3848
+ label {
3849
+ grid column: 0, row: 3, sticky: 'w'
3850
+ text 'Zip:'
3851
+ }
3852
+ entry {
3853
+ grid column: 1, row: 3
3854
+ width 15
3855
+ }
3856
+ }
3857
+
3858
+ labelframe {
3859
+ grid column: 1, row: 0, rowspan: 2, padx: 10, pady: 10
3860
+ text 'Medical Info:'
3861
+
3862
+ label {
3863
+ grid column: 0, row: 0, sticky: 'w'
3864
+ text 'Family Doctor:'
3865
+ }
3866
+ entry {
3867
+ grid column: 1, row: 0
3868
+ width 15
3869
+ }
3870
+
3871
+ label {
3872
+ grid column: 0, row: 1, sticky: 'w'
3873
+ text 'Chronic Conditions:'
3874
+ }
3875
+ entry {
3876
+ grid column: 1, row: 1
3877
+ width 15
3878
+ }
3879
+
3880
+ label {
3881
+ grid column: 0, row: 2, sticky: 'w'
3882
+ text 'Past Surgeries:'
3883
+ }
3884
+ entry {
3885
+ grid column: 1, row: 2
3886
+ width 15
3887
+ }
3888
+
3889
+ label {
3890
+ grid column: 0, row: 3, sticky: 'w'
3891
+ text 'Health Insurance Info:'
3892
+ }
3893
+ entry {
3894
+ grid column: 1, row: 3
3895
+ width 15
3896
+ }
3897
+
3898
+ label {
3899
+ grid column: 0, row: 4, sticky: 'w'
3900
+ text 'Dental Insurance Info:'
3901
+ }
3902
+ entry {
3903
+ grid column: 1, row: 4
3904
+ width 15
3905
+ }
3906
+
3907
+ label {
3908
+ grid column: 0, row: 5, sticky: 'w'
3909
+ text 'Diet:'
3910
+ }
3911
+ entry {
3912
+ grid column: 1, row: 5
3913
+ width 15
3914
+ }
3915
+
3916
+ label {
3917
+ grid column: 0, row: 6, sticky: 'w'
3918
+ text 'Exercise:'
3919
+ }
3920
+ entry {
3921
+ grid column: 1, row: 6
3922
+ width 15
3923
+ }
3924
+ }
3925
+ }.open
3926
+ ```
3927
+
3928
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
3929
+
3930
+ ```
3931
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_labelframe'"
3932
+ ```
3933
+
3934
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
3935
+
3936
+ ```
3937
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_labelframe.rb
3938
+ ```
3939
+
3940
+ Glimmer app:
3941
+
3942
+ ![glimmer dsl tk screenshot sample hello label-frame](images/glimmer-dsl-tk-screenshot-sample-hello-labelframe.png)
3943
+
3944
+ ### Hello, Scale!
3945
+
3946
+ Glimmer code (from [samples/hello/hello_scale.rb](samples/hello/hello_scale.rb)):
3947
+
3948
+ ```ruby
3949
+ require 'glimmer-dsl-tk'
3950
+
3951
+ class HelloScale
3952
+ include Glimmer
3953
+
3954
+ attr_accessor :scale_value
3955
+
3956
+ def initialize
3957
+ self.scale_value = 50
3958
+ end
3959
+
3960
+ def launch
3961
+ root {
3962
+ text 'Hello, Scale!'
3963
+
3964
+ label {
3965
+ anchor 'center'
3966
+ text <= [self, :scale_value]
3967
+ }
3968
+
3969
+ scale {
3970
+ orient 'horizontal'
3971
+ length 200
3972
+ from 0.0
3973
+ to 100.0
3974
+ variable <=> [self, :scale_value, on_write: ->(val) {val.to_i}]
3975
+ }
3976
+ }.open
3977
+ end
3978
+ end
3979
+
3980
+ HelloScale.new.launch
3981
+ ```
3982
+
3983
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
3984
+
3985
+ ```
3986
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_scale'"
3987
+ ```
3988
+
3989
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
3990
+
3991
+ ```
3992
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_scale.rb
3993
+ ```
3994
+
3995
+ Glimmer app:
3996
+
3997
+ ![glimmer dsl tk screenshot sample hello scale](images/glimmer-dsl-tk-screenshot-sample-hello-scale.png)
3998
+
3999
+ ### Hello, Progressbar!
4000
+
4001
+ Glimmer code (from [samples/hello/hello_progressbar.rb](samples/hello/hello_progressbar.rb)):
4002
+
4003
+ ```ruby
4004
+ require 'glimmer-dsl-tk'
4005
+
4006
+ class HelloProgressbar
4007
+ include Glimmer
4008
+
4009
+ attr_accessor :progress_value, :maximum_value, :delay_value
4010
+
4011
+ def initialize
4012
+ self.progress_value = 0
4013
+ self.maximum_value = 100
4014
+ self.delay_value = 0.01
4015
+
4016
+ Thread.new do
4017
+ loop do
4018
+ self.progress_value = (self.progress_value.to_i + 1) % (maximum_value.to_i + 1)
4019
+ sleep(delay_value) # yields to main thread
4020
+ end
4021
+ end
4022
+ end
4023
+
4024
+ def launch
4025
+ root {
4026
+ text 'Hello, Progressbar!'
4027
+
4028
+ progressbar {
4029
+ grid row: 0, column: 0, columnspan: 3
4030
+ orient 'horizontal'
4031
+ length 200
4032
+ mode 'indeterminate'
4033
+ maximum <= [self, :maximum_value]
4034
+ value <= [self, :progress_value]
4035
+ }
4036
+
4037
+ label {
4038
+ grid row: 1, column: 0
4039
+ text 'Value'
4040
+ }
4041
+
4042
+ label {
4043
+ grid row: 1, column: 1
4044
+ text 'Maximum'
4045
+ }
4046
+
4047
+ label {
4048
+ grid row: 1, column: 2
4049
+ text 'Delay in Seconds'
4050
+ }
4051
+
4052
+ spinbox {
4053
+ grid row: 2, column: 0
4054
+ from 0.0
4055
+ to 100.0
4056
+ increment 1.0
4057
+ format '%0f'
4058
+ text <=> [self, :progress_value, on_read: :to_i, on_write: :to_i]
4059
+ }
4060
+
4061
+ spinbox {
4062
+ grid row: 2, column: 1
4063
+ from 1.0
4064
+ to 100.0
4065
+ increment 1.0
4066
+ format '%0f'
4067
+ text <=> [self, :maximum_value, on_read: :to_i, on_write: :to_i]
4068
+ }
4069
+
4070
+ spinbox {
4071
+ grid row: 2, column: 2
4072
+ from 0.01
4073
+ to 1.0
4074
+ increment 0.1
4075
+ format '%0.2f'
4076
+ text <=> [self, :delay_value, on_write: ->(val) {[val.to_f, 1.0].min}]
4077
+ }
4078
+
4079
+ progressbar {
4080
+ grid row: 3, column: 0, columnspan: 3
4081
+ orient 'horizontal'
4082
+ length 200
4083
+ mode 'determinate'
4084
+ maximum <= [self, :maximum_value]
4085
+ value <= [self, :progress_value]
4086
+ }
4087
+
4088
+ progressbar {
4089
+ grid row: 4, column: 0, columnspan: 3
4090
+ orient 'vertical'
4091
+ length 200
4092
+ mode 'determinate'
4093
+ maximum <= [self, :maximum_value]
4094
+ value <= [self, :progress_value]
4095
+ }
4096
+ }.open
4097
+ end
4098
+ end
4099
+
4100
+ HelloProgressbar.new.launch
4101
+ ```
4102
+
4103
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
4104
+
4105
+ ```
4106
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_progressbar'"
4107
+ ```
4108
+
4109
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
4110
+
4111
+ ```
4112
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_progressbar.rb
4113
+ ```
4114
+
4115
+ Glimmer app:
4116
+
4117
+ ![glimmer dsl tk screenshot sample hello progressbar](images/glimmer-dsl-tk-screenshot-sample-hello-progressbar.png)
4118
+
4119
+ ![glimmer dsl tk screenshot sample hello progressbar gif](images/glimmer-dsl-tk-screenshot-sample-hello-progressbar.gif)
4120
+
3729
4121
  ## Applications
3730
4122
 
3731
4123
  ### Glimmer Tk Calculator
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.53
1
+ 0.0.56
Binary file
@@ -0,0 +1,39 @@
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/notebook_proxy'
24
+
25
+ module Glimmer
26
+ module Tk
27
+ # Proxy for Tk::Tile::Labelframe
28
+ #
29
+ # Follows the Proxy Design Pattern
30
+ class LabelframeProxy < WidgetProxy
31
+ private
32
+
33
+ def initialize_defaults
34
+ super
35
+ self.padding = 15
36
+ end
37
+ end
38
+ end
39
+ end
@@ -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,161 @@
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
+ include Glimmer
25
+
26
+ root {
27
+ title 'Hello, Labelframe!'
28
+
29
+ labelframe {
30
+ grid column: 0, row: 0, padx: 10, pady: 10
31
+ text 'Name:'
32
+ # labelanchor 'nw' # Default. Other options: 'n', 'ne', 'en', 'e', 'es', 'se', 's', 'sw', 'ws', 'w', 'wn'
33
+
34
+ label {
35
+ grid column: 0, row: 0, sticky: 'w'
36
+ text 'First Name:'
37
+ }
38
+ entry {
39
+ grid column: 1, row: 0
40
+ width 15
41
+ }
42
+
43
+ label {
44
+ grid column: 0, row: 1, sticky: 'w'
45
+ text 'Last Name:'
46
+ }
47
+ entry {
48
+ grid column: 1, row: 1
49
+ width 15
50
+ }
51
+ }
52
+
53
+ labelframe {
54
+ grid column: 0, row: 1, padx: 10, pady: 10
55
+ text 'Address:'
56
+
57
+ label {
58
+ grid column: 0, row: 0, sticky: 'w'
59
+ text 'Street:'
60
+ }
61
+ entry {
62
+ grid column: 1, row: 0
63
+ width 15
64
+ }
65
+
66
+ label {
67
+ grid column: 0, row: 1, sticky: 'w'
68
+ text 'City:'
69
+ }
70
+ entry {
71
+ grid column: 1, row: 1
72
+ width 15
73
+ }
74
+
75
+ label {
76
+ grid column: 0, row: 2, sticky: 'w'
77
+ text 'State:'
78
+ }
79
+ entry {
80
+ grid column: 1, row: 2
81
+ width 15
82
+ }
83
+
84
+ label {
85
+ grid column: 0, row: 3, sticky: 'w'
86
+ text 'Zip:'
87
+ }
88
+ entry {
89
+ grid column: 1, row: 3
90
+ width 15
91
+ }
92
+ }
93
+
94
+ labelframe {
95
+ grid column: 1, row: 0, rowspan: 2, padx: 10, pady: 10
96
+ text 'Medical Info:'
97
+
98
+ label {
99
+ grid column: 0, row: 0, sticky: 'w'
100
+ text 'Family Doctor:'
101
+ }
102
+ entry {
103
+ grid column: 1, row: 0
104
+ width 15
105
+ }
106
+
107
+ label {
108
+ grid column: 0, row: 1, sticky: 'w'
109
+ text 'Chronic Conditions:'
110
+ }
111
+ entry {
112
+ grid column: 1, row: 1
113
+ width 15
114
+ }
115
+
116
+ label {
117
+ grid column: 0, row: 2, sticky: 'w'
118
+ text 'Past Surgeries:'
119
+ }
120
+ entry {
121
+ grid column: 1, row: 2
122
+ width 15
123
+ }
124
+
125
+ label {
126
+ grid column: 0, row: 3, sticky: 'w'
127
+ text 'Health Insurance Info:'
128
+ }
129
+ entry {
130
+ grid column: 1, row: 3
131
+ width 15
132
+ }
133
+
134
+ label {
135
+ grid column: 0, row: 4, sticky: 'w'
136
+ text 'Dental Insurance Info:'
137
+ }
138
+ entry {
139
+ grid column: 1, row: 4
140
+ width 15
141
+ }
142
+
143
+ label {
144
+ grid column: 0, row: 5, sticky: 'w'
145
+ text 'Diet:'
146
+ }
147
+ entry {
148
+ grid column: 1, row: 5
149
+ width 15
150
+ }
151
+
152
+ label {
153
+ grid column: 0, row: 6, sticky: 'w'
154
+ text 'Exercise:'
155
+ }
156
+ entry {
157
+ grid column: 1, row: 6
158
+ width 15
159
+ }
160
+ }
161
+ }.open
@@ -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
@@ -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: :to_i]
48
+ }
49
+ }.open
50
+ end
51
+ end
52
+
53
+ HelloScale.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.53
4
+ version: 0.0.56
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-22 00:00:00.000000000 Z
11
+ date: 2022-03-26 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
@@ -213,6 +213,7 @@ files:
213
213
  - lib/glimmer/tk/entry_proxy.rb
214
214
  - lib/glimmer/tk/frame_proxy.rb
215
215
  - lib/glimmer/tk/label_proxy.rb
216
+ - lib/glimmer/tk/labelframe_proxy.rb
216
217
  - lib/glimmer/tk/lbl_proxy.rb
217
218
  - lib/glimmer/tk/list_proxy.rb
218
219
  - lib/glimmer/tk/menu_item_proxy.rb
@@ -221,6 +222,7 @@ files:
221
222
  - lib/glimmer/tk/os.rb
222
223
  - lib/glimmer/tk/radiobutton_proxy.rb
223
224
  - lib/glimmer/tk/root_proxy.rb
225
+ - lib/glimmer/tk/scale_proxy.rb
224
226
  - lib/glimmer/tk/scrollbar_frame_proxy.rb
225
227
  - lib/glimmer/tk/spinbox_proxy.rb
226
228
  - lib/glimmer/tk/text_proxy.rb
@@ -242,13 +244,16 @@ files:
242
244
  - samples/hello/hello_entry.rb
243
245
  - samples/hello/hello_frame.rb
244
246
  - samples/hello/hello_label.rb
247
+ - samples/hello/hello_labelframe.rb
245
248
  - samples/hello/hello_list_multi_selection.rb
246
249
  - samples/hello/hello_list_single_selection.rb
247
250
  - samples/hello/hello_menu_bar.rb
248
251
  - samples/hello/hello_message_box.rb
249
252
  - samples/hello/hello_notebook.rb
253
+ - samples/hello/hello_progressbar.rb
250
254
  - samples/hello/hello_radiobutton.rb
251
255
  - samples/hello/hello_root.rb
256
+ - samples/hello/hello_scale.rb
252
257
  - samples/hello/hello_scrollbar.rb
253
258
  - samples/hello/hello_scrollbar_frame.rb
254
259
  - samples/hello/hello_separator.rb