glimmer-dsl-tk 0.0.15 → 0.0.20

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: 12e68b40c6fb5c056f778d8864b88a01adb69ee4c0fe4273cc007a7d8d589cb9
4
- data.tar.gz: 16281eeb0be0b1556390c42504f82d879ae6e13f427875215454f8a5d8949706
3
+ metadata.gz: 9b35ad7e7ce829ab16c8ded93da64a71120483982e1799afddf538ff0726d686
4
+ data.tar.gz: 6a5eec2b8c52f7df03d1f324780cc3b209b2969fe04ab64dc33efc8a1b3d05e7
5
5
  SHA512:
6
- metadata.gz: 07ec8746537d220b0b768715f29f5796543f497c1054c55796b8a23ae0ac83c4007d545d378b3ac7896893f68a1a2f2d0b11a0bbd002254cddb5369d7d6a5653
7
- data.tar.gz: aae794b82923901cd227d899fa914978e168fb8c35ff8433ccda048d7845e346aa9b74b001d91cc7779dcbe588cad46817fac48aa7c3ec3be1332ebf9ce80852
6
+ metadata.gz: 3b462e07684dc68a0c15096ea80cd5a516ac9332a1ba21f2235e85b5343b174561446d62633aa2dfc280557ff01531872fd3a033aafc1bf0eec6386b8b4d9901
7
+ data.tar.gz: 79dba86d404165e841ad94d034799bf3ba10e52fc286bdaa2af3d85b80d0ada8a075396f229e2de498fcea61274722cb8dacd762e68fb7243a9754b57e6221fe
data/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.20
4
+
5
+ - Hello, Root! sample
6
+ - Support `root` `width`, `height`, `x`, `y` attributes
7
+ - Support `root` attribute: `resizable`
8
+ - Support `root` attribute: `minsize`
9
+ - Support `root` attribute: `maxsize`
10
+ - Set minimum width/height on `root` (190 pixels)
11
+
12
+ ## 0.0.18
13
+
14
+ - Hello, Frame! sample
15
+ - Avoid setting grid geometry manager on `toplevel` widget
16
+ - Support `frame` `width` and `height` attributes
17
+ - Support `frame` `borderwidth` attribute
18
+ - Support `frame` `relief` attribute
19
+ - Support `frame` `padding` attribute
20
+ - Rename Hello, Tab! to Hello, Notebook!
21
+
22
+ ## 0.0.17
23
+
24
+ - Hello, Label! sample
25
+ - Support `label` `anchor` attribute (`'e'`, `'se'`, `'s'`, `'sw'`, `'w'`, `'nw'` or `'center'`)
26
+ - Support `label` `width` attributes
27
+ - Support `label` `image` attribute
28
+ - Support `label` `justify` attribute (`'left', 'center', 'right'`)
29
+ - Support `label` `font` attribute (`'default', 'text', 'fixed', 'menu', 'heading', 'caption', 'small_caption', 'icon', 'tooltip'`)
30
+ - Support `label` `foreground` attribute
31
+ - Support `label` `background` attribute (note that it does not work in Mac 'aqua' theme)
32
+ - Support `label` `compound` attribute
33
+ - Support `label` `relief` attributes (`'flat' (default), 'raised', 'sunken', 'solid', 'ridge', 'groove'`)
34
+
35
+ ## 0.0.16
36
+
37
+ - Support common themed widget state attributes: `active`, `disabled`, `focus`, `pressed`, `selected`, `background`, `readonly`, `alternate`, `invalid`, and `hover`
38
+ - Update Hello, Button! to utilize `focus true` in first button.
39
+
3
40
  ## 0.0.15
4
41
 
5
42
  - Update Hello, Button! to demo all button attributes
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.15
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.20
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)
@@ -9,7 +10,7 @@
9
10
 
10
11
  [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).
11
12
 
12
- [Tcl/Tk](https://www.tcl.tk/) has evolved into a practical desktop GUI toolkit due to 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.).
13
+ [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.).
13
14
 
14
15
  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).
15
16
 
