glimmer-dsl-tk 0.0.16 → 0.0.17

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: 86a726f184dac65952c4a78352e88df639707b156a3a95bf9a9e99728b78b3a1
4
- data.tar.gz: f6caaace87672c8f636d3f97f5b223b167e48f1f23620b82c0b19286cdfd6f35
3
+ metadata.gz: 21a6a1f1d2d85928c9bac3b9fd14ce7d8ca39f1ddec7ad82b8bafa733a0e4caa
4
+ data.tar.gz: 3d3acdb3c53c63d45a54188e956fedc8fa010dadaa3b3edb697f4b5f23a85126
5
5
  SHA512:
6
- metadata.gz: e64dc523caf04755e3380846ef1ac9b9abec8bfdb3cd8b1e251dd98ef4a70470e73e744310cf2e9ce943a0085ac9c730b655dc5945c29409d6e09cc6f1095dd4
7
- data.tar.gz: 23f99d7734e49d93f702c8987840e6ac043c247c83457be9f6cd1b028624aedb733e68b98c7922a2ec5a17afe05134da90664ab5dcf464350f31dc1afb45dd18
6
+ metadata.gz: 2c118bbcd96a99bbd4037e8df41595e7e514e16a0077d895e3b1808d62f7a62062f784b450fbdb299f2e48d59f60dce1e5de6ab08267a55123d4cffd100d494b
7
+ data.tar.gz: fe21b7c7cc00eb47c9313ea953b4fdce36b8a2bc2aa86de010fd8f68fde9c0487bb86b629263d0fc47ac2b64ce6fcdf2003879fd124607f4ea9c666800093660
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.17
4
+
5
+ - Support `label` `anchor` attribute (`'e'`, `'se'`, `'s'`, `'sw'`, `'w'`, `'nw'` or `'center'`)
6
+ - Support `label` `width` attributes
7
+ - Support `label` `image` attribute
8
+ - Support `label` `justify` attribute (`'left', 'center', 'right'`)
9
+ - Support `label` `font` attribute (`'default', 'text', 'fixed', 'menu', 'heading', 'caption', 'small_caption', 'icon', 'tooltip'`)
10
+ - Support `label` `foreground` attribute
11
+ - Support `label` `background` attribute (note that it does not work in Mac 'aqua' theme)
12
+ - Support `label` `compound` attribute
13
+ - Support `label` `relief` attributes (`'flat' (default), 'raised', 'sunken', 'solid', 'ridge', 'groove'`)
14
+
3
15
  ## 0.0.16
4
16
 
5
17
  - Support common themed widget state attributes: `active`, `disabled`, `focus`, `pressed`, `selected`, `background`, `readonly`, `alternate`, `invalid`, and `hover`
data/README.md CHANGED
@@ -1,6 +1,7 @@
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.16
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.17
2
2
  ## MRI Ruby 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
+ [![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)
4
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)
5
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/ce2853efdbecf6ebdc73/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-tk/maintainability)
6
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)
@@ -61,6 +62,52 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
61
62
  - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
62
63
  - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
63
64
 
