glimmer-dsl-tk 0.0.27 → 0.0.31

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.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Tk 0.0.27
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.30
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
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)
@@ -12,7 +12,7 @@
12
12
 
13
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.). 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).
14
14
 
15
- The trade-off is that while [SWT](https://www.eclipse.org/swt/) provides a plethora of high quality reusable widgets for the Enterprise (such as [Nebula](https://github.com/AndyObtiva/glimmer-cw-nebula)), [Tk](https://www.tcl.tk/) enables very fast app startup time and a small memory footprint via [MRI Ruby](https://www.ruby-lang.org/en/).
15
+ The trade-off is that while [SWT](https://www.eclipse.org/swt/) provides a plethora of high quality reusable widgets for the Enterprise (such as [Nebula](https://github.com/AndyObtiva/glimmer-cw-nebula)), [Tk](https://www.tcl.tk/) has a very fast app startup time and a small memory footprint courtesy of [MRI Ruby](https://www.ruby-lang.org/en/).
16
16
 
17
17
  [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk) aims to provide a DSL similar to the [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) to enable more productive desktop development in Ruby with:
18
18
  - Declarative DSL syntax that visually maps to the GUI widget hierarchy
@@ -74,7 +74,8 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
74
74
  - [Supported Widgets](#supported-widgets)
75
75
  - [Common Attributes](#common-attributes)
76
76
  - [Common Themed Widget States](#common-themed-widget-states)
77
- - [Text Extra API Methods](#text-extra-api-methods)
77
+ - [Text API](#text-api)
78
+ - [Drag and Drop API](#drag-and-drop-api)
78
79
  - [Smart Defaults and Conventions](#smart-defaults-and-conventions)
79
80
  - [Grid Layout](#grid-layout)
80
81
  - [Image Attribute](#image-attribute)
@@ -90,6 +91,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
90
91
  - [List Single Selection Data-Binding](#list-single-selection-data-binding)
91
92
  - [List Multi Selection Data-Binding](#list-multi-selection-data-binding)
92
93
  - [Entry Data-Binding](#entry-data-binding)
94
+ - [Text Data-Binding](#text-data-binding)
93
95
  - [Spinbox Data-Binding](#spinbox-data-binding)
94
96
  - [Checkbutton Data-Binding](#checkbutton-data-binding)
95
97
  - [Radiobutton Data-Binding](#radiobutton-data-binding)
@@ -112,10 +114,18 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
112
114
  - [Hello, Text!](#hello-text)
113
115
  - [Hello, Spinbox!](#hello-spinbox)
114
116
  - [Hello, Computed!](#hello-computed)
117
+ - [Hello, Drag and Drop!](#hello-drag-and-drop)
118
+ - [Hello, Built-in Dialog!](#hello-built-in-dialog)
119
+ - [Hello, Separator!](#hello-separator)
120
+ - [Applications](#applications)
121
+ - [Glimmer Tk Calculator](#glimmer-tk-calculator)
122
+ - [Y3network Ruby UI](#y3network-ruby-ui)
123
+ - [CryptoPunks GUI](#cryptopunks-gui)
124
+ - [Process](#process)
125
+ - [Resources](#resources)
115
126
  - [Help](#help)
116
127
  - [Issues](#issues)
117
128
  - [Chat](#chat)
118
- - [Process](#process)
119
129
  - [Planned Features and Feature Suggestions](#planned-features-and-feature-suggestions)
120
130
  - [Change Log](#change-log)
121
131
  - [Contributing](#contributing)
@@ -148,7 +158,7 @@ gem install glimmer-dsl-tk
148
158
 
149
159
  Add the following to `Gemfile`:
150
160
  ```
151
- gem 'glimmer-dsl-tk', '~> 0.0.27'
161
+ gem 'glimmer-dsl-tk', '~> 0.0.30'
152
162
  ```
153
163
 
154
164
  And, then run:
@@ -259,8 +269,14 @@ keyword(args) | attributes | event bindings & callbacks
259
269
  ------------- | ---------- | ---------
260
270
  `button` | `text`, `image` (optional keyword args: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`), `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `default` (`'active', 'normal'`) | `command {}`
261
271
  `checkbutton` | `text`, `variable` (Boolean), `image` (optional keyword args: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`), `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `onvalue` (default: `1`), `offvalue` (default: `0`) | `command {}`
272
+ `choose_color(options = nil)` | None | None
273
+ `choose_directory(options = nil)` | None | None
274
+ `choose_font(options = nil) {|font| ... }` | None | None
262
275
  `combobox` | `state`, `text` | `'ComboboxSelected'`
263
276
  `entry` | `width`, `text`, `validate`, `show` (`'none', 'focus', 'focusin', 'focusout', 'key', or 'all'`) | `'validate'`, `'invalid'`, `'change'`, `validatecommand {}`, `invalidcommand {}`
277
+ `get_multiple_open_file(options = nil)` | None | None
278
+ `get_open_file(options = nil)` | None | None
279
+ `get_save_file(options = nil)` | None | None
264
280
  `spinbox` | `text`, `from`, `to`, `increment`, `format`, [more attributes](https://tcl.tk/man/tcl8.6/TkCmd/text.htm#M116) | `command {}`, `'increment'`, `'decrement'`
265
281
  `frame(text: nil)` | `width`, `height`, `borderwidth`, `relief` (`'flat' (default), 'raised', 'sunken', 'solid', 'ridge', 'groove'`) | None
266
282
  `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
@@ -269,7 +285,11 @@ keyword(args) | attributes | event bindings & callbacks
269
285
  `notebook` | None | None
270
286
  `radiobutton` | `text`, `variable` (Boolean), `image` (optional keyword args: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`), `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `value` (default: `text`) | `command {}`
271
287
  `root` | `title`, `iconphoto`, `background`, `alpha`, `fullscreen?`, `topmost?`, `transparent?`, `stackorder`, `winfo_screendepth`, `winfo_screenvisual`, `winfo_screenwidth`, `winfo_screenheight`, `winfo_pixels('li')`, `winfo_screen`, `wm_maxsize`, `state` (`'normal', 'iconic', 'withdrawn', 'icon', 'zoomed'`) | `'DELETE_WINDOW'`, `'OPEN_WINDOW'`
272
- `text` | `text`, [many more attributes](https://tcl.tk/man/tcl8.6/TkCmd/text.htm#M116) | `'modified'`, `'selection'`
288
+ `separator` | `orient` (`'horizontal' (default) or 'vertical'`) | None
289
+ `text` | `value`, [many more attributes](https://tcl.tk/man/tcl8.6/TkCmd/text.htm#M116) | `'modified'`, `'selection'`
290
+
291
+ Options for `get_open_file` and `get_multiple_open_file` include:
292
+ - `filetypes`: `Hash` of `'Group Name' => '.ext'` entries (e.g. `filetypes: {'PNG Images' => '.png'}`
273
293
 
274
294
  #### Common Attributes
275
295
 
@@ -319,11 +339,9 @@ keyword(args) | attributes | event bindings & callbacks
319
339
  - `invalid?`
320
340
  - `hover?`
321
341
 
322
- #### Text Extra API Methods
342
+ #### Text API
323
343
 
324
- [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk) automatically provides a `text` attribute for the `text` widget that enables updating its content simply without worrying about whether to manually insert by index, delete, or append.
325
-
326
- Also, the `text` widget is enhanced by [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk) to enable simpler manipulation of text options without dealing with [tags](https://tkdocs.com/tutorial/text.html) directly. Simply specify region to mutate and option/value or font_option/value, and [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk) takes care of the rest by automating work of adding/removing [tags](https://tkdocs.com/tutorial/text.html) behind the scenes.
344
+ The `text` widget is enhanced by [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk) to enable simpler manipulation of text options without dealing with [tags](https://tkdocs.com/tutorial/text.html) directly. Simply specify region to mutate and option/value or font_option/value, and [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk) takes care of the rest by automating work of adding/removing [tags](https://tkdocs.com/tutorial/text.html) behind the scenes.
327
345
 
328
346
  - `add_format(region_start, region_end, option, value)`
329
347
  - `remove_format(region_start, region_end, option, value)`
@@ -337,6 +355,8 @@ Also, the `text` widget is enhanced by [Glimmer DSL for Tk](https://rubygems.org
337
355
  - `add_selection_font_format(region_start, region_end, font_option, value)`
338
356
  - `remove_selection_font_format(region_start, region_end, font_option, value)`
339
357
  - `toggle_selection_font_format(region_start, region_end, font_option, value)`
358
+ - `text#insert_image(text_index, *image_args)`: inserts image into `text` `value` content at `text_index` location (e.g. `'insert'`)
359
+ - `text#get_open_file_to_insert_image(text_index = 'insert')`: opens a file dialog to select one of the available image formats and then inserts image into `text` `value` content
340
360
 
341
361
  Available options:
342
362
 
@@ -370,7 +390,28 @@ Available font options:
370
390
  - `underline` (default: `false`)
371
391
  - `overstrike` (default: `false`)
372
392
 
373
- Check out the [Hello, Text!](#hello-text) sample for a good demonstration of the `text` widget.
393
+ Other useful built-in API methods:
394
+
395
+ - `text_cut`
396
+ - `text_copy`
397
+ - `text_paste`
398
+ - `text_edit_undo`
399
+ - `text_edit_redo`
400
+
401
+ Check out the [Hello, Text!](#hello-text) sample for a good demonstration of the `text` widget features.
402
+
403
+ #### Drag and Drop API
404
+
405
+ Drag and drop works by simply designating a widget as a drag source with attribute `drag_source true`
406
+
407
+ Alternatively, add listeners:
408
+ - `on_drag_start {|event| ...}`: fires on drag start receiving an `event` arg to set `data` and configure `source`
409
+ - `on_drag_motion {|event| ...}`: fires on drag motion receiving an `event` arg to check `event#drop_accepted`, and configure `source` and `tooltip`
410
+
411
+ On the drop target, you simply define:
412
+ - `on_drop { |event| ...}`: fires on drop, receiving an `event` arg with `event#target` and `event#data` (set during drag). You can even destroy the `event#source` if you want to get rid of the dragged widget.
413
+
414
+ Learn more at the [Hello, Drag and Drop!](#hello-drag-and-drop) sample.
374
415
 
375
416
  ### Smart Defaults and Conventions
376
417
 
@@ -388,7 +429,13 @@ To override that behavior, you may set alternative `grid` keyword args if needed
388
429
 
389
430
  #### Image Attribute
390
431
 
391
- Widget `image` attribute (e.g. `label` `image`) 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`)
432
+ Widget `image` attribute (e.g. `label` `image`) can accept image path directly as an alternative to `TkPhotoImage` object in addition to key values for automatic processing of image:
433
+ - `subsample(x_divider, y_divider)`: Specifies that the source image should be reduced in size by using only every xth pixel in the X direction and yth pixel in the Y direction. Negative values will cause the image to be flipped about the Y or X axes, respectively. If y is not given, the default value is the same as x.
434
+ - `zoom(x_multiplier, y_multiplier)`: Specifies that the source region should be magnified by a factor of x in the X direction and y in the Y direction. If y is not given, the default value is the same as x. With this option, each pixel in the source image will be expanded into a block of x x y pixels in the destination image, all the same color. x and y must be greater than 0.
435
+ - `from(x1, y1, x2, y2)`: Specifies a rectangular sub-region of the source image to be copied. (x1,y1) and (x2,y2) specify diagonally opposite corners of the rectangle. If x2 and y2 are not specified, the default value is the bottom-right corner of the source image. The pixels copied will include the left and top edges of the specified rectangle but not the bottom or right edges. If the :from option is not given, the default is the whole source image.
436
+ - `to(x1, y1, x2, y2)`: Specifies a rectangular sub-region of the destination image to be affected. (x1,y1) and (x2,y2) specify diagonally opposite corners of the rectangle. If x2 and y2 are not specified, the default value is (x1,y1) plus the size of the source region (after subsampling and zooming, if specified). If x2 and y2 are specified, the source region will be replicated if necessary to fill the destination region in a tiled fashion.
437
+ - `shrink`: Specifies that the size of the destination image should be reduced, if necessary, so that the region being copied into is at the bottom-right corner of the image. This option will not affect the width or height of the image if the user has specified a non-zero value for the :width or :height configuration option, respectively.
438
+ - `compositingrule` (can be `'overlay'` or `'set'`): Specifies how transparent pixels in the source image are combined with the destination image. When a compositing rule of <tt>overlay</tt> is set, the old contents of the destination image are visible, as if the source image were printed on a piece of transparent film and placed over the top of the destination. When a compositing rule of <tt>set</tt> is set, the old contents of the destination image are discarded and the source image is used as-is. The default compositing rule is <tt>overlay</tt>.
392
439
 
393
440
  #### Frame Padding
394
441
 
@@ -451,6 +498,8 @@ Example:
451
498
  ```
452
499
 
453
500
  Extra convenience options may be passed to `grid` when using [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk):
501
+ - `column_span`: alias for `columnspan` keyword arg
502
+ - `row_span`: alias for `rowspan` keyword arg
454
503
  - `min_width`: alias for `columnminsize` being called on `TkGrid.columnconfigure`
455
504
  - `min_height`: alias for `rowminsize` being called on `TkGrid.rowconfigure`
456
505
  - `column_weight`: alias for `columnweight` being called on `TkGrid.columnconfigure`
@@ -563,6 +612,24 @@ It automatically handles all the Tk plumbing behind the scenes.
563
612
 
564
613
  More details can be found in [Hello, Entry!](#hello-entry) and [Hello, Computed!](#hello-computed) samples below.
565
614
 
615
+ ### Text Data-Binding
616
+
617
+ Example:
618
+
619
+ This assumes a `Person` model with a `biography` attribute.
620
+
621
+ ```ruby
622
+ text {
623
+ value <=> [person, :biography]
624
+ }
625
+ ```
626
+
627
+ That code binds the `value` of `text` to the `biography` attribute on the `person` model.
628
+
629
+ It automatically handles all the Tk plumbing behind the scenes.
630
+
631
+ More details can be found in [Hello, Text!](#hello-text) sample below.
632
+
566
633
  ### Spinbox Data-Binding
567
634
 
568
635
  Example:
@@ -683,6 +750,128 @@ ruby -r ./lib/glimmer-dsl-tk.rb samples/elaborate/meta_sample.rb
683
750
 
684
751
  ![glimmer dsl tk screenshot sample meta sample](images/glimmer-dsl-tk-screenshot-sample-elaborate-meta-sample.png)
685
752
 
753
+ Code:
754
+
755
+ ```ruby
756
+ require 'glimmer-dsl-tk'
757
+ require 'facets'
758
+ require 'fileutils'
759
+
760
+ class MetaSample
761
+ include Glimmer
762
+
763
+ attr_accessor :selected_sample_index
764
+
765
+ def initialize
766
+ @selected_sample_index = 0
767
+ end
768
+
769
+ def samples
770
+ if @samples.nil?
771
+ sample_files = Dir.glob(File.join(File.expand_path('../hello', __dir__), '**', 'hello_*.rb'))
772
+ sample_file_names = sample_files.map { |f| File.basename(f, '.rb') }
773
+ sample_file_names = sample_file_names.reject { |f| f == 'meta_sample' || f.match(/\d$/) }
774
+ @samples = sample_file_names.map { |f| f.underscore.titlecase }
775
+ end
776
+ @samples
777
+ end
778
+
779
+ def file_path_for(sample)
780
+ File.join(File.expand_path('../hello', __dir__), "#{sample.underscore}.rb")
781
+ end
782
+
783
+ def glimmer_dsl_tk_file
784
+ File.expand_path('../../lib/glimmer-dsl-tk', __dir__)
785
+ end
786
+
787
+ def selected_sample
788
+ samples[@selected_sample_index]
789
+ end
790
+
791
+ def run_sample(sample)
792
+ Thread.new do
793
+ command = "ruby -r #{glimmer_dsl_tk_file} #{sample} 2>&1"
794
+ result = ''
795
+ IO.popen(command) do |f|
796
+ f.each_line do |line|
797
+ result << line
798
+ puts line
799
+ $stdout.flush
800
+ end
801
+ end
802
+ ::Tk.after(100) do
803
+ message_box(parent: @root, title: 'Error Running Sample', message: result) if result.downcase.include?('error')
804
+ end
805
+ end
806
+ end
807
+
808
+ def launch
809
+ @root = root {
810
+ title 'Glimmer Meta-Sample'
811
+ width 1280
812
+ height 720
813
+
814
+ frame {
815
+ grid row: 0, column: 0, column_weight: 0, row_weight: 1
816
+
817
+ samples.each_with_index do |sample, index|
818
+ radiobutton {
819
+ text sample
820
+ variable <=> [self, :selected_sample_index, on_write: ->(v) {v ? index : selected_sample_index}, on_read: ->(v) {v == index}]
821
+
822
+ on('command') do
823
+ @selected_sample_index = index
824
+ @code_text.value = File.read(file_path_for(selected_sample))
825
+ end
826
+ }
827
+ end
828
+
829
+ frame {
830
+ button {
831
+ grid row: 0, column: 0
832
+ text 'Launch'
833
+
834
+ on('command') do
835
+ begin
836
+ parent_dir = File.join(Dir.home, '.glimmer-dsl-tk', 'samples', 'hello')
837
+ FileUtils.mkdir_p(parent_dir)
838
+ sample_file = File.join(parent_dir, "#{selected_sample.underscore}.rb")
839
+ File.write(sample_file, @code_text.value)
840
+ FileUtils.cp_r(File.expand_path('../../icons', __dir__), File.dirname(File.dirname(parent_dir)))
841
+ FileUtils.cp_r(File.expand_path('../hello/images', __dir__), parent_dir)
842
+ sample_namespace_directory = File.expand_path("../hello/#{selected_sample.underscore}", __dir__)
843
+ FileUtils.cp_r(sample_namespace_directory, parent_dir) if Dir.exist?(sample_namespace_directory)
844
+ run_sample(sample_file)
845
+ rescue => e
846
+ puts e.full_message
847
+ puts 'Unable to write code changes! Running original sample...'
848
+ run_sample(file_path_for(selected_sample))
849
+ end
850
+ end
851
+ }
852
+ button {
853
+ grid row: 0, column: 1
854
+ text 'Reset'
855
+
856
+ on('command') do
857
+ @code_text.value = File.read(file_path_for(selected_sample))
858
+ end
859
+ }
860
+ }
861
+ }
862
+
863
+ @code_text = text {
864
+ grid row: 0, column: 1, column_weight: 1
865
+ value File.read(file_path_for(selected_sample))
866
+ }
867
+ }
868
+ @root.open
869
+ end
870
+ end
871
+
872
+ MetaSample.new.launch
873
+ ```
874
+
686
875
  ### Hello, World!
687
876
 
688
877
  Glimmer code (from [samples/hello/hello_world.rb](samples/hello/hello_world.rb)):
@@ -1243,6 +1432,8 @@ Glimmer app:
1243
1432
 
1244
1433
  ### Hello, Label!
1245
1434
 
1435
+ Icons used in this sample were made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a>
1436
+
1246
1437
  Glimmer code (from [samples/hello/hello_label.rb](samples/hello/hello_label.rb)):
1247
1438
 
1248
1439
  ```ruby
@@ -1372,8 +1563,6 @@ root { |r|
1372
1563
  title 'Hello, Message Box!'
1373
1564
 
1374
1565
  frame {
1375
- grid sticky: 'nsew', padx: 15, pady: 15
1376
-
1377
1566
  button {
1378
1567
  text 'Please Click To Win a Surprise'
1379
1568
 
@@ -1425,8 +1614,6 @@ root { |r|
1425
1614
  }
1426
1615
 
1427
1616
  frame {
1428
- grid sticky: 'nsew', padx: 15, pady: 15
1429
-
1430
1617
  label {
1431
1618
  grid row: 0, column: 0
1432
1619
  text 'Result:'
@@ -1454,7 +1641,6 @@ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_message_box.rb
1454
1641
  Glimmer app:
1455
1642
 
1456
1643
  ![glimmer dsl tk screenshot sample hello message box](images/glimmer-dsl-tk-screenshot-sample-hello-message-box.png)
1457
- ![glimmer dsl tk screenshot sample hello message box open](images/glimmer-dsl-tk-screenshot-sample-hello-message-box-open.png)
1458
1644
 
1459
1645
  ### Hello, Combobox!
1460
1646
 
@@ -1683,6 +1869,10 @@ Glimmer app:
1683
1869
 
1684
1870
  ### Hello, Text!
1685
1871
 
1872
+ You may use the META+F shortcut to bring up the Find Dialog.
1873
+
1874
+ Icons used in this sample were made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a>
1875
+
1686
1876
  Glimmer code (from [samples/hello/hello_text.rb](samples/hello/hello_text.rb)):
1687
1877
 
1688
1878
  ```ruby
@@ -1692,14 +1882,47 @@ class HelloText
1692
1882
  include Glimmer
1693
1883
 
1694
1884
  COLOR_OPTIONS = %w[black purple blue green orange yellow red white].map(&:capitalize)
1695
- FOREGROUND_PROMPT = '<select foreground>'
1696
- BACKGROUND_PROMPT = '<select background>'
1885
+ FONT_FAMILY_OPTIONS = ::TkFont.families
1886
+ FOREGROUND_PROMPT = '<foreground>'
1887
+ BACKGROUND_PROMPT = '<background>'
1888
+ FONT_FAMILY_PROMPT = '<font family>'
1889
+ FONT_SIZE_PROMPT = '<font size>'
1697
1890
 
1698
1891
  def initialize
1699
1892
  @foreground = FOREGROUND_PROMPT
1700
1893
  @background = BACKGROUND_PROMPT
1894
+ @font_family = FONT_FAMILY_PROMPT
1895
+ @font_size = FONT_SIZE_PROMPT
1896
+ @document = <<~MULTI_LINE_STRING
1897
+ According to the National Post, a heavy metal-loving high school principal in Canada will be allowed to keep her job, days after a public campaign to oust her made headlines around the globe.
1898
+
1899
+ Parents at Eden High School in St. Catharines, Ontario launched a petition to remove principal Sharon Burns after discovering she's an IRON MAIDEN fan.
1900
+
1901
+ The petition, titled "Eden High School Principal, Sharon Burns, Needs to Be Transferred Immediately!" read, "We are deeply disturbed that the principal assigned to the school blatantly showed Satanic symbols and her allegiance to Satanic practices on her public social media platforms where all the students can see them under @edenprincipal (not her personal account)."
1902
+
1903
+ More than 500 people signed the petition to transfer Burns after she posted a picture of herself flashing the "devil horns" hand sign with a doll of the MAIDEN zombie mascot Eddie behind her as well as a personalized license plate reading "IRNMADEN" and a handwritten note that reads "Eddie 666" on a car's dashboard.
1904
+
1905
+
1906
+ The number 666 is used to represent the devil, and is featured prominently in MAIDEN's artwork by the band, whose classic third album is titled "The Number Of The Beast".
1907
+
1908
+ The petition was later updated to state that the demand for her transfer is not because of her love for metal, but for "openly displaying her own handmade sign with the 666 clearly displayed on it".
1909
+
1910
+ The creator of the original petition wrote: "Sharon knows full well what she did was simply inappropriate, unnecessary and not professional but has yet to publicly admit so and is willing to allow people to believe a completely different story, making very real concerns seem petty."
1911
+
1912
+ Meanwhile, a counter-petition supporting Burns garnered over 20,000 signatures.
1913
+
1914
+ "It is ridiculous that a couple of parents judge her role as a principal only based on an Instagram post. (About liking the band IRON MAIDEN. That's it.) Eden High School is a public school. Not a Christian school," the petition titled "We need Mrs Burns" stated. "She has made Eden a safe space for so many people. She spreads nothing but love and kindness."
1915
+
1916
+ After the complaints were aired, the District School Board of Niagara spoke with Burns and the parents who launched the petition, and the issue is over as far as the board is concerned, Kim Sweeney, the board's chief communications officer, told the National Post. No disciplinary action or policy changes were needed.
1917
+
1918
+ "Our belief is that taste in music is subjective and we support that both students and staff enjoy a wide variety of genres," Sweeney said.
1919
+
1920
+ The original petition has since been removed.
1921
+ MULTI_LINE_STRING
1701
1922
  end
1702
1923
 
1924
+ attr_accessor :document
1925
+
1703
1926
  attr_accessor :foreground
1704
1927
 
1705
1928
  def foreground_options
@@ -1712,15 +1935,65 @@ class HelloText
1712
1935
  [BACKGROUND_PROMPT] + COLOR_OPTIONS
1713
1936
  end
1714
1937
 
1938
+ attr_accessor :font_family
1939
+
1940
+ def font_family_options
1941
+ [FONT_FAMILY_PROMPT] + FONT_FAMILY_OPTIONS
1942
+ end
1943
+
1944
+ attr_accessor :font_size
1945
+
1946
+ def font_size_options
1947
+ [FONT_SIZE_PROMPT] + (9..64).to_a.map(&:to_s)
1948
+ end
1949
+
1715
1950
  def launch
1716
1951
  root {
1717
1952
  title 'Hello, Text!'
1953
+ width 1280
1954
+ height 800
1718
1955
 
1719
1956
  frame {
1720
1957
  grid row: 0, column: 0
1721
1958
 
1959
+ label {
1960
+ grid row: 0, column: 0, columnspan: 17
1961
+ text 'Select a region of text and then apply formatting from the toolbar'
1962
+ }
1963
+
1964
+ column_index = -1
1965
+
1966
+ combobox {
1967
+ grid row: 1, column: column_index += 1, column_weight: 1
1968
+ readonly true
1969
+ text <=> [self, :font_family, after_write: ->(value) { @text.toggle_selection_font_format('family', value == FONT_FAMILY_PROMPT ? 'Courier New' : value) }]
1970
+ }
1971
+
1972
+ combobox {
1973
+ grid row: 1, column: column_index += 1, column_weight: 1
1974
+ readonly true
1975
+ text <=> [self, :font_size, after_write: ->(value) { @text.toggle_selection_font_format('size', value == FONT_SIZE_PROMPT ? 13 : value) }]
1976
+ }
1977
+
1978
+ combobox {
1979
+ grid row: 1, column: column_index += 1, column_weight: 1
1980
+ readonly true
1981
+ text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value) }]
1982
+ }
1983
+
1984
+ combobox {
1985
+ grid row: 1, column: column_index += 1, column_weight: 1
1986
+ readonly true
1987
+ text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'white' : value) }]
1988
+ }
1989
+
1990
+ separator {
1991
+ grid row: 1, column: column_index += 1, column_weight: 0
1992
+ orient 'vertical'
1993
+ }
1994
+
1722
1995
  button {
1723
- grid row: 0, column: 0, column_weight: 0
1996
+ grid row: 1, column: column_index += 1, column_weight: 0
1724
1997
  text 'B'
1725
1998
  style font: {weight: 'bold'}
1726
1999
 
@@ -1730,7 +2003,7 @@ class HelloText
1730
2003
  }
1731
2004
 
1732
2005
  button {
1733
- grid row: 0, column: 1, column_weight: 0
2006
+ grid row: 1, column: column_index += 1, column_weight: 0
1734
2007
  text 'I'
1735
2008
  style font: {slant: 'italic'}
1736
2009
 
@@ -1740,7 +2013,7 @@ class HelloText
1740
2013
  }
1741
2014
 
1742
2015
  button {
1743
- grid row: 0, column: 2, column_weight: 0
2016
+ grid row: 1, column: column_index += 1, column_weight: 0
1744
2017
  text 'U'
1745
2018
  style font: {underline: true}
1746
2019
 
@@ -1749,48 +2022,113 @@ class HelloText
1749
2022
  end
1750
2023
  }
1751
2024
 
1752
- combobox {
1753
- grid row: 0, column: 4, column_weight: 1
1754
- readonly true
1755
- text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value) }]
2025
+ separator {
2026
+ grid row: 1, column: column_index += 1, column_weight: 0
2027
+ orient 'vertical'
1756
2028
  }
1757
2029
 
1758
- combobox {
1759
- grid row: 0, column: 5, column_weight: 1
1760
- readonly true
1761
- text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'black' : value) }]
1762
- }
1763
- }
1764
-
1765
- @text = text {
1766
- grid row: 1, column: 0, row_weight: 1
1767
- wrap 'word'
1768
- text <<~MULTI_LINE_STRING
1769
- According to the National Post, a heavy metal-loving high school principal in Canada will be allowed to keep her job, days after a public campaign to oust her made headlines around the globe.
1770
-
1771
- Parents at Eden High School in St. Catharines, Ontario launched a petition to remove principal Sharon Burns after discovering she's an IRON MAIDEN fan.
1772
-
1773
- The petition, titled "Eden High School Principal, Sharon Burns, Needs to Be Transferred Immediately!" read, "We are deeply disturbed that the principal assigned to the school blatantly showed Satanic symbols and her allegiance to Satanic practices on her public social media platforms where all the students can see them under @edenprincipal (not her personal account)."
1774
-
1775
- More than 500 people signed the petition to transfer Burns after she posted a picture of herself flashing the "devil horns" hand sign with a doll of the MAIDEN zombie mascot Eddie behind her as well as a personalized license plate reading "IRNMADEN" and a handwritten note that reads "Eddie 666" on a car's dashboard.
2030
+ button {
2031
+ grid row: 1, column: column_index += 1, column_weight: 0
2032
+ image File.expand_path("images/cut.png", __dir__), subsample: 32
1776
2033
 
2034
+ on('command') do
2035
+ @text.text_cut
2036
+ end
2037
+ }
2038
+
2039
+ button {
2040
+ grid row: 1, column: column_index += 1, column_weight: 0
2041
+ image File.expand_path("images/copy.png", __dir__), subsample: 32
1777
2042
 
1778
- The number 666 is used to represent the devil, and is featured prominently in MAIDEN's artwork by the band, whose classic third album is titled "The Number Of The Beast".
2043
+ on('command') do
2044
+ @text.text_copy
2045
+ end
2046
+ }
2047
+
2048
+ button {
2049
+ grid row: 1, column: column_index += 1, column_weight: 0
2050
+ image File.expand_path("images/paste.png", __dir__), subsample: 32
1779
2051
 
1780
- The petition was later updated to state that the demand for her transfer is not because of her love for metal, but for "openly displaying her own handmade sign with the 666 clearly displayed on it".
2052
+ on('command') do
2053
+ @text.text_paste
2054
+ end
2055
+ }
2056
+
2057
+ separator {
2058
+ grid row: 1, column: column_index += 1, column_weight: 0
2059
+ orient 'vertical'
2060
+ }
2061
+
2062
+ button {
2063
+ grid row: 1, column: column_index += 1, column_weight: 0
2064
+ image File.expand_path("images/align-left.png", __dir__), subsample: 32
1781
2065
 
1782
- The creator of the original petition wrote: "Sharon knows full well what she did was simply inappropriate, unnecessary and not professional but has yet to publicly admit so and is willing to allow people to believe a completely different story, making very real concerns seem petty."
2066
+ on('command') do
2067
+ @text.add_selection_format('justify', 'left')
2068
+ end
2069
+ }
2070
+
2071
+ button {
2072
+ grid row: 1, column: column_index += 1, column_weight: 0
2073
+ image File.expand_path("images/align-center.png", __dir__), subsample: 32
1783
2074
 
1784
- Meanwhile, a counter-petition supporting Burns garnered over 20,000 signatures.
2075
+ on('command') do
2076
+ @text.add_selection_format('justify', 'center')
2077
+ end
2078
+ }
2079
+
2080
+ button {
2081
+ grid row: 1, column: column_index += 1, column_weight: 0
2082
+ image File.expand_path("images/align-right.png", __dir__), subsample: 32
1785
2083
 
1786
- "It is ridiculous that a couple of parents judge her role as a principal only based on an Instagram post. (About liking the band IRON MAIDEN. That's it.) Eden High School is a public school. Not a Christian school," the petition titled "We need Mrs Burns" stated. "She has made Eden a safe space for so many people. She spreads nothing but love and kindness."
2084
+ on('command') do
2085
+ @text.add_selection_format('justify', 'right')
2086
+ end
2087
+ }
2088
+
2089
+ separator {
2090
+ grid row: 1, column: column_index += 1, column_weight: 0
2091
+ orient 'vertical'
2092
+ }
2093
+
2094
+ button {
2095
+ grid row: 1, column: column_index += 1, column_weight: 0
2096
+ image File.expand_path("images/undo.png", __dir__), subsample: 32
1787
2097
 
1788
- After the complaints were aired, the District School Board of Niagara spoke with Burns and the parents who launched the petition, and the issue is over as far as the board is concerned, Kim Sweeney, the board's chief communications officer, told the National Post. No disciplinary action or policy changes were needed.
2098
+ on('command') do
2099
+ @text.edit_undo
2100
+ end
2101
+ }
2102
+
2103
+ button {
2104
+ grid row: 1, column: column_index += 1, column_weight: 0
2105
+ image File.expand_path("images/redo.png", __dir__), subsample: 32
1789
2106
 
1790
- "Our belief is that taste in music is subjective and we support that both students and staff enjoy a wide variety of genres," Sweeney said.
2107
+ on('command') do
2108
+ @text.edit_redo
2109
+ end
2110
+ }
2111
+
2112
+ separator {
2113
+ grid row: 1, column: column_index += 1, column_weight: 0
2114
+ orient 'vertical'
2115
+ }
2116
+
2117
+ button {
2118
+ grid row: 1, column: column_index += 1, column_weight: 0
2119
+ image File.expand_path("images/picture.png", __dir__), subsample: 32
1791
2120
 
1792
- The original petition has since been removed.
1793
- MULTI_LINE_STRING
2121
+ on('command') do
2122
+ @text.get_open_file_to_insert_image
2123
+ end
2124
+ }
2125
+ }
2126
+
2127
+ @text = text {
2128
+ grid row: 1, column: 0, row_weight: 1
2129
+ wrap 'word'
2130
+ undo true
2131
+ value <=> [self, :document]
1794
2132
  }
1795
2133
  }.open
1796
2134
  end
@@ -1815,6 +2153,8 @@ Glimmer app:
1815
2153
 
1816
2154
  ![glimmer dsl tk screenshot sample hello text](images/glimmer-dsl-tk-screenshot-sample-hello-text.png)
1817
2155
 
2156
+ ![glimmer dsl tk screenshot sample hello text find dialog](images/glimmer-dsl-tk-screenshot-sample-hello-text-find-dialog.png)
2157
+
1818
2158
  ### Hello, Spinbox!
1819
2159
 
1820
2160
  Glimmer code (from [samples/hello/hello_spinbox.rb](samples/hello/hello_spinbox.rb)):
@@ -1972,22 +2312,356 @@ Glimmer app:
1972
2312
 
1973
2313
  ![glimmer dsl tk screenshot sample hello computed](images/glimmer-dsl-tk-screenshot-sample-hello-computed.png)
1974
2314
 
1975
- ## Help
2315
+ ### Hello, Drag and Drop!
1976
2316
 
1977
- ### Issues
2317
+ Glimmer code (from [samples/hello/hello_drag_and_drop.rb](samples/hello/hello_drag_and_drop.rb)):
1978
2318
 
1979
- You may submit [issues](https://github.com/AndyObtiva/glimmer/issues) on [GitHub](https://github.com/AndyObtiva/glimmer/issues).
2319
+ ```ruby
2320
+ require "glimmer-dsl-tk"
2321
+ require "glimmer/tk/drag_and_drop_extension"
1980
2322
 
1981
- [Click here to submit an issue.](https://github.com/AndyObtiva/glimmer/issues)
2323
+ include Glimmer
1982
2324
 
1983
- ### Chat
2325
+ root {
2326
+ title "Hello, Drag and Drop!"
2327
+ frame {
2328
+ padding 5
2329
+ labelframe {
2330
+ text "Drag sources"
2331
+ padding 5
2332
+ label {
2333
+ text "Entry"
2334
+ grid :row => 0, :column => 0
2335
+ }
2336
+ entry {
2337
+ text "Drag entry text"
2338
+ width 30
2339
+ grid :row => 0, :column => 1, :pady => 5, :sticky => "e"
2340
+ on_drag_start { |event|
2341
+ event.data = event.source.textvariable&.value
2342
+ event.source.configure(:cursor => "hand2")
2343
+ TkLabel.new(event.tooltip) {
2344
+ text event.data + " "
2345
+ bg "yellow"
2346
+ bitmap "warning"
2347
+ compound "right"
2348
+ }.pack
2349
+ }
2350
+ on_drag_motion { |event|
2351
+ if event.drop_accepted
2352
+ event.source.configure(:cursor => "hand1")
2353
+ else
2354
+ event.source.configure(:cursor => "hand2")
2355
+ end
2356
+ event.tooltip.geometry("+#{event.x_root + 10}+#{event.y_root - 4}")
2357
+ }
2358
+ }
2359
+ label {
2360
+ text "Label"
2361
+ grid :row => 1, :column => 0
2362
+ }
2363
+ label {
2364
+ text "Drag label text"
2365
+ width 30
2366
+ grid :row => 1, :column => 1, :pady => 10, :sticky => "e"
2367
+ drag_source true
2368
+ }
2369
+ label {
2370
+ text "Combobox"
2371
+ grid :row => 2, :column => 0
2372
+ }
2373
+ combobox {
2374
+ text "Spain"
2375
+ values %w[USA Canada Mexico Columbia UK Australia Germany Italy Spain]
2376
+ width 27
2377
+ grid :row => 2, :column => 1, :pady => 5, :sticky => "e"
2378
+ on_drag_start { |event|
2379
+ event.data = event.source.textvariable&.value
2380
+ }
2381
+ }
2382
+ label {
2383
+ text "Button"
2384
+ grid :row => 3, :column => 0
2385
+ }
2386
+ button {
2387
+ text "Drag it"
2388
+ grid :row => 3, :column => 1, :pady => 5, :sticky => "w"
2389
+ drag_source true
2390
+ }
2391
+ }
1984
2392
 
1985
- If you need live help, try to [![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)
2393
+ labelframe {
2394
+ text "Drop targets"
2395
+ grid :sticky => "nsew", :pady => 15
2396
+ padding 5
2397
+ label {
2398
+ text "Entry"
2399
+ grid :row => 0, :column => 0
2400
+ }
2401
+ entry {
2402
+ width 30
2403
+ grid :row => 0, :column => 1, :pady => 5, :sticky => "e"
2404
+ on_drop { |event|
2405
+ event.target.textvariable.value = event.data
2406
+ }
2407
+ }
2408
+ label {
2409
+ text "Label"
2410
+ grid :row => 1, :column => 0
2411
+ }
2412
+ label {
2413
+ width 30
2414
+ grid :row => 1, :column => 1, :pady => 10, :sticky => "e"
2415
+ borderwidth 2
2416
+ relief "solid"
2417
+ on_drop { |event|
2418
+ event.target.textvariable.value = event.data
2419
+ }
2420
+ }
2421
+ label {
2422
+ text "Combobox"
2423
+ grid :row => 2, :column => 0
2424
+ }
2425
+ combobox {
2426
+ width 27
2427
+ grid :row => 2, :column => 1, :pady => 5, :sticky => "e"
2428
+ on_drop { |event|
2429
+ event.target.textvariable.value = event.data
2430
+ }
2431
+ }
2432
+ label {
2433
+ text "Button"
2434
+ grid :row => 3, :column => 0
2435
+ }
2436
+ button {
2437
+ text "Drop here"
2438
+ grid :row => 3, :column => 1, :pady => 5, :sticky => "w"
2439
+ on_drop { |event|
2440
+ event.target.text = event.data
2441
+ }
2442
+ }
2443
+ label {
2444
+ text "Checkbutton"
2445
+ grid :row => 4, :column => 0
2446
+ }
2447
+ checkbutton {
2448
+ text "Drop here to destroy a widget\n(except button)"
2449
+ grid :row => 4, :column => 1, :pady => 5, :sticky => "w"
2450
+ on_drop { |event|
2451
+ event.target.text = event.data
2452
+ event.source.destroy unless event.source.is_a? Tk::Button
2453
+ }
2454
+ }
2455
+ }
2456
+ }
2457
+ }.open
2458
+ ```
2459
+
2460
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
2461
+
2462
+ ```
2463
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_drag_and_drop'"
2464
+ ```
2465
+
2466
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
2467
+
2468
+ ```
2469
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_drag_and_drop.rb
2470
+ ```
2471
+
2472
+ Glimmer app:
2473
+
2474
+ ![glimmer dsl tk screenshot sample hello drag and drop](images/glimmer-dsl-tk-screenshot-sample-hello-drag-and-drop.png)
2475
+
2476
+ ### Hello, Built-in Dialog!
2477
+
2478
+ Glimmer code (from [samples/hello/hello_built_in_dialog.rb](samples/hello/hello_built_in_dialog.rb)):
2479
+
2480
+ ```ruby
2481
+ require 'glimmer-dsl-tk'
2482
+
2483
+ include Glimmer
2484
+
2485
+ root { |w|
2486
+ title 'Hello, Built-in Dialog!'
2487
+ width 400
2488
+ height 400
2489
+ x 150
2490
+ y 150
2491
+
2492
+ frame {
2493
+ %w[get_open_file get_multiple_open_file get_save_file choose_directory choose_color].each do |dialog|
2494
+ button {
2495
+ text dialog.split('_').map(&:capitalize).join(' ')
2496
+
2497
+ on('command') do
2498
+ result = send(dialog, parent: w)
2499
+ @result_label.text = [result].flatten.join("\n")
2500
+ end
2501
+ }
2502
+ end
2503
+
2504
+ button {
2505
+ text 'Choose Font'
2506
+
2507
+ on('command') do
2508
+ choose_font(family: 'Courier New', size: '30', weight: 'bold') do |chosen_font|
2509
+ @result_label.text = chosen_font
2510
+ end
2511
+ end
2512
+ }
2513
+ }
2514
+
2515
+ frame {
2516
+ grid sticky: 'nsew', padx: 15, pady: 15
2517
+
2518
+ label {
2519
+ grid row: 0, column: 0
2520
+ text 'Result:'
2521
+ }
2522
+
2523
+ @result_label = label {
2524
+ grid row: 0, column: 1
2525
+ }
2526
+ }
2527
+ }.open
2528
+ ```
2529
+
2530
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
2531
+
2532
+ ```
2533
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_built_in_dialog'"
2534
+ ```
2535
+
2536
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
2537
+
2538
+ ```
2539
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_built_in_dialog.rb
2540
+ ```
2541
+
2542
+ Glimmer app:
2543
+
2544
+ ![glimmer dsl tk screenshot sample hello built in dialog 1](images/glimmer-dsl-tk-screenshot-sample-hello-built-in-dialog-get-open-file.png)
2545
+ ![glimmer dsl tk screenshot sample hello built in dialog 2](images/glimmer-dsl-tk-screenshot-sample-hello-built-in-dialog-get-open-file-done.png)
2546
+
2547
+ ![glimmer dsl tk screenshot sample hello built in dialog 3](images/glimmer-dsl-tk-screenshot-sample-hello-built-in-dialog-choose-color.png)
2548
+ ![glimmer dsl tk screenshot sample hello built in dialog 4](images/glimmer-dsl-tk-screenshot-sample-hello-built-in-dialog-choose-color-done.png)
2549
+
2550
+ ![glimmer dsl tk screenshot sample hello built in dialog 5](images/glimmer-dsl-tk-screenshot-sample-hello-built-in-dialog-choose-font.png)
2551
+ ![glimmer dsl tk screenshot sample hello built in dialog 6](images/glimmer-dsl-tk-screenshot-sample-hello-built-in-dialog-choose-font-done.png)
2552
+
2553
+ ### Hello, Separator!
2554
+
2555
+ Glimmer code (from [samples/hello/hello_separator.rb](samples/hello/hello_separator.rb)):
2556
+
2557
+ ```ruby
2558
+ require 'glimmer-dsl-tk'
2559
+
2560
+ include Glimmer
2561
+
2562
+ root {
2563
+ title 'Hello, Separator!'
2564
+ width 200
2565
+ height 200
2566
+
2567
+ label {
2568
+ grid row: 0, column: 0, min_width: 100, min_height: 100, column_weight: 0, sticky: 'nsew'
2569
+ text 'Label 1'
2570
+ anchor 'center'
2571
+ }
2572
+
2573
+ separator {
2574
+ grid row: 0, column: 1
2575
+ orient 'vertical'
2576
+ }
2577
+
2578
+ label {
2579
+ grid row: 0, column: 2, min_width: 100, min_height: 100, sticky: 'nsew'
2580
+ text 'Label 2'
2581
+ anchor 'center'
2582
+ }
2583
+
2584
+ separator {
2585
+ grid row: 1, column: 0, column_span: 3
2586
+ # orient 'horizontal' # default
2587
+ }
2588
+
2589
+ label {
2590
+ grid row: 2, column: 0, min_width: 100, min_height: 100, sticky: 'nsew'
2591
+ text 'Label 3'
2592
+ anchor 'center'
2593
+ }
2594
+
2595
+ separator {
2596
+ grid row: 2, column: 1
2597
+ orient 'vertical'
2598
+ }
2599
+
2600
+ label {
2601
+ grid row: 2, column: 2, min_width: 100, min_height: 100, sticky: 'nsew'
2602
+ text 'Label 4'
2603
+ anchor 'center'
2604
+ }
2605
+ }.open
2606
+ ```
2607
+
2608
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
2609
+
2610
+ ```
2611
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_separator'"
2612
+ ```
2613
+
2614
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
2615
+
2616
+ ```
2617
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_separator.rb
2618
+ ```
2619
+
2620
+ Glimmer app:
2621
+
2622
+ ![glimmer dsl tk screenshot sample hello separator](images/glimmer-dsl-tk-screenshot-sample-hello-separator.png)
2623
+
2624
+ ## Applications
2625
+
2626
+ ### Glimmer Tk Calculator
2627
+
2628
+ "I wanted to try how it feels to write an UI in glimmer-dsl-tk so I decided to write an alternative version of the [Glimmer Calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) that uses [Tk]([Tk](https://www.tcl.tk/)) and runs in the regular [MRI Ruby interpreter](https://www.ruby-lang.org/en/)." - [Ancor Gonzalez Sosa](https://github.com/ancorgs)
2629
+
2630
+ https://github.com/ancorgs/glimmer-tk-calculator
2631
+
2632
+ ![Glimmer Tk Calculator Screenshot](https://raw.githubusercontent.com/ancorgs/glimmer-tk-calculator/master/screenshot.png)
2633
+
2634
+ ### Y3network Ruby UI
2635
+
2636
+ https://github.com/ancorgs/y3network-ruby-ui
2637
+
2638
+ ### CryptoPunks GUI
2639
+
2640
+ This is a Graphical User Interface for the famous [cryptopunks Ruby gem](https://github.com/cryptopunksnotdead/cryptopunks/tree/master/cryptopunks).
2641
+
2642
+ https://github.com/AndyObtiva/cryptopunks-gui
2643
+
2644
+ ![CryptoPunks GUI Screenshot](https://raw.githubusercontent.com/AndyObtiva/cryptopunks-gui/master/screenshots/cryptopunks-gui-screenshot.png)
1986
2645
 
1987
2646
  ## Process
1988
2647
 
1989
2648
  [Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
1990
2649
 
2650
+ ## Resources
2651
+
2652
+ - [Tk Tutorial](https://tkdocs.com/tutorial/index.html)
2653
+ - [Code Master Blog](https://andymaleh.blogspot.com/search/label/Tk)
2654
+
2655
+ ## Help
2656
+
2657
+ ### Issues
2658
+
2659
+ If you encounter [issues](https://github.com/AndyObtiva/glimmer-dsl-tk/issues) that are not reported, discover missing features that are not mentioned in [TODO.md](TODO.md), or think up better ways to use [Tk](https://www.tcl.tk/) than what is possible with [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk), you may submit an [issue](https://github.com/AndyObtiva/glimmer-dsl-tk/issues/new) or [pull request](https://github.com/AndyObtiva/glimmer-dsl-tk/compare) on [GitHub](https://github.com).
2660
+
2661
+ ### Chat
2662
+
2663
+ If you need live help, try to [![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)
2664
+
1991
2665
  ## Planned Features and Feature Suggestions
1992
2666
 
1993
2667
  These features have been planned or suggested. You might see them in a future version of [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk). You are welcome to contribute more feature suggestions.
@@ -2005,6 +2679,7 @@ These features have been planned or suggested. You might see them in a future ve
2005
2679
  ## Contributors
2006
2680
 
2007
2681
  * [Andy Maleh](https://github.com/AndyObtiva) (Founder)
2682
+ * [vin1antme](https://github.com/vin1antme)
2008
2683
 
2009
2684
  [Click here to view contributor commits.](https://github.com/AndyObtiva/glimmer-dsl-tk/graphs/contributors)
2010
2685