@@ -61,6 +62,56 @@ 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
+ - [Notebook Frame](#notebook-frame)
83
+ - [Icon Photo](#icon-photo)
84
+ - [The Grid Geometry Manager](#the-grid-geometry-manager)
85
+ - [Bidirectional Data-Binding](#bidirectional-data-binding)
86
+ - [General Property Data-Binding](#general-property-data-binding)
87
+ - [Combobox Data-Binding](#combobox-data-binding)
88
+ - [List Single Selection Data-Binding](#list-single-selection-data-binding)
89
+ - [List Multi Selection Data-Binding](#list-multi-selection-data-binding)
90
+ - [Entry Data-Binding](#entry-data-binding)
91
+ - [Command Observer](#command-observer)
92
+ - [Gotchas](#gotchas)
93
+ - [Samples](#samples)
94
+ - [Hello, World!](#hello-world)
95
+ - [Hello, Button!](#hello-button)
96
+ - [Hello, Frame!](#hello-frame)
97
+ - [Hello, Root!](#hello-root)
98
+ - [Hello, Notebook!](#hello-notebook)
99
+ - [Hello, Label!](#hello-label)
100
+ - [Hello, Message Box!](#hello-message-box)
101
+ - [Hello, Combobox!](#hello-combobox)
102
+ - [Hello, List Single Selection!](#hello-list-single-selection)
103
+ - [Hello, List Multi Selection!](#hello-list-multi-selection)
104
+ - [Hello, Computed!](#hello-computed)
105
+ - [Help](#help)
106
+ - [Issues](#issues)
107
+ - [Chat](#chat)
108
+ - [Process](#process)
109
+ - [Planned Features and Feature Suggestions](#planned-features-and-feature-suggestions)
110
+ - [Change Log](#change-log)
111
+ - [Contributing](#contributing)
112
+ - [Contributors](#contributors)
113
+ - [License](#license)
114
+
64
115
  ## Pre-requisites
65
116
 
66
117
  - [Tcl/Tk](https://www.tcl.tk/): Follow the [install instructions](https://tkdocs.com/tutorial/install.html)
@@ -87,7 +138,7 @@ gem install glimmer-dsl-tk
87
138
 
88
139
  Add the following to `Gemfile`:
89
140
  ```
90
- gem 'glimmer-dsl-tk', '~> 0.0.15'
141
+ gem 'glimmer-dsl-tk', '~> 0.0.20'
91
142
  ```
92
143
 
93
144
  And, then run:
@@ -134,7 +185,7 @@ Example of an app written in [Tk](https://www.tcl.tk/) imperative syntax:
134
185
 
135
186
  ```ruby
136
187
  root = TkRoot.new
137
- root.title = 'Hello, Tab!'
188
+ root.title = 'Hello, Notebook!'
138
189
 
139
190
  notebook = ::Tk::Tile::Notebook.new(root).grid
140
191
 
@@ -155,7 +206,7 @@ Example of the same app written in [Glimmer](https://github.com/AndyObtiva/glimm
155
206
 
156
207
  ```ruby
157
208
  root {
158
- title 'Hello, Tab!'
209
+ title 'Hello, Notebook!'
159
210
 
160
211
  notebook {
161
212
  frame(text: 'English') {
@@ -175,12 +226,12 @@ root {
175
226
 
176
227
  ### Supported Widgets
177
228
 
178
- keyword(args) | attributes | listeners / events / bindings / callbacks
229
+ keyword(args) | attributes | event bindings & callbacks
179
230
  ------------- | ---------- | ---------
180
- `button` | `text`, `image`, `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `default` (`'active', 'normal'`) | `command`
231
+ `button` | `text`, `image` (optional keyword args: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`), `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `default` (`'active', 'normal'`) | `command`
181
232
  `entry` | `width`, `text` | None
182
- `frame(text: )` | None | None
183
- `label` | `text` | None
233
+ `frame(text: nil)` | `width`, `height`, `borderwidth`, `relief` (`'flat' (default), 'raised', 'sunken', 'solid', 'ridge', 'groove'`) | None
234
+ `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
235
  `list` | `selectmode`, `selection` | None
185
236
  `message_box(type: , message: , detail: , title: , icon: , default: , parent: )` | None | None
186
237
  `notebook` | None | None
@@ -188,7 +239,20 @@ keyword(args) | attributes | listeners / events / bindings / callbacks
188
239
 
189
240
  #### Common Attributes
190
241
 
191
- - `grid`
242
+ - `grid`: `Hash` of `:row`, `:column`, `:padx`, `:pady`, `:sticky` (`'e', 'w', 'n', 's'` or any combination of direction letters)
243
+
244
+ #### Common Themed Widget States
245
+
246
+ - `active?`
247
+ - `disabled?`
248
+ - `focus?`
249
+ - `pressed?`
250
+ - `selected?`
251
+ - `background?`
252
+ - `readonly?`
253
+ - `alternate?`
254
+ - `invalid?`
255
+ - `hover?`
192
256
 
193
257
  ### Smart Defaults and Convensions
194
258
 
@@ -196,6 +260,14 @@ keyword(args) | attributes | listeners / events / bindings / callbacks
196
260
 
197
261
  `grid` layout is the default on most widgets (which support it).
198
262
 
263
+ #### Label/Button Image
264
+
265
+ 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`)
266
+
267
+ #### Notebook Frame
268
+
269
+ When nesting `frame` under `notebook`, you can pass a `:text` keyword argument to indicate the tab title.
270
+
199
271
  #### Icon Photo
200
272
 
201
273
  The `iconphoto` attribute on `root` is set to the Glimmer icon by default if no icon photo is supplied.
@@ -362,6 +434,10 @@ This resets the person country.
362
434
 
363
435
  More details can be found in the [Hello, Combobox!](#hello-combobox) sample below.
364
436
 
437
+ ## Gotchas
438
+
439
+ - Setting `background` attribute on `frame` or `label` does not work in `'aqua'` theme on the Mac (only in `'classic'` theme)
440
+
365
441
  ## Samples
366
442
 
367
443
  ### Hello, World!
@@ -429,6 +505,7 @@ class HelloButton
429
505
  button {
430
506
  text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
431
507
  default 'active'
508
+ focus true
432
509
 
433
510
  command {
434
511
  self.count += 1
@@ -496,48 +573,284 @@ Glimmer app:
496
573
 
497
574
  ![glimmer dsl tk screenshot sample hello button](images/glimmer-dsl-tk-screenshot-sample-hello-button.png)
498
575
 
499
- ### Hello, Tab!
576
+ ### Hello, Frame!
500
577
 
501
- Glimmer code (from [samples/hello/hello_tab.rb](samples/hello/hello_tab.rb)):
578
+ Glimmer code (from [samples/hello/hello_frame.rb](samples/hello/hello_frame.rb)):
502
579
 
503
580
  ```ruby
581
+ require 'glimmer-dsl-tk'
582
+
583
+ class HelloFrame
584
+ include Glimmer
585
+
586
+ def launch
587
+ root {
588
+ title 'Hello, Frame!'
589
+
590
+ frame { # frame simply contains widgets for visual organization via a layout
591
+ relief 'sunken'
592
+
593
+ label {
594
+ grid row: 0, column: 0, columnspan: 4, padx: 5, pady: 5
595
+ text 'Enter Your Full Name'
596
+ font 'caption'
597
+ anchor 'center'
598
+ }
599
+
600
+ label {
601
+ grid row: 1, column: 0, padx: 5
602
+ text "First Name:"
603
+ }
604
+
605
+ entry {
606
+ grid row: 1, column: 1, padx: 5
607
+ }
608
+
609
+ label {
610
+ grid row: 2, column: 0, padx: 5
611
+ text "Last Name:"
612
+ }
613
+
614
+ entry {
615
+ grid row: 2, column: 1, padx: 5
616
+ }
617
+ }
618
+
619
+ frame { # an empty frame can specify width and height
620
+ grid padx: 7, pady: 7
621
+ width 200
622
+ height 100
623
+ borderwidth 3
624
+ relief 'sunken'
625
+ }
626
+ }.open
627
+ end
628
+ end
629
+
630
+ HelloFrame.new.launch
631
+ ```
632
+
633
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
634
+
635
+ ```
636
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_frame'"
637
+ ```
638
+
639
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
640
+
641
+ ```
642
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_frame.rb
643
+ ```
644
+
645
+ Glimmer app:
646
+
647
+ ![glimmer dsl tk screenshot sample hello frame](images/glimmer-dsl-tk-screenshot-sample-hello-frame.png)
648
+
649
+ ### Hello, Root!
650
+
651
+ Glimmer code (from [samples/hello/hello_frame.rb](samples/hello/hello_frame.rb)):
652
+
653
+ ```ruby
654
+ require 'glimmer-dsl-tk'
655
+
504
656
  include Glimmer
505
657
 
506
658
  root {
507
- title 'Hello, Tab!'
508
-
509
- notebook {
510
- frame(text: 'English') {
511
- label {
512
- text 'Hello, World!'
659
+ title 'Hello, Root!'
660
+ width 400
661
+ height 200
662
+ x 150
663
+ y 300
664
+ resizable true # same as `resizable true, true`, meaning cannot resize horizontally and vertically
665
+ minsize 200, 100
666
+ maxsize 600, 400
667
+ }.open
668
+ ```
669
+
670
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
671
+
672
+ ```
673
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_root'"
674
+ ```
675
+
676
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
677
+
678
+ ```
679
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_root.rb
680
+ ```
681
+
682
+ ### Hello, Notebook!
683
+
684
+ Glimmer code (from [samples/hello/hello_notebook.rb](samples/hello/hello_notebook.rb)):
685
+
686
+ ```ruby
687
+ require 'glimmer-dsl-tk'
688
+
689
+ class HelloNotebook
690
+ include Glimmer
691
+
692
+ def launch
693
+ root {
694
+ title 'Hello, Notebook!'
695
+
696
+ notebook {
697
+ frame(text: 'English') {
698
+ label {
699
+ text 'Hello, World!'
700
+ }
701
+ }
702
+
703
+ frame(text: 'French') {
704
+ label {
705
+ text 'Bonjour, Univers!'
706
+ }
707
+ }
513
708
  }
514
- }
515
-
516
- frame(text: 'French') {
517
- label {
518
- text 'Bonjour, Univers!'
709
+ }.open
710
+ end
711
+ end
712
+
713
+ HelloNotebook.new.launch
714
+ ```
715
+
716
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
717
+
718
+ ```
719
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_notebook'"
720
+ ```
721
+
722
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
723
+
724
+ ```
725
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_notebook.rb
726
+ ```
727
+
728
+ Glimmer app:
729
+
730
+ ![glimmer dsl tk screenshot sample hello notebook English](images/glimmer-dsl-tk-screenshot-sample-hello-notebook-english.png)
731
+ ![glimmer dsl tk screenshot sample hello notebook French](images/glimmer-dsl-tk-screenshot-sample-hello-notebook-french.png)
732
+
733
+ ### Hello, Label!
734
+
735
+ Glimmer code (from [samples/hello/hello_label.rb](samples/hello/hello_label.rb)):
736
+
737
+ ```ruby
738
+ require 'glimmer-dsl-tk'
739
+
740
+ class HelloLabel
741
+ include Glimmer
742
+
743
+ LABEL_FONTS = ['default', 'text', 'fixed', 'menu', 'heading', 'caption', 'small_caption', 'icon', 'tooltip']
744
+ LABEL_RELIEFS = ['flat', 'raised', 'sunken', 'solid', 'ridge', 'groove']
745
+
746
+ def launch
747
+ root {
748
+ title 'Hello, Label!'
749
+
750
+ notebook {
751
+ frame(text: 'left-aligned') {
752
+ 3.times do |n|
753
+ label {
754
+ text "Field #{n + 1} / default font / flat relief"
755
+ width 60
756
+ anchor 'w'
757
+ }
758
+ end
759
+ }
760
+
761
+ frame(text: 'centered') {
762
+ 9.times do |n|
763
+ label {
764
+ text "Field #{n + 1} / fixed font / raised relief"
765
+ width 80
766
+ anchor 'center'
767
+ font 'fixed'
768
+ relief 'raised'
769
+ }
770
+ end
771
+ }
772
+
773
+ frame(text: 'right-aligned') {
774
+ 9.times do |n|
775
+ label {
776
+ text "Field #{n + 1} / small_caption font / ridge relief"
777
+ width 80
778
+ anchor 'e'
779
+ font 'small_caption'
780
+ relief 'ridge'
781
+ }
782
+ end
783
+ }
784
+
785
+ frame(text: 'justified') {
786
+ label {
787
+ text <<~MULTI_LINE_STRING
788
+ This is a very long paragraph that spans multiple lines. It looks better and
789
+ is easier to read when justified. In fact, this is how to make it look like a
790
+ new paper column. That results in professional looking text. Magazines use the
791
+ same sort of justified text. Word processors also support justified text. In
792
+ fact, this is how text is made for news papers and magainzes, and then published
793
+ in paper form and digitally.
794
+ MULTI_LINE_STRING
795
+ width 60
796
+ anchor 'center'
797
+ justify 'center' # other options are: 'left' and 'right'
798
+ font 'caption' # other options are: 'default', 'text', 'fixed', 'menu', 'heading', 'small_caption', 'icon', 'tooltip'
799
+ foreground 'blue'
800
+ relief 'sunken' # other options are: 'flat' (default), 'raised', 'solid', 'ridge', 'groove'
801
+ }
802
+ }
803
+
804
+ frame(text: 'images') {
805
+ ['denmark', 'finland', 'norway'].each do |image_name|
806
+ label {
807
+ image File.expand_path("images/#{image_name}.png", __dir__)
808
+ }
809
+ end
810
+ }
811
+
812
+ frame(text: 'background images') {
813
+ ['italy', 'france', 'mexico'].each do |image_name|
814
+ label {
815
+ text image_name.capitalize
816
+ image File.expand_path("images/#{image_name}.png", __dir__)
817
+ compound 'center'
818
+ }
819
+ end
820
+ }
519
821
  }
520
- }
521
- }
522
- }.open
822
+ }.open
823
+ end
824
+ end
825
+
826
+ HelloLabel.new.launch
523
827
  ```
524
828
 
525
829
  Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
526
830
 
527
831
  ```
528
- ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_tab'"
832
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_label'"
529
833
  ```
530
834
 
531
835
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
532
836
 
533
837
  ```
534
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_tab'"
838
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_label.rb
535
839
  ```
536
840
 
537
841
  Glimmer app:
538
842
 
539
- ![glimmer dsl tk screenshot sample hello tab English](images/glimmer-dsl-tk-screenshot-sample-hello-tab-english.png)
540
- ![glimmer dsl tk screenshot sample hello tab French](images/glimmer-dsl-tk-screenshot-sample-hello-tab-french.png)
843
+ ![glimmer dsl tk screenshot sample hello label left aligned](images/glimmer-dsl-tk-screenshot-sample-hello-label-left-aligned.png)
844
+
845
+ ![glimmer dsl tk screenshot sample hello label centered](images/glimmer-dsl-tk-screenshot-sample-hello-label-centered.png)
846
+
847
+ ![glimmer dsl tk screenshot sample hello label right aligned](images/glimmer-dsl-tk-screenshot-sample-hello-label-right-aligned.png)
848
+
849
+ ![glimmer dsl tk screenshot sample hello label justified](images/glimmer-dsl-tk-screenshot-sample-hello-label-justified.png)
850
+
851
+ ![glimmer dsl tk screenshot sample hello label images](images/glimmer-dsl-tk-screenshot-sample-hello-label-images.png)
852
+
853
+ ![glimmer dsl tk screenshot sample hello label background images](images/glimmer-dsl-tk-screenshot-sample-hello-label-background-images.png)
541
854
 
542
855
  ### Hello, Message Box!
543
856
 
@@ -618,13 +931,13 @@ root { |r|
618
931
  Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
619
932
 
620
933
  ```
621
- ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_tab'"
934
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_message_box'"
622
935
  ```
623
936
 
624
937
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
625
938
 
626
939
  ```
627
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_tab'"
940
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_message_box.rb
628
941
  ```
629
942
 
630
943
  Glimmer app:
@@ -665,7 +978,7 @@ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_combobox'"
665
978
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
666
979
 
667
980
  ```
668
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_combobox'"
981
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_combobox.rb
669
982
  ```
670
983
 
671
984
  Glimmer app:
@@ -705,7 +1018,7 @@ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_list_single_selection'"
705
1018
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
706
1019
 
707
1020
  ```
708
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_list_single_selection'"
1021
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_list_single_selection.rb
709
1022
  ```
710
1023
 
711
1024
  Glimmer app:
@@ -743,7 +1056,7 @@ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_list_multi_selection'"
743
1056
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
744
1057
 
745
1058
  ```
746
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_list_multi_selection'"
1059
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_list_multi_selection.rb
747
1060
  ```
748
1061
 
749
1062
  Glimmer app:
@@ -823,7 +1136,7 @@ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_computed'"
823
1136
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
824
1137
 
825
1138
  ```
826
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_computed'"
1139
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_computed.rb
827
1140
  ```
828
1141
 
829
1142
  Glimmer app:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.15
1
+ 0.0.20
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
@@ -27,8 +27,13 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class RootProxy < WidgetProxy
30
+ REGEX_GEOMETRY = /[x+-]/
31
+ DEFAULT_WIDTH = 190
32
+ DEFAULT_HEIGHT = 95
33
+
30
34
  def initialize(*args)
31
35
  @tk = ::TkRoot.new
36
+ @tk.minsize = DEFAULT_WIDTH, DEFAULT_HEIGHT
32
37
  end
33
38
 
34
39
  def post_add_content
@@ -43,19 +48,114 @@ module Glimmer
43
48
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::RootExpression.new, keyword, *args, &block)
44
49
  end
45
50
 
51
+ def has_attribute?(attribute, *args)
52
+ %w[width height x y].include?(attribute.to_s) || super
53
+ end
54
+
46
55
  def set_attribute(attribute, *args)
47
- if attribute.to_s == 'iconphoto'
56
+ case attribute.to_s
57
+ when 'iconphoto'
48
58
  args[0..-1] = [image_argument(args)]
49
59
  super
60
+ when 'width'
61
+ @width = args.first.to_i
62
+ self.geometry = "#{args.first.to_i}x#{@height || DEFAULT_HEIGHT}#{x_sign}#{abs_x}#{y_sign}#{abs_y}"
63
+ when 'height'
64
+ @height = args.first.to_i
65
+ self.geometry = "#{@width || DEFAULT_WIDTH}x#{args.first.to_i}#{x_sign}#{abs_x}#{y_sign}#{abs_y}"
66
+ when 'x'
67
+ self.geometry = "#{@width || DEFAULT_WIDTH}x#{@height || DEFAULT_HEIGHT}#{args.first.to_i > 0 ? '+' : '-'}#{args.first.to_i.abs}#{y_sign}#{abs_y}"
68
+ when 'y'
69
+ self.geometry = "#{@width || DEFAULT_WIDTH}x#{@height || DEFAULT_HEIGHT}#{x_sign}#{abs_x}#{args.first.to_i > 0 ? '+' : '-'}#{args.first.to_i.abs}"
70
+ when 'resizable'
71
+ if args.size == 1 && !args.first.is_a?(Array)
72
+ self.resizable = [args.first]*2
73
+ else
74
+ super
75
+ end
50
76
  else
51
77
  super
52
78
  end
53
79
  end
54
-
80
+
81
+ def get_attribute(attribute)
82
+ attribute = attribute.to_s
83
+ case attribute
84
+ when 'width'
85
+ geometry.split(REGEX_GEOMETRY)[0].to_i
86
+ when 'height'
87
+ geometry.split(REGEX_GEOMETRY)[1].to_i
88
+ when 'x'
89
+ sign_number(x_sign, geometry.split(REGEX_GEOMETRY)[2].to_i)
90
+ when 'y'
91
+ sign_number(y_sign, geometry.split(REGEX_GEOMETRY)[3].to_i)
92
+ else
93
+ super
94
+ end
95
+ end
96
+
97
+ def width
98
+ get_attribute(:width)
99
+ end
100
+
101
+ def height
102
+ get_attribute(:height)
103
+ end
104
+
105
+ def x
106
+ get_attribute(:x)
107
+ end
108
+
109
+ def y
110
+ get_attribute(:y)
111
+ end
112
+
113
+ def width=(value)
114
+ set_attribute(:width, value)
115
+ end
116
+
117
+ def height=(value)
118
+ set_attribute(:height, value)
119
+ end
120
+
121
+ def x=(value)
122
+ set_attribute(:x, value)
123
+ end
124
+
125
+ def y=(value)
126
+ set_attribute(:y, value)
127
+ end
128
+
55
129
  # Starts Tk mainloop
56
130
  def start_event_loop
57
131
  ::Tk.mainloop
58
132
  end
133
+
134
+ private
135
+
136
+ def sign_number(sign, number)
137
+ "#{sign}1".to_i * number
138
+ end
139
+
140
+ def abs_x
141
+ geometry.split(REGEX_GEOMETRY)[2].to_i
142
+ end
143
+
144
+ def abs_y
145
+ geometry.split(REGEX_GEOMETRY)[3].to_i
146
+ end
147
+
148
+ def x_sign
149
+ geometry_signs[0]
150
+ end
151
+
152
+ def y_sign
153
+ geometry_signs[1]
154
+ end
155
+
156
+ def geometry_signs
157
+ geometry.chars.select {|char| char.match(/[+-]/)}
158
+ end
59
159
  end
60
160
  end
61
161
  end
@@ -85,7 +85,7 @@ module Glimmer
85
85
  tk_widget_class = self.class.tk_widget_class_for(underscored_widget_name)
86
86
  @tk = tk_widget_class.new(@parent_proxy.tk, *args)
87
87
  # a common widget initializer
88
- @tk.grid
88
+ @tk.grid unless @tk.is_a?(::Tk::Toplevel)
89
89
  DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@tk)
90
90
  @parent_proxy.post_initialize_child(self)
91
91
  end
@@ -117,13 +117,34 @@ 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
127
+ end
128
+
129
+ def has_state?(attribute)
130
+ attribute = attribute.sub(/\?$/, '').sub(/=$/, '')
131
+ if @tk.respond_to?(:tile_state)
132
+ begin
133
+ @tk.tile_instate(attribute)
134
+ true
135
+ rescue
136
+ false
137
+ end
138
+ else
139
+ false
140
+ end
121
141
  end
122
142
 
123
143
  def has_attribute?(attribute, *args)
124
- (widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][attribute.to_s]) ||
125
- tk_widget_has_attribute_setter?(attribute) ||
126
- tk_widget_has_attribute_getter_setter?(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
127
148
  respond_to?(attribute_setter(attribute), args)
128
149
  end
129
150
 
@@ -132,9 +153,22 @@ module Glimmer
132
153
  if widget_custom_attribute
133
154
  widget_custom_attribute[:setter][:invoker].call(@tk, args)
134
155
  elsif tk_widget_has_attribute_setter?(attribute)
135
- @tk.send(attribute_setter(attribute), *args) unless @tk.send(attribute) == args.first
156
+ unless args.size == 1 && @tk.send(attribute) == args.first
157
+ if args.size == 1
158
+ @tk.send(attribute_setter(attribute), *args)
159
+ else
160
+ @tk.send(attribute_setter(attribute), args)
161
+ end
162
+ end
136
163
  elsif tk_widget_has_attribute_getter_setter?(attribute)
137
164
  @tk.send(attribute, *args)
165
+ elsif has_state?(attribute)
166
+ attribute = attribute.sub(/=$/, '')
167
+ if !!args.first
168
+ @tk.tile_state(attribute)
169
+ else
170
+ @tk.tile_state("!#{attribute}")
171
+ end
138
172
  else
139
173
  send(attribute_setter(attribute), args)
140
174
  end
@@ -146,6 +180,8 @@ module Glimmer
146
180
  widget_custom_attribute[:getter][:invoker].call(@tk, args)
147
181
  elsif tk_widget_has_attribute_getter_setter?(attribute)
148
182
  @tk.send(attribute)
183
+ elsif has_state?(attribute)
184
+ @tk.tile_instate(attribute.sub(/\?$/, ''))
149
185
  else
150
186
  send(attribute)
151
187
  end
@@ -159,8 +195,8 @@ module Glimmer
159
195
  @widget_custom_attribute_mapping ||= {
160
196
  ::Tk::Tile::TButton => {
161
197
  'image' => {
162
- getter: {name: 'image', invoker: lambda { |widget, args| @tk.textvariable&.value }},
163
- setter: {name: 'image=', invoker: lambda { |widget, args| @tk['image'] = image_argument(args) }},
198
+ getter: {name: 'image', invoker: lambda { |widget, args| @tk.image }},
199
+ setter: {name: 'image=', invoker: lambda { |widget, args| @tk.image = image_argument(args) }},
164
200
  },
165
201
  },
166
202
  ::Tk::Tile::TCombobox => {
@@ -174,6 +210,10 @@ module Glimmer
174
210
  getter: {name: 'text', invoker: lambda { |widget, args| @tk.textvariable&.value }},
175
211
  setter: {name: 'text=', invoker: lambda { |widget, args| @tk.textvariable&.value = args.first }},
176
212
  },
213
+ 'image' => {
214
+ getter: {name: 'image', invoker: lambda { |widget, args| @tk.image }},
215
+ setter: {name: 'image=', invoker: lambda { |widget, args| @tk.image = image_argument(args) }},
216
+ },
177
217
  },
178
218
  ::Tk::Tile::TEntry => {
179
219
  'text' => {
@@ -244,9 +284,9 @@ module Glimmer
244
284
 
245
285
  def method_missing(method, *args, &block)
246
286
  method = method.to_s
247
- if args.empty? && block.nil? && widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][method]
287
+ if args.empty? && block.nil? && ((widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][method]) || has_state?(method))
248
288
  get_attribute(method)
249
- elsif widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][method.sub(/=$/, '')] && method.end_with?('=') && block.nil?
289
+ elsif method.end_with?('=') && block.nil? && ((widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][method.sub(/=$/, '')]) || has_state?(method))
250
290
  set_attribute(method.sub(/=$/, ''), *args)
251
291
  else
252
292
  tk.send(method, *args, &block)
@@ -42,9 +42,10 @@ class HelloButton
42
42
  text 'Text Button'
43
43
  }
44
44
 
45
- button {
45
+ button { |b|
46
46
  text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
47
47
  default 'active'
48
+ focus true
48
49
 
49
50
  command {
50
51
  self.count += 1
@@ -0,0 +1,71 @@
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 HelloFrame
25
+ include Glimmer
26
+
27
+ def launch
28
+ root {
29
+ title 'Hello, Frame!'
30
+
31
+ frame { # frame simply contains widgets for visual organization via a layout
32
+ relief 'sunken'
33
+
34
+ label {
35
+ grid row: 0, column: 0, columnspan: 4, padx: 5, pady: 5
36
+ text 'Enter Your Full Name'
37
+ font 'caption'
38
+ anchor 'center'
39
+ }
40
+
41
+ label {
42
+ grid row: 1, column: 0, padx: 5
43
+ text "First Name:"
44
+ }
45
+
46
+ entry {
47
+ grid row: 1, column: 1, padx: 5
48
+ }
49
+
50
+ label {
51
+ grid row: 2, column: 0, padx: 5
52
+ text "Last Name:"
53
+ }
54
+
55
+ entry {
56
+ grid row: 2, column: 1, padx: 5
57
+ }
58
+ }
59
+
60
+ frame { # an empty frame can specify width and height
61
+ grid padx: 7, pady: 7
62
+ width 200
63
+ height 100
64
+ borderwidth 3
65
+ relief 'sunken'
66
+ }
67
+ }.open
68
+ end
69
+ end
70
+
71
+ HelloFrame.new.launch
@@ -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
@@ -21,12 +21,12 @@
21
21
 
22
22
  require 'glimmer-dsl-tk'
23
23
 
24
- class HelloTab
24
+ class HelloNotebook
25
25
  include Glimmer
26
26
 
27
27
  def launch
28
28
  root {
29
- title 'Hello, Tab!'
29
+ title 'Hello, Notebook!'
30
30
 
31
31
  notebook {
32
32
  frame(text: 'English') {
@@ -45,4 +45,4 @@ class HelloTab
45
45
  end
46
46
  end
47
47
 
48
- HelloTab.new.launch
48
+ HelloNotebook.new.launch
@@ -0,0 +1,35 @@
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
+ include Glimmer
25
+
26
+ root {
27
+ title 'Hello, Root!'
28
+ width 400
29
+ height 200
30
+ x 150
31
+ y 300
32
+ resizable true # same as `resizable true, true`, meaning cannot resize horizontally and vertically
33
+ minsize 200, 100
34
+ maxsize 600, 400
35
+ }.open
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.15
4
+ version: 0.0.20
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-09 00:00:00.000000000 Z
11
+ date: 2021-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 3.5.0
69
- - !ruby/object:Gem::Dependency
70
- name: rdoc
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.12'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.12'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: bundler
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -142,6 +128,20 @@ dependencies:
142
128
  - - '='
143
129
  - !ruby/object:Gem::Version
144
130
  version: 0.8.23
131
+ - !ruby/object:Gem::Dependency
132
+ name: json
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - '='
136
+ - !ruby/object:Gem::Version
137
+ version: 2.5.1
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - '='
143
+ - !ruby/object:Gem::Version
144
+ version: 2.5.1
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: simplecov
147
147
  requirement: !ruby/object:Gem::Requirement
@@ -170,7 +170,7 @@ dependencies:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
172
  version: 0.7.0
173
- description: Glimmer DSL for Tk (Ruby Desktop Development GUI Library)
173
+ description: Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
174
174
  email: andy.am@gmail.com
175
175
  executables:
176
176
  - girb
@@ -214,11 +214,23 @@ 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_frame.rb
218
+ - samples/hello/hello_label.rb
217
219
  - samples/hello/hello_list_multi_selection.rb
218
220
  - samples/hello/hello_list_single_selection.rb
219
221
  - samples/hello/hello_message_box.rb
220
- - samples/hello/hello_tab.rb
222
+ - samples/hello/hello_notebook.rb
223
+ - samples/hello/hello_root.rb
221
224
  - samples/hello/hello_world.rb
225
+ - samples/hello/images/denmark.png
226
+ - samples/hello/images/finland.png
227
+ - samples/hello/images/france.png
228
+ - samples/hello/images/germany.png
229
+ - samples/hello/images/italy.png
230
+ - samples/hello/images/mexico.png
231
+ - samples/hello/images/netherlands.png
232
+ - samples/hello/images/norway.png
233
+ - samples/hello/images/usa.png
222
234
  homepage: http://github.com/AndyObtiva/glimmer-dsl-tk
223
235
  licenses:
224
236
  - MIT