65
+ ## Table of Contents
66
+
67
+ - [Glimmer DSL for Tk](#)
68
+ - [MRI Ruby Desktop Development GUI Library](#mri-ruby-desktop-development-gui-library)
69
+ - [Pre-requisites](#pre-requisites)
70
+ - [Setup](#setup)
71
+ - [Option 1: Install](#option-1-install)
72
+ - [Option 2: Bundler](#option-2-bundler)
73
+ - [Girb (Glimmer IRB)](#girb-glimmer-irb)
74
+ - [Tk Concepts](#tk-concepts)
75
+ - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
76
+ - [Supported Widgets](#supported-widgets)
77
+ - [Common Attributes](#common-attributes)
78
+ - [Common Themed Widget States](#common-themed-widget-states)
79
+ - [Smart Defaults and Convensions](#smart-defaults-and-convensions)
80
+ - [Grid Layout](#grid-layout)
81
+ - [Label/Button Image](#labelbutton-image)
82
+ - [Icon Photo](#icon-photo)
83
+ - [The Grid Geometry Manager](#the-grid-geometry-manager)
84
+ - [Bidirectional Data-Binding](#bidirectional-data-binding)
85
+ - [General Property Data-Binding](#general-property-data-binding)
86
+ - [Combobox Data-Binding](#combobox-data-binding)
87
+ - [List Single Selection Data-Binding](#list-single-selection-data-binding)
88
+ - [List Multi Selection Data-Binding](#list-multi-selection-data-binding)
89
+ - [Entry Data-Binding](#entry-data-binding)
90
+ - [Command Observer](#command-observer)
91
+ - [Samples](#samples)
92
+ - [Hello, World!](#hello-world)
93
+ - [Hello, Button!](#hello-button)
94
+ - [Hello, Tab!](#hello-tab)
95
+ - [Hello, Label!](#hello-label)
96
+ - [Hello, Message Box!](#hello-message-box)
97
+ - [Hello, Combobox!](#hello-combobox)
98
+ - [Hello, List Single Selection!](#hello-list-single-selection)
99
+ - [Hello, List Multi Selection!](#hello-list-multi-selection)
100
+ - [Hello, Computed!](#hello-computed)
101
+ - [Help](#help)
102
+ - [Issues](#issues)
103
+ - [Chat](#chat)
104
+ - [Process](#process)
105
+ - [Planned Features and Feature Suggestions](#planned-features-and-feature-suggestions)
106
+ - [Change Log](#change-log)
107
+ - [Contributing](#contributing)
108
+ - [Contributors](#contributors)
109
+ - [License](#license)
110
+
64
111
  ## Pre-requisites
65
112
 
66
113
  - [Tcl/Tk](https://www.tcl.tk/): Follow the [install instructions](https://tkdocs.com/tutorial/install.html)
@@ -87,7 +134,7 @@ gem install glimmer-dsl-tk
87
134
 
88
135
  Add the following to `Gemfile`:
89
136
  ```
90
- gem 'glimmer-dsl-tk', '~> 0.0.16'
137
+ gem 'glimmer-dsl-tk', '~> 0.0.17'
91
138
  ```
92
139
 
93
140
  And, then run:
@@ -179,8 +226,8 @@ keyword(args) | attributes | event bindings & callbacks
179
226
  ------------- | ---------- | ---------
180
227
  `button` | `text`, `image` (optional keyword args: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`), `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `default` (`'active', 'normal'`) | `command`
181
228
  `entry` | `width`, `text` | None
182
- `frame(text: )` | None | None
183
- `label` | `text` | None
229
+ `frame(text: nil)` | None | None
230
+ `label` | `text`, `image` (optional keyword args: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`), `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `font` (`'default', 'text', 'fixed', 'menu', 'heading', 'caption', 'small_caption', 'icon', 'tooltip'`), `relief` (`'flat' (default), 'raised', 'sunken', 'solid', 'ridge', 'groove'`), `justify` (`'left', 'center', 'right'`), `foreground`, `background` | None
184
231
  `list` | `selectmode`, `selection` | None
185
232
  `message_box(type: , message: , detail: , title: , icon: , default: , parent: )` | None | None
186
233
  `notebook` | None | None
@@ -209,6 +256,10 @@ keyword(args) | attributes | event bindings & callbacks
209
256
 
210
257
  `grid` layout is the default on most widgets (which support it).
211
258
 
259
+ #### Label/Button Image
260
+
261
+ Label and Button `image` attribute can accept image path directly as an alternative to `TkPhotoImage` object in addition to key values for automatic processing of image (`subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`)
262
+
212
263
  #### Icon Photo
213
264
 
214
265
  The `iconphoto` attribute on `root` is set to the Glimmer icon by default if no icon photo is supplied.
@@ -545,7 +596,7 @@ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_tab'"
545
596
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
546
597
 
547
598
  ```
548
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_tab'"
599
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_tab.rb
549
600
  ```
550
601
 
551
602
  Glimmer app:
@@ -553,6 +604,128 @@ Glimmer app:
553
604
  ![glimmer dsl tk screenshot sample hello tab English](images/glimmer-dsl-tk-screenshot-sample-hello-tab-english.png)
554
605
  ![glimmer dsl tk screenshot sample hello tab French](images/glimmer-dsl-tk-screenshot-sample-hello-tab-french.png)
555
606
 
607
+ ### Hello, Label!
608
+
609
+ Glimmer code (from [samples/hello/hello_label.rb](samples/hello/hello_label.rb)):
610
+
611
+ ```ruby
612
+ require 'glimmer-dsl-tk'
613
+
614
+ class HelloLabel
615
+ include Glimmer
616
+
617
+ LABEL_FONTS = ['default', 'text', 'fixed', 'menu', 'heading', 'caption', 'small_caption', 'icon', 'tooltip']
618
+ LABEL_RELIEFS = ['flat', 'raised', 'sunken', 'solid', 'ridge', 'groove']
619
+
620
+ def launch
621
+ root {
622
+ title 'Hello, Label!'
623
+
624
+ notebook {
625
+ frame(text: 'left-aligned') {
626
+ 3.times do |n|
627
+ label {
628
+ text "Field #{n + 1} / default font / flat relief"
629
+ width 60
630
+ anchor 'w'
631
+ }
632
+ end
633
+ }
634
+
635
+ frame(text: 'centered') {
636
+ 9.times do |n|
637
+ label {
638
+ text "Field #{n + 1} / fixed font / raised relief"
639
+ width 80
640
+ anchor 'center'
641
+ font 'fixed'
642
+ relief 'raised'
643
+ }
644
+ end
645
+ }
646
+
647
+ frame(text: 'right-aligned') {
648
+ 9.times do |n|
649
+ label {
650
+ text "Field #{n + 1} / small_caption font / ridge relief"
651
+ width 80
652
+ anchor 'e'
653
+ font 'small_caption'
654
+ relief 'ridge'
655
+ }
656
+ end
657
+ }
658
+
659
+ frame(text: 'justified') {
660
+ label {
661
+ text <<~MULTI_LINE_STRING
662
+ This is a very long paragraph that spans multiple lines. It looks better and
663
+ is easier to read when justified. In fact, this is how to make it look like a
664
+ new paper column. That results in professional looking text. Magazines use the
665
+ same sort of justified text. Word processors also support justified text. In
666
+ fact, this is how text is made for news papers and magainzes, and then published
667
+ in paper form and digitally.
668
+ MULTI_LINE_STRING
669
+ width 60
670
+ anchor 'center'
671
+ justify 'center' # other options are: 'left' and 'right'
672
+ font 'caption' # other options are: 'default', 'text', 'fixed', 'menu', 'heading', 'small_caption', 'icon', 'tooltip'
673
+ foreground 'blue'
674
+ relief 'sunken' # other options are: 'flat' (default), 'raised', 'solid', 'ridge', 'groove'
675
+ }
676
+ }
677
+
678
+ frame(text: 'images') {
679
+ ['denmark', 'finland', 'norway'].each do |image_name|
680
+ label {
681
+ image File.expand_path("images/#{image_name}.png", __dir__)
682
+ }
683
+ end
684
+ }
685
+
686
+ frame(text: 'background images') {
687
+ ['italy', 'france', 'mexico'].each do |image_name|
688
+ label {
689
+ text image_name.capitalize
690
+ image File.expand_path("images/#{image_name}.png", __dir__)
691
+ compound 'center'
692
+ }
693
+ end
694
+ }
695
+ }
696
+ }.open
697
+ end
698
+ end
699
+
700
+ HelloLabel.new.launch
701
+ ```
702
+
703
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
704
+
705
+ ```
706
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_label'"
707
+ ```
708
+
709
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
710
+
711
+ ```
712
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_label.rb
713
+ ```
714
+
715
+ Glimmer app:
716
+
717
+ ![glimmer dsl tk screenshot sample hello label left aligned](images/glimmer-dsl-tk-screenshot-sample-hello-label-left-aligned.png)
718
+
719
+ ![glimmer dsl tk screenshot sample hello label centered](images/glimmer-dsl-tk-screenshot-sample-hello-label-centered.png)
720
+
721
+ ![glimmer dsl tk screenshot sample hello label right aligned](images/glimmer-dsl-tk-screenshot-sample-hello-label-right-aligned.png)
722
+
723
+ ![glimmer dsl tk screenshot sample hello label justified](images/glimmer-dsl-tk-screenshot-sample-hello-label-justified.png)
724
+
725
+ ![glimmer dsl tk screenshot sample hello label images](images/glimmer-dsl-tk-screenshot-sample-hello-label-images.png)
726
+
727
+ ![glimmer dsl tk screenshot sample hello label background images](images/glimmer-dsl-tk-screenshot-sample-hello-label-background-images.png)
728
+
556
729
  ### Hello, Message Box!
557
730
 
558
731
  Glimmer code (from [samples/hello/hello_message_box.rb](samples/hello/hello_message_box.rb)):
@@ -632,13 +805,13 @@ root { |r|
632
805
  Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
633
806
 
634
807
  ```
635
- ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_tab'"
808
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_message_box'"
636
809
  ```
637
810
 
638
811
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
639
812
 
640
813
  ```
641
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_tab'"
814
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_message_box.rb
642
815
  ```
643
816
 
644
817
  Glimmer app:
@@ -679,7 +852,7 @@ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_combobox'"
679
852
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
680
853
 
681
854
  ```
682
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_combobox'"
855
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_combobox.rb
683
856
  ```
684
857
 
685
858
  Glimmer app:
@@ -719,7 +892,7 @@ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_list_single_selection'"
719
892
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
720
893
 
721
894
  ```
722
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_list_single_selection'"
895
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_list_single_selection.rb
723
896
  ```
724
897
 
725
898
  Glimmer app:
@@ -757,7 +930,7 @@ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_list_multi_selection'"
757
930
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
758
931
 
759
932
  ```
760
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_list_multi_selection'"
933
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_list_multi_selection.rb
761
934
  ```
762
935
 
763
936
  Glimmer app:
@@ -837,7 +1010,7 @@ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_computed'"
837
1010
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
838
1011
 
839
1012
  ```
840
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_computed'"
1013
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_computed.rb
841
1014
  ```
842
1015
 
843
1016
  Glimmer app:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.16
1
+ 0.0.17
Binary file
@@ -27,14 +27,14 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class LabelProxy < WidgetProxy
30
- # TODO specify attribute setters
31
- # def tk_widget_has_attribute_setter?(attribute)
32
- # if ['anchor', 'justify'].include?(attribute.to_s)
33
- # true
34
- # else
35
- # super
36
- # end
37
- # end
30
+ def set_attribute(attribute, *args)
31
+ if attribute.to_s == 'font'
32
+ args[0] = "tk_#{args[0]}_font".camelcase(:upper) if (args[0].is_a?(Symbol) || args[0].is_a?(String)) && args[0].to_s == args[0].to_s.downcase
33
+ super
34
+ else
35
+ super
36
+ end
37
+ end
38
38
  end
39
39
  end
40
40
  end
@@ -117,7 +117,13 @@ module Glimmer
117
117
  end
118
118
 
119
119
  def tk_widget_has_attribute_getter_setter?(attribute)
120
- @tk.respond_to?(attribute)
120
+ begin
121
+ # TK Widget currently doesn't support respond_to? properly, so I have to resort to this trick for now
122
+ @tk.send(attribute)
123
+ true
124
+ rescue
125
+ false
126
+ end
121
127
  end
122
128
 
123
129
  def has_state?(attribute)
@@ -135,10 +141,10 @@ module Glimmer
135
141
  end
136
142
 
137
143
  def has_attribute?(attribute, *args)
138
- (widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][attribute.to_s]) ||
139
- tk_widget_has_attribute_setter?(attribute) ||
140
- tk_widget_has_attribute_getter_setter?(attribute) ||
141
- has_state?(attribute) ||
144
+ (widget_custom_attribute_mapping[tk.class] and widget_custom_attribute_mapping[tk.class][attribute.to_s]) or
145
+ tk_widget_has_attribute_setter?(attribute) or
146
+ tk_widget_has_attribute_getter_setter?(attribute) or
147
+ has_state?(attribute) or
142
148
  respond_to?(attribute_setter(attribute), args)
143
149
  end
144
150
 
@@ -183,8 +189,8 @@ module Glimmer
183
189
  @widget_custom_attribute_mapping ||= {
184
190
  ::Tk::Tile::TButton => {
185
191
  'image' => {
186
- getter: {name: 'image', invoker: lambda { |widget, args| @tk.textvariable&.value }},
187
- setter: {name: 'image=', invoker: lambda { |widget, args| @tk['image'] = image_argument(args) }},
192
+ getter: {name: 'image', invoker: lambda { |widget, args| @tk.image }},
193
+ setter: {name: 'image=', invoker: lambda { |widget, args| @tk.image = image_argument(args) }},
188
194
  },
189
195
  },
190
196
  ::Tk::Tile::TCombobox => {
@@ -198,6 +204,10 @@ module Glimmer
198
204
  getter: {name: 'text', invoker: lambda { |widget, args| @tk.textvariable&.value }},
199
205
  setter: {name: 'text=', invoker: lambda { |widget, args| @tk.textvariable&.value = args.first }},
200
206
  },
207
+ 'image' => {
208
+ getter: {name: 'image', invoker: lambda { |widget, args| @tk.image }},
209
+ setter: {name: 'image=', invoker: lambda { |widget, args| @tk.image = image_argument(args) }},
210
+ },
201
211
  },
202
212
  ::Tk::Tile::TEntry => {
203
213
  'text' => {
@@ -0,0 +1,110 @@
1
+ # Copyright (c) 2020-2021 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 HelloLabel
25
+ include Glimmer
26
+
27
+ LABEL_FONTS = ['default', 'text', 'fixed', 'menu', 'heading', 'caption', 'small_caption', 'icon', 'tooltip']
28
+ LABEL_RELIEFS = ['flat', 'raised', 'sunken', 'solid', 'ridge', 'groove']
29
+
30
+ def launch
31
+ root {
32
+ title 'Hello, Label!'
33
+
34
+ notebook {
35
+ frame(text: 'left-aligned') {
36
+ 3.times do |n|
37
+ label {
38
+ text "Field #{n + 1} / default font / flat relief"
39
+ width 60
40
+ anchor 'w'
41
+ }
42
+ end
43
+ }
44
+
45
+ frame(text: 'centered') {
46
+ 9.times do |n|
47
+ label {
48
+ text "Field #{n + 1} / fixed font / raised relief"
49
+ width 80
50
+ anchor 'center'
51
+ font 'fixed'
52
+ relief 'raised'
53
+ }
54
+ end
55
+ }
56
+
57
+ frame(text: 'right-aligned') {
58
+ 9.times do |n|
59
+ label {
60
+ text "Field #{n + 1} / small_caption font / ridge relief"
61
+ width 80
62
+ anchor 'e'
63
+ font 'small_caption'
64
+ relief 'ridge'
65
+ }
66
+ end
67
+ }
68
+
69
+ frame(text: 'justified') {
70
+ label {
71
+ text <<~MULTI_LINE_STRING
72
+ This is a very long paragraph that spans multiple lines. It looks better and
73
+ is easier to read when justified. In fact, this is how to make it look like a
74
+ new paper column. That results in professional looking text. Magazines use the
75
+ same sort of justified text. Word processors also support justified text. In
76
+ fact, this is how text is made for news papers and magainzes, and then published
77
+ in paper form and digitally.
78
+ MULTI_LINE_STRING
79
+ width 60
80
+ anchor 'center'
81
+ justify 'center' # other options are: 'left' and 'right'
82
+ font 'caption' # other options are: 'default', 'text', 'fixed', 'menu', 'heading', 'small_caption', 'icon', 'tooltip'
83
+ foreground 'blue'
84
+ relief 'sunken' # other options are: 'flat' (default), 'raised', 'solid', 'ridge', 'groove'
85
+ }
86
+ }
87
+
88
+ frame(text: 'images') {
89
+ ['denmark', 'finland', 'norway'].each do |image_name|
90
+ label {
91
+ image File.expand_path("images/#{image_name}.png", __dir__)
92
+ }
93
+ end
94
+ }
95
+
96
+ frame(text: 'background images') {
97
+ ['italy', 'france', 'mexico'].each do |image_name|
98
+ label {
99
+ text image_name.capitalize
100
+ image File.expand_path("images/#{image_name}.png", __dir__)
101
+ compound 'center'
102
+ }
103
+ end
104
+ }
105
+ }
106
+ }.open
107
+ end
108
+ end
109
+
110
+ HelloLabel.new.launch
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
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.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-10 00:00:00.000000000 Z
11
+ date: 2021-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -214,11 +214,21 @@ files:
214
214
  - samples/hello/hello_combobox.rb
215
215
  - samples/hello/hello_computed.rb
216
216
  - samples/hello/hello_computed/contact.rb
217
+ - samples/hello/hello_label.rb
217
218
  - samples/hello/hello_list_multi_selection.rb
218
219
  - samples/hello/hello_list_single_selection.rb
219
220
  - samples/hello/hello_message_box.rb
220
221
  - samples/hello/hello_tab.rb
221
222
  - samples/hello/hello_world.rb
223
+ - samples/hello/images/denmark.png
224
+ - samples/hello/images/finland.png
225
+ - samples/hello/images/france.png
226
+ - samples/hello/images/germany.png
227
+ - samples/hello/images/italy.png
228
+ - samples/hello/images/mexico.png
229
+ - samples/hello/images/netherlands.png
230
+ - samples/hello/images/norway.png
231
+ - samples/hello/images/usa.png
222
232
  homepage: http://github.com/AndyObtiva/glimmer-dsl-tk
223
233
  licenses:
224
234
  - MIT