glimmer-dsl-tk 0.0.28 → 0.0.29

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: 2da9cdf30a1b710a0122d360320ffe0300a1a325eba5cf35f4749005673b2f9d
4
- data.tar.gz: c58af78a953f2feb85dd639595e3a47ea69bcba2097f155124e3597c48080d88
3
+ metadata.gz: c1fcdcc1d27b712822692998523397ade9998b767e861b47f71cb09305d0590a
4
+ data.tar.gz: 7810abe93ea87970f241b1401e50c93303a571f753e4ef107753fabd40f5ebbf
5
5
  SHA512:
6
- metadata.gz: 7e3faf577f5abc1ca7b9e0597fc5e36f7b917c5afc3dbcc0bee99d8168ab5b30a5f571d73a495f7ca86c2e574e4c6e6272d0b83853081020d1ebce9c2b3d6f9c
7
- data.tar.gz: 741c9d95b80cff4c7666d78ce7ad0600e9227d5808982e5ea8a5728c39ad0e717148746febc5c57ba7c3d3896e4815ef096d7d41e3b6c52e46f566f5c0053353
6
+ metadata.gz: d622997fa2f4913ddda14fdab69fd26f40f97f83d7f8646be5a46c874dca53bbdaa73a7e884069a778ebfa2e6dadca3c1e5b61809a79a6b1cdd11236eac5272d
7
+ data.tar.gz: 97133b4cb58fce828ffa8f6d0c9b361c4681e19bffe4e752c1983e110150ac0d8dac6b464b622f649df68b987e1d3e469f1a7caf2defad2c402e1f405f78f8c4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.29
4
+
5
+ - Hello, Built-in Dialog! (demonstrating all built-in dialogs like get_open_file and choose_color)
6
+ - Hello, Separator!
7
+ - Improve Hello, Text! (toolbar buttons: insert image)
8
+ - Removed unnecessary `text` widget `text` attribute after realizing `value` does the same thing
9
+ - Support `text` widget data-binding on 'modified' event and use in Hello, Text!
10
+ - Support `text#insert_image(text_index, *image_args)`
11
+ - Support `text#get_open_file_to_insert_image(text_index = 'insert')` shortcut for doing both `get_open_file` and `insert_image` in one shot
12
+ - Support built-in dialogs: `get_open_file(options = nil)`, `get_multiple_open_file(options = nil)`, `get_save_file(options = nil)`, `get_multiple_save_file(options = nil)`, `choose_directory(options = nil)`, `choose_color(options = nil)`, `choose_font(initial_font_args) {|font| do_something_with_font(font) }`
13
+ - Support built-in dialog aliases: `open_file`, `multiple_open_file`, `save_file`
14
+ - Enhance `get_open_file`/`get_multiple_open_file` `filetypes` support to take a real Ruby hash instead of `['{Image Files} {.png}']`
15
+ - Support `grid` keyword arg `'column_span'` (with _) and `'row_span'` as aliases for `'columnspan'` and `'rowspan'`
16
+
3
17
  ## 0.0.28
4
18
 
5
19
  - Hello, Drag and Drop!
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.28
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.29
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)
@@ -75,6 +75,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
75
75
  - [Common Attributes](#common-attributes)
76
76
  - [Common Themed Widget States](#common-themed-widget-states)
77
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)
@@ -113,6 +115,8 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
113
115
  - [Hello, Spinbox!](#hello-spinbox)
114
116
  - [Hello, Computed!](#hello-computed)
115
117
  - [Hello, Drag and Drop!](#hello-drag-and-drop)
118
+ - [Hello, Built-in Dialog!](#hello-built-in-dialog)
119
+ - [Hello, Separator!](#hello-separator)
116
120
  - [Help](#help)
117
121
  - [Issues](#issues)
118
122
  - [Chat](#chat)
@@ -149,7 +153,7 @@ gem install glimmer-dsl-tk
149
153
 
150
154
  Add the following to `Gemfile`:
151
155
  ```
152
- gem 'glimmer-dsl-tk', '~> 0.0.28'
156
+ gem 'glimmer-dsl-tk', '~> 0.0.29'
153
157
  ```
154
158
 
155
159
  And, then run:
@@ -260,8 +264,14 @@ keyword(args) | attributes | event bindings & callbacks
260
264
  ------------- | ---------- | ---------
261
265
  `button` | `text`, `image` (optional keyword args: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`), `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `default` (`'active', 'normal'`) | `command {}`
262
266
  `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 {}`
267
+ `choose_color(options = nil)` | None | None
268
+ `choose_directory(options = nil)` | None | None
269
+ `choose_font(options = nil) {|font| ... }` | None | None
263
270
  `combobox` | `state`, `text` | `'ComboboxSelected'`
264
271
  `entry` | `width`, `text`, `validate`, `show` (`'none', 'focus', 'focusin', 'focusout', 'key', or 'all'`) | `'validate'`, `'invalid'`, `'change'`, `validatecommand {}`, `invalidcommand {}`
272
+ `get_multiple_open_file(options = nil)` | None | None
273
+ `get_open_file(options = nil)` | None | None
274
+ `get_save_file(options = nil)` | None | None
265
275
  `spinbox` | `text`, `from`, `to`, `increment`, `format`, [more attributes](https://tcl.tk/man/tcl8.6/TkCmd/text.htm#M116) | `command {}`, `'increment'`, `'decrement'`
266
276
  `frame(text: nil)` | `width`, `height`, `borderwidth`, `relief` (`'flat' (default), 'raised', 'sunken', 'solid', 'ridge', 'groove'`) | None
267
277
  `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
@@ -272,6 +282,9 @@ keyword(args) | attributes | event bindings & callbacks
272
282
  `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'`
273
283
  `text` | `text`, [many more attributes](https://tcl.tk/man/tcl8.6/TkCmd/text.htm#M116) | `'modified'`, `'selection'`
274
284
 
285
+ Options for `get_open_file` and `get_multiple_open_file` include:
286
+ - `filetypes`: `Hash` of `'Group Name' => '.ext'` entries (e.g. `filetypes: {'PNG Images' => '.png'}`
287
+
275
288
  #### Common Attributes
276
289
 
277
290
  - `grid`: `Hash` of `:row`, `:column`, `:padx`, `:pady`, `:sticky` (`'e', 'w', 'n', 's'` or any combination of direction letters)
@@ -322,9 +335,7 @@ keyword(args) | attributes | event bindings & callbacks
322
335
 
323
336
  #### Text API
324
337
 
325
- [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.
326
-
327
- 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.
338
+ 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.
328
339
 
329
340
  - `add_format(region_start, region_end, option, value)`
330
341
  - `remove_format(region_start, region_end, option, value)`
@@ -338,6 +349,8 @@ Also, the `text` widget is enhanced by [Glimmer DSL for Tk](https://rubygems.org
338
349
  - `add_selection_font_format(region_start, region_end, font_option, value)`
339
350
  - `remove_selection_font_format(region_start, region_end, font_option, value)`
340
351
  - `toggle_selection_font_format(region_start, region_end, font_option, value)`
352
+ - `text#insert_image(text_index, *image_args)`: inserts image into `text` `value` content at `text_index` location (e.g. `'insert'`)
353
+ - `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
341
354
 
342
355
  Available options:
343
356
 
@@ -381,6 +394,19 @@ Other useful built-in API methods:
381
394
 
382
395
  Check out the [Hello, Text!](#hello-text) sample for a good demonstration of the `text` widget features.
383
396
 
397
+ #### Drag and Drop API
398
+
399
+ Drag and drop works by simply designating a widget as a drag source with attribute `drag_source true`
400
+
401
+ Alternatively, add listeners:
402
+ - `on_drag_start {|event| ...}`: fires on drag start receiving an `event` arg to set `data` and configure `source`
403
+ - `on_drag_motion {|event| ...}`: fires on drag motion receiving an `event` arg to check `event#drop_accepted`, and configure `source` and `tooltip`
404
+
405
+ On the drop target, you simply define:
406
+ - `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.
407
+
408
+ Learn more at the [Hello, Drag and Drop!](#hello-drag-and-drop) sample.
409
+
384
410
  ### Smart Defaults and Conventions
385
411
 
386
412
  #### Event Bindings
@@ -466,6 +492,8 @@ Example:
466
492
  ```
467
493
 
468
494
  Extra convenience options may be passed to `grid` when using [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk):
495
+ - `column_span`: alias for `columnspan` keyword arg
496
+ - `row_span`: alias for `rowspan` keyword arg
469
497
  - `min_width`: alias for `columnminsize` being called on `TkGrid.columnconfigure`
470
498
  - `min_height`: alias for `rowminsize` being called on `TkGrid.rowconfigure`
471
499
  - `column_weight`: alias for `columnweight` being called on `TkGrid.columnconfigure`
@@ -578,6 +606,24 @@ It automatically handles all the Tk plumbing behind the scenes.
578
606
 
579
607
  More details can be found in [Hello, Entry!](#hello-entry) and [Hello, Computed!](#hello-computed) samples below.
580
608
 
609
+ ### Text Data-Binding
610
+
611
+ Example:
612
+
613
+ This assumes a `Person` model with a `biography` attribute.
614
+
615
+ ```ruby
616
+ text {
617
+ value <=> [person, :biography]
618
+ }
619
+ ```
620
+
621
+ That code binds the `value` of `text` to the `biography` attribute on the `person` model.
622
+
623
+ It automatically handles all the Tk plumbing behind the scenes.
624
+
625
+ More details can be found in [Hello, Text!](#hello-text) sample below.
626
+
581
627
  ### Spinbox Data-Binding
582
628
 
583
629
  Example:
@@ -698,6 +744,128 @@ ruby -r ./lib/glimmer-dsl-tk.rb samples/elaborate/meta_sample.rb
698
744
 
699
745
  ![glimmer dsl tk screenshot sample meta sample](images/glimmer-dsl-tk-screenshot-sample-elaborate-meta-sample.png)
700
746
 
747
+ Code:
748
+
749
+ ```ruby
750
+ require 'glimmer-dsl-tk'
751
+ require 'facets'
752
+ require 'fileutils'
753
+
754
+ class MetaSample
755
+ include Glimmer
756
+
757
+ attr_accessor :selected_sample_index
758
+
759
+ def initialize
760
+ @selected_sample_index = 0
761
+ end
762
+
763
+ def samples
764
+ if @samples.nil?
765
+ sample_files = Dir.glob(File.join(File.expand_path('../hello', __dir__), '**', 'hello_*.rb'))
766
+ sample_file_names = sample_files.map { |f| File.basename(f, '.rb') }
767
+ sample_file_names = sample_file_names.reject { |f| f == 'meta_sample' || f.match(/\d$/) }
768
+ @samples = sample_file_names.map { |f| f.underscore.titlecase }
769
+ end
770
+ @samples
771
+ end
772
+
773
+ def file_path_for(sample)
774
+ File.join(File.expand_path('../hello', __dir__), "#{sample.underscore}.rb")
775
+ end
776
+
777
+ def glimmer_dsl_tk_file
778
+ File.expand_path('../../lib/glimmer-dsl-tk', __dir__)
779
+ end
780
+
781
+ def selected_sample
782
+ samples[@selected_sample_index]
783
+ end
784
+
785
+ def run_sample(sample)
786
+ Thread.new do
787
+ command = "ruby -r #{glimmer_dsl_tk_file} #{sample} 2>&1"
788
+ result = ''
789
+ IO.popen(command) do |f|
790
+ f.each_line do |line|
791
+ result << line
792
+ puts line
793
+ $stdout.flush
794
+ end
795
+ end
796
+ ::Tk.after(100) do
797
+ message_box(parent: @root, title: 'Error Running Sample', message: result) if result.downcase.include?('error')
798
+ end
799
+ end
800
+ end
801
+
802
+ def launch
803
+ @root = root {
804
+ title 'Glimmer Meta-Sample'
805
+ width 1280
806
+ height 720
807
+
808
+ frame {
809
+ grid row: 0, column: 0, column_weight: 0, row_weight: 1
810
+
811
+ samples.each_with_index do |sample, index|
812
+ radiobutton {
813
+ text sample
814
+ variable <=> [self, :selected_sample_index, on_write: ->(v) {v ? index : selected_sample_index}, on_read: ->(v) {v == index}]
815
+
816
+ on('command') do
817
+ @selected_sample_index = index
818
+ @code_text.value = File.read(file_path_for(selected_sample))
819
+ end
820
+ }
821
+ end
822
+
823
+ frame {
824
+ button {
825
+ grid row: 0, column: 0
826
+ text 'Launch'
827
+
828
+ on('command') do
829
+ begin
830
+ parent_dir = File.join(Dir.home, '.glimmer-dsl-tk', 'samples', 'hello')
831
+ FileUtils.mkdir_p(parent_dir)
832
+ sample_file = File.join(parent_dir, "#{selected_sample.underscore}.rb")
833
+ File.write(sample_file, @code_text.value)
834
+ FileUtils.cp_r(File.expand_path('../../icons', __dir__), File.dirname(File.dirname(parent_dir)))
835
+ FileUtils.cp_r(File.expand_path('../hello/images', __dir__), parent_dir)
836
+ sample_namespace_directory = File.expand_path("../hello/#{selected_sample.underscore}", __dir__)
837
+ FileUtils.cp_r(sample_namespace_directory, parent_dir) if Dir.exist?(sample_namespace_directory)
838
+ run_sample(sample_file)
839
+ rescue => e
840
+ puts e.full_message
841
+ puts 'Unable to write code changes! Running original sample...'
842
+ run_sample(file_path_for(selected_sample))
843
+ end
844
+ end
845
+ }
846
+ button {
847
+ grid row: 0, column: 1
848
+ text 'Reset'
849
+
850
+ on('command') do
851
+ @code_text.value = File.read(file_path_for(selected_sample))
852
+ end
853
+ }
854
+ }
855
+ }
856
+
857
+ @code_text = text {
858
+ grid row: 0, column: 1, column_weight: 1
859
+ value File.read(file_path_for(selected_sample))
860
+ }
861
+ }
862
+ @root.open
863
+ end
864
+ end
865
+
866
+ MetaSample.new.launch
867
+ ```
868
+
701
869
  ### Hello, World!
702
870
 
703
871
  Glimmer code (from [samples/hello/hello_world.rb](samples/hello/hello_world.rb)):
@@ -1389,8 +1557,6 @@ root { |r|
1389
1557
  title 'Hello, Message Box!'
1390
1558
 
1391
1559
  frame {
1392
- grid sticky: 'nsew', padx: 15, pady: 15
1393
-
1394
1560
  button {
1395
1561
  text 'Please Click To Win a Surprise'
1396
1562
 
@@ -1442,8 +1608,6 @@ root { |r|
1442
1608
  }
1443
1609
 
1444
1610
  frame {
1445
- grid sticky: 'nsew', padx: 15, pady: 15
1446
-
1447
1611
  label {
1448
1612
  grid row: 0, column: 0
1449
1613
  text 'Result:'
@@ -1471,7 +1635,6 @@ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_message_box.rb
1471
1635
  Glimmer app:
1472
1636
 
1473
1637
  ![glimmer dsl tk screenshot sample hello message box](images/glimmer-dsl-tk-screenshot-sample-hello-message-box.png)
1474
- ![glimmer dsl tk screenshot sample hello message box open](images/glimmer-dsl-tk-screenshot-sample-hello-message-box-open.png)
1475
1638
 
1476
1639
  ### Hello, Combobox!
1477
1640
 
@@ -1711,12 +1874,17 @@ class HelloText
1711
1874
  include Glimmer
1712
1875
 
1713
1876
  COLOR_OPTIONS = %w[black purple blue green orange yellow red white].map(&:capitalize)
1714
- FOREGROUND_PROMPT = '<select foreground>'
1715
- BACKGROUND_PROMPT = '<select background>'
1877
+ FONT_FAMILY_OPTIONS = ::TkFont.families
1878
+ FOREGROUND_PROMPT = '<foreground>'
1879
+ BACKGROUND_PROMPT = '<background>'
1880
+ FONT_FAMILY_PROMPT = '<font family>'
1881
+ FONT_SIZE_PROMPT = '<font size>'
1716
1882
 
1717
1883
  def initialize
1718
1884
  @foreground = FOREGROUND_PROMPT
1719
1885
  @background = BACKGROUND_PROMPT
1886
+ @font_family = FONT_FAMILY_PROMPT
1887
+ @font_size = FONT_SIZE_PROMPT
1720
1888
  end
1721
1889
 
1722
1890
  attr_accessor :foreground
@@ -1731,6 +1899,18 @@ class HelloText
1731
1899
  [BACKGROUND_PROMPT] + COLOR_OPTIONS
1732
1900
  end
1733
1901
 
1902
+ attr_accessor :font_family
1903
+
1904
+ def font_family_options
1905
+ [FONT_FAMILY_PROMPT] + FONT_FAMILY_OPTIONS
1906
+ end
1907
+
1908
+ attr_accessor :font_size
1909
+
1910
+ def font_size_options
1911
+ [FONT_SIZE_PROMPT] + (9..64).to_a.map(&:to_s)
1912
+ end
1913
+
1734
1914
  def launch
1735
1915
  root {
1736
1916
  title 'Hello, Text!'
@@ -1738,8 +1918,39 @@ class HelloText
1738
1918
  frame {
1739
1919
  grid row: 0, column: 0
1740
1920
 
1921
+ column_index = -1
1922
+
1923
+ combobox {
1924
+ grid row: 0, column: column_index += 1, column_weight: 1
1925
+ readonly true
1926
+ text <=> [self, :font_family, after_write: ->(value) { @text.toggle_selection_font_format('family', value == FONT_FAMILY_PROMPT ? 'Courier New' : value) }]
1927
+ }
1928
+
1929
+ combobox {
1930
+ grid row: 0, column: column_index += 1, column_weight: 1
1931
+ readonly true
1932
+ text <=> [self, :font_size, after_write: ->(value) { @text.toggle_selection_font_format('size', value == FONT_SIZE_PROMPT ? 13 : value) }]
1933
+ }
1934
+
1935
+ combobox {
1936
+ grid row: 0, column: column_index += 1, column_weight: 1
1937
+ readonly true
1938
+ text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value) }]
1939
+ }
1940
+
1941
+ combobox {
1942
+ grid row: 0, column: column_index += 1, column_weight: 1
1943
+ readonly true
1944
+ text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'white' : value) }]
1945
+ }
1946
+
1947
+ separator {
1948
+ grid row: 0, column: column_index += 1, column_weight: 0
1949
+ orient 'vertical'
1950
+ }
1951
+
1741
1952
  button {
1742
- grid row: 0, column: 0, column_weight: 0
1953
+ grid row: 0, column: column_index += 1, column_weight: 0
1743
1954
  text 'B'
1744
1955
  style font: {weight: 'bold'}
1745
1956
 
@@ -1749,7 +1960,7 @@ class HelloText
1749
1960
  }
1750
1961
 
1751
1962
  button {
1752
- grid row: 0, column: 1, column_weight: 0
1963
+ grid row: 0, column: column_index += 1, column_weight: 0
1753
1964
  text 'I'
1754
1965
  style font: {slant: 'italic'}
1755
1966
 
@@ -1759,7 +1970,7 @@ class HelloText
1759
1970
  }
1760
1971
 
1761
1972
  button {
1762
- grid row: 0, column: 2, column_weight: 0
1973
+ grid row: 0, column: column_index += 1, column_weight: 0
1763
1974
  text 'U'
1764
1975
  style font: {underline: true}
1765
1976
 
@@ -1768,23 +1979,67 @@ class HelloText
1768
1979
  end
1769
1980
  }
1770
1981
 
1771
- combobox {
1772
- grid row: 0, column: 4, column_weight: 1
1773
- readonly true
1774
- text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value) }]
1982
+ separator {
1983
+ grid row: 0, column: column_index += 1, column_weight: 0
1984
+ orient 'vertical'
1775
1985
  }
1776
1986
 
1777
- combobox {
1778
- grid row: 0, column: 5, column_weight: 1
1779
- readonly true
1780
- text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'black' : value) }]
1987
+ button {
1988
+ grid row: 0, column: column_index += 1, column_weight: 0
1989
+ image File.expand_path("images/cut.png", __dir__), subsample: 32
1990
+
1991
+ on('command') do
1992
+ @text.text_cut
1993
+ end
1994
+ }
1995
+
1996
+ button {
1997
+ grid row: 0, column: column_index += 1, column_weight: 0
1998
+ image File.expand_path("images/copy.png", __dir__), subsample: 32
1999
+
2000
+ on('command') do
2001
+ @text.text_copy
2002
+ end
2003
+ }
2004
+
2005
+ button {
2006
+ grid row: 0, column: column_index += 1, column_weight: 0
2007
+ image File.expand_path("images/paste.png", __dir__), subsample: 32
2008
+
2009
+ on('command') do
2010
+ @text.text_paste
2011
+ end
2012
+ }
2013
+
2014
+ separator {
2015
+ grid row: 0, column: column_index += 1, column_weight: 0
2016
+ orient 'vertical'
2017
+ }
2018
+
2019
+ button {
2020
+ grid row: 0, column: column_index += 1, column_weight: 0
2021
+ image File.expand_path("images/undo.png", __dir__), subsample: 32
2022
+
2023
+ on('command') do
2024
+ @text.edit_undo
2025
+ end
2026
+ }
2027
+
2028
+ button {
2029
+ grid row: 0, column: column_index += 1, column_weight: 0
2030
+ image File.expand_path("images/redo.png", __dir__), subsample: 32
2031
+
2032
+ on('command') do
2033
+ @text.edit_redo
2034
+ end
1781
2035
  }
1782
2036
  }
1783
2037
 
1784
2038
  @text = text {
1785
2039
  grid row: 1, column: 0, row_weight: 1
1786
2040
  wrap 'word'
1787
- text <<~MULTI_LINE_STRING
2041
+ undo true
2042
+ value <<~MULTI_LINE_STRING
1788
2043
  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.
1789
2044
 
1790
2045
  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.
@@ -2152,6 +2407,154 @@ Glimmer app:
2152
2407
 
2153
2408
  ![glimmer dsl tk screenshot sample hello drag and drop](images/glimmer-dsl-tk-screenshot-sample-hello-drag-and-drop.png)
2154
2409
 
2410
+ ### Hello, Built-in Dialog!
2411
+
2412
+ Glimmer code (from [samples/hello/hello_built_in_dialog.rb](samples/hello/hello_built_in_dialog.rb)):
2413
+
2414
+ ```ruby
2415
+ require 'glimmer-dsl-tk'
2416
+
2417
+ include Glimmer
2418
+
2419
+ root { |w|
2420
+ title 'Hello, Built-in Dialog!'
2421
+ width 400
2422
+ height 400
2423
+ x 150
2424
+ y 150
2425
+
2426
+ frame {
2427
+ %w[get_open_file get_multiple_open_file get_save_file choose_directory choose_color].each do |dialog|
2428
+ button {
2429
+ text dialog.split('_').map(&:capitalize).join(' ')
2430
+
2431
+ on('command') do
2432
+ result = send(dialog, parent: w)
2433
+ @result_label.text = [result].flatten.join("\n")
2434
+ end
2435
+ }
2436
+ end
2437
+
2438
+ button {
2439
+ text 'Choose Font'
2440
+
2441
+ on('command') do
2442
+ choose_font(family: 'Courier New', size: '30', weight: 'bold') do |chosen_font|
2443
+ @result_label.text = chosen_font(parent: w)
2444
+ end
2445
+ end
2446
+ }
2447
+ }
2448
+
2449
+ frame {
2450
+ grid sticky: 'nsew', padx: 15, pady: 15
2451
+
2452
+ label {
2453
+ grid row: 0, column: 0
2454
+ text 'Result:'
2455
+ }
2456
+
2457
+ @result_label = label {
2458
+ grid row: 0, column: 1
2459
+ }
2460
+ }
2461
+ }.open
2462
+ ```
2463
+
2464
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
2465
+
2466
+ ```
2467
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_built_in_dialog'"
2468
+ ```
2469
+
2470
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
2471
+
2472
+ ```
2473
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_built_in_dialog.rb
2474
+ ```
2475
+
2476
+ Glimmer app:
2477
+
2478
+ ![glimmer dsl tk screenshot sample hello built in dialog 1](images/glimmer-dsl-tk-screenshot-sample-hello-built-in-dialog-get-open-file.png)
2479
+ ![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)
2480
+
2481
+ ![glimmer dsl tk screenshot sample hello built in dialog 3](images/glimmer-dsl-tk-screenshot-sample-hello-built-in-dialog-choose-color.png)
2482
+ ![glimmer dsl tk screenshot sample hello built in dialog 4](images/glimmer-dsl-tk-screenshot-sample-hello-built-in-dialog-choose-color-done.png)
2483
+
2484
+ ![glimmer dsl tk screenshot sample hello built in dialog 5](images/glimmer-dsl-tk-screenshot-sample-hello-built-in-dialog-choose-font.png)
2485
+ ![glimmer dsl tk screenshot sample hello built in dialog 6](images/glimmer-dsl-tk-screenshot-sample-hello-built-in-dialog-choose-font-done.png)
2486
+
2487
+ ### Hello, Separator!
2488
+
2489
+ Glimmer code (from [samples/hello/hello_separator.rb](samples/hello/hello_separator.rb)):
2490
+
2491
+ ```ruby
2492
+ require 'glimmer-dsl-tk'
2493
+
2494
+ include Glimmer
2495
+
2496
+ root {
2497
+ title 'Hello, Separator!'
2498
+ width 200
2499
+ height 200
2500
+
2501
+ label {
2502
+ grid row: 0, column: 0, min_width: 100, min_height: 100, column_weight: 0, sticky: 'nsew'
2503
+ text 'Label 1'
2504
+ anchor 'center'
2505
+ }
2506
+
2507
+ separator {
2508
+ grid row: 0, column: 1
2509
+ orient 'vertical'
2510
+ }
2511
+
2512
+ label {
2513
+ grid row: 0, column: 2, min_width: 100, min_height: 100, sticky: 'nsew'
2514
+ text 'Label 2'
2515
+ anchor 'center'
2516
+ }
2517
+
2518
+ separator {
2519
+ grid row: 1, column: 0, column_span: 3
2520
+ orient 'horizontal'
2521
+ }
2522
+
2523
+ label {
2524
+ grid row: 2, column: 0, min_width: 100, min_height: 100, sticky: 'nsew'
2525
+ text 'Label 3'
2526
+ anchor 'center'
2527
+ }
2528
+
2529
+ separator {
2530
+ grid row: 2, column: 1
2531
+ orient 'vertical'
2532
+ }
2533
+
2534
+ label {
2535
+ grid row: 2, column: 2, min_width: 100, min_height: 100, sticky: 'nsew'
2536
+ text 'Label 4'
2537
+ anchor 'center'
2538
+ }
2539
+ }.open
2540
+ ```
2541
+
2542
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
2543
+
2544
+ ```
2545
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_separator'"
2546
+ ```
2547
+
2548
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
2549
+
2550
+ ```
2551
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_separator.rb
2552
+ ```
2553
+
2554
+ Glimmer app:
2555
+
2556
+ ![glimmer dsl tk screenshot sample hello separator](images/glimmer-dsl-tk-screenshot-sample-hello-separator.png)
2557
+
2155
2558
  ## Help
2156
2559
 
2157
2560
  ### Issues
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.28
1
+ 0.0.29
Binary file
@@ -0,0 +1,57 @@
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'
23
+ require 'glimmer/dsl/expression'
24
+
25
+ module Glimmer
26
+ module DSL
27
+ module Tk
28
+ class BuiltInDialogExpression < Expression
29
+ def can_interpret?(parent, keyword, *args, &block)
30
+ keyword = "get_#{keyword}" if keyword.start_with?('open')
31
+ (keyword.start_with?('get') or keyword.start_with?('choose')) and
32
+ (
33
+ (block.nil? and ::Tk.respond_to?(keyword.camelcase)) or
34
+ keyword == 'choose_font'
35
+ )
36
+ end
37
+
38
+ def interpret(parent, keyword, *args, &block)
39
+ if args.first.is_a?(Hash)
40
+ options = args.first.symbolize_keys
41
+ options[:filetypes] = options.delete(:file_types) if options.keys.include?(:file_types)
42
+ options[:filetypes] = options[:filetypes].map { |key, value| "{#{key}} {#{value}}" } if options[:filetypes].is_a?(Hash)
43
+ options[:parent] = options[:parent].tk if options[:parent].is_a?(Glimmer::Tk::RootProxy)
44
+ args[0] = options
45
+ end
46
+ keyword = "get_#{keyword}" if keyword.start_with?('open') || keyword.start_with?('save') || keyword.start_with?('multiple')
47
+ if keyword == 'choose_font'
48
+ TkFont::Fontchooser.configure(:font => args, :command => block)
49
+ TkFont::Fontchooser.show
50
+ else
51
+ ::Tk.send(keyword.camelcase, *args)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -42,6 +42,7 @@ module Glimmer
42
42
  attribute
43
43
  shine_data_binding
44
44
  widget
45
+ built_in_dialog
45
46
  ]
46
47
  )
47
48
  end
@@ -43,22 +43,6 @@ module Glimmer
43
43
  end
44
44
  end
45
45
 
46
- def text=(value)
47
- if value != @text
48
- if @text && value.start_with?(@text)
49
- insert('end', value[@text.size..-1])
50
- else
51
- delete('1.0', 'end')
52
- insert('end', value)
53
- end
54
- @text = value
55
- end
56
- end
57
-
58
- def text
59
- @text = get("1.0", 'end')
60
- end
61
-
62
46
  def add_selection_format(option, value)
63
47
  process_selection_ranges { |range_start, range_end| add_format(range_start, range_end, option, value) }
64
48
  end
@@ -158,7 +142,7 @@ module Glimmer
158
142
  end
159
143
 
160
144
  def applied_font_format_tags_and_regions(region_start, region_end)
161
- lines = text.split("\n")
145
+ lines = value.split("\n")
162
146
  tags_and_regions = []
163
147
  all_tag_names = @tk.tag_names - ['sel']
164
148
  (region_start.to_i..region_end.to_i).each do |line_number|
@@ -332,8 +316,17 @@ module Glimmer
332
316
  region1_parts.last.to_i >= region2_parts.last.to_i
333
317
  end
334
318
 
335
- def clone_font(font)
336
- ::TkFont.new(Hash[font.actual])
319
+ def insert_image(text_index, *image_args)
320
+ TkTextImage.new(@tk, 'insert', :image => image_argument(image_args))
321
+ end
322
+
323
+ def get_open_file_to_insert_image(text_index = 'insert')
324
+ image_filename = Glimmer::DSL::Tk::BuiltInDialogExpression.new.interpret(nil, 'get_open_file', filetypes: {
325
+ 'PNG Images' => '.png',
326
+ 'Gif Images' => '.gif',
327
+ 'PPM Images' => '.ppm'
328
+ })
329
+ insert_image('insert', image_filename) unless image_filename.nil? || image_filename.to_s.empty?
337
330
  end
338
331
 
339
332
  private
@@ -345,6 +338,10 @@ module Glimmer
345
338
  self.padx = 5
346
339
  self.pady = 5
347
340
  end
341
+
342
+ def clone_font(font)
343
+ ::TkFont.new(Hash[font.actual])
344
+ end
348
345
  end
349
346
  end
350
347
  end
@@ -228,6 +228,8 @@ module Glimmer
228
228
  def grid(options = {})
229
229
  options = options.stringify_keys
230
230
  index_in_parent = @parent_proxy.children.index(self)
231
+ options['rowspan'] = options.delete('row_span') if options.keys.include?('row_span')
232
+ options['columnspan'] = options.delete('column_span') if options.keys.include?('column_span')
231
233
  options['rowweight'] = options.delete('row_weight') if options.keys.include?('row_weight')
232
234
  options['columnweight'] = options.delete('column_weight') if options.keys.include?('column_weight')
233
235
  options['columnweight'] = options['rowweight'] = options.delete('weight') if options.keys.include?('weight')
@@ -379,9 +381,9 @@ module Glimmer
379
381
  end,
380
382
  },
381
383
  ::Tk::Text => {
382
- 'text' => lambda do |observer|
384
+ 'value' => lambda do |observer|
383
385
  handle_listener('modified') do
384
- observer.call(text)
386
+ observer.call(value)
385
387
  end
386
388
  end,
387
389
  },
@@ -422,6 +424,7 @@ module Glimmer
422
424
  begin
423
425
  @tk.bind(listener_name, &listener)
424
426
  rescue => e
427
+ Glimmer::Config.logger.debug {"Unable to bind to #{listener_name} .. attempting to surround with <>"}
425
428
  Glimmer::Config.logger.debug {e.full_message}
426
429
  listener_name = "<#{listener_name}" if !listener_name.start_with?('<')
427
430
  listener_name = "#{listener_name}>" if !listener_name.end_with?('>')
@@ -87,7 +87,7 @@ class MetaSample
87
87
 
88
88
  on('command') do
89
89
  @selected_sample_index = index
90
- @code_text.text = File.read(file_path_for(selected_sample))
90
+ @code_text.value = File.read(file_path_for(selected_sample))
91
91
  end
92
92
  }
93
93
  end
@@ -102,7 +102,7 @@ class MetaSample
102
102
  parent_dir = File.join(Dir.home, '.glimmer-dsl-tk', 'samples', 'hello')
103
103
  FileUtils.mkdir_p(parent_dir)
104
104
  sample_file = File.join(parent_dir, "#{selected_sample.underscore}.rb")
105
- File.write(sample_file, @code_text.text)
105
+ File.write(sample_file, @code_text.value)
106
106
  FileUtils.cp_r(File.expand_path('../../icons', __dir__), File.dirname(File.dirname(parent_dir)))
107
107
  FileUtils.cp_r(File.expand_path('../hello/images', __dir__), parent_dir)
108
108
  sample_namespace_directory = File.expand_path("../hello/#{selected_sample.underscore}", __dir__)
@@ -120,7 +120,7 @@ class MetaSample
120
120
  text 'Reset'
121
121
 
122
122
  on('command') do
123
- @code_text.text = File.read(file_path_for(selected_sample))
123
+ @code_text.value = File.read(file_path_for(selected_sample))
124
124
  end
125
125
  }
126
126
  }
@@ -128,7 +128,7 @@ class MetaSample
128
128
 
129
129
  @code_text = text {
130
130
  grid row: 0, column: 1, column_weight: 1
131
- text File.read(file_path_for(selected_sample))
131
+ value File.read(file_path_for(selected_sample))
132
132
  }
133
133
  }
134
134
  @root.open
@@ -0,0 +1,68 @@
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 { |w|
27
+ title 'Hello, Built-in Dialog!'
28
+ width 400
29
+ height 400
30
+ x 150
31
+ y 150
32
+
33
+ frame {
34
+ %w[get_open_file get_multiple_open_file get_save_file choose_directory choose_color].each do |dialog|
35
+ button {
36
+ text dialog.split('_').map(&:capitalize).join(' ')
37
+
38
+ on('command') do
39
+ result = send(dialog, parent: w)
40
+ @result_label.text = [result].flatten.join("\n")
41
+ end
42
+ }
43
+ end
44
+
45
+ button {
46
+ text 'Choose Font'
47
+
48
+ on('command') do
49
+ choose_font(family: 'Courier New', size: '30', weight: 'bold') do |chosen_font|
50
+ @result_label.text = chosen_font(parent: w)
51
+ end
52
+ end
53
+ }
54
+ }
55
+
56
+ frame {
57
+ grid sticky: 'nsew', padx: 15, pady: 15
58
+
59
+ label {
60
+ grid row: 0, column: 0
61
+ text 'Result:'
62
+ }
63
+
64
+ @result_label = label {
65
+ grid row: 0, column: 1
66
+ }
67
+ }
68
+ }.open
@@ -27,8 +27,6 @@ root { |r|
27
27
  title 'Hello, Message Box!'
28
28
 
29
29
  frame {
30
- grid sticky: 'nsew', padx: 15, pady: 15
31
-
32
30
  button {
33
31
  text 'Please Click To Win a Surprise'
34
32
 
@@ -80,8 +78,6 @@ root { |r|
80
78
  }
81
79
 
82
80
  frame {
83
- grid sticky: 'nsew', padx: 15, pady: 15
84
-
85
81
  label {
86
82
  grid row: 0, column: 0
87
83
  text 'Result:'
@@ -0,0 +1,69 @@
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, Separator!'
28
+ width 200
29
+ height 200
30
+
31
+ label {
32
+ grid row: 0, column: 0, min_width: 100, min_height: 100, column_weight: 0, sticky: 'nsew'
33
+ text 'Label 1'
34
+ anchor 'center'
35
+ }
36
+
37
+ separator {
38
+ grid row: 0, column: 1
39
+ orient 'vertical'
40
+ }
41
+
42
+ label {
43
+ grid row: 0, column: 2, min_width: 100, min_height: 100, sticky: 'nsew'
44
+ text 'Label 2'
45
+ anchor 'center'
46
+ }
47
+
48
+ separator {
49
+ grid row: 1, column: 0, column_span: 3
50
+ orient 'horizontal'
51
+ }
52
+
53
+ label {
54
+ grid row: 2, column: 0, min_width: 100, min_height: 100, sticky: 'nsew'
55
+ text 'Label 3'
56
+ anchor 'center'
57
+ }
58
+
59
+ separator {
60
+ grid row: 2, column: 1
61
+ orient 'vertical'
62
+ }
63
+
64
+ label {
65
+ grid row: 2, column: 2, min_width: 100, min_height: 100, sticky: 'nsew'
66
+ text 'Label 4'
67
+ anchor 'center'
68
+ }
69
+ }.open
@@ -36,8 +36,36 @@ class HelloText
36
36
  @background = BACKGROUND_PROMPT
37
37
  @font_family = FONT_FAMILY_PROMPT
38
38
  @font_size = FONT_SIZE_PROMPT
39
+ @document = <<~MULTI_LINE_STRING
40
+ 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.
41
+
42
+ 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.
43
+
44
+ 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)."
45
+
46
+ 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.
47
+
48
+
49
+ 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".
50
+
51
+ 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".
52
+
53
+ 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."
54
+
55
+ Meanwhile, a counter-petition supporting Burns garnered over 20,000 signatures.
56
+
57
+ "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."
58
+
59
+ 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.
60
+
61
+ "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.
62
+
63
+ The original petition has since been removed.
64
+ MULTI_LINE_STRING
39
65
  end
40
66
 
67
+ attr_accessor :document
68
+
41
69
  attr_accessor :foreground
42
70
 
43
71
  def foreground_options
@@ -69,37 +97,44 @@ class HelloText
69
97
  frame {
70
98
  grid row: 0, column: 0
71
99
 
100
+ label {
101
+ grid row: 0, column: 0, columnspan: 17
102
+ text 'Select a region of text and then apply formatting from the toolbar'
103
+ }
104
+
105
+ column_index = -1
106
+
72
107
  combobox {
73
- grid row: 0, column: 0, column_weight: 1
108
+ grid row: 1, column: column_index += 1, column_weight: 1
74
109
  readonly true
75
110
  text <=> [self, :font_family, after_write: ->(value) { @text.toggle_selection_font_format('family', value == FONT_FAMILY_PROMPT ? 'Courier New' : value) }]
76
111
  }
77
112
 
78
113
  combobox {
79
- grid row: 0, column: 1, column_weight: 1
114
+ grid row: 1, column: column_index += 1, column_weight: 1
80
115
  readonly true
81
116
  text <=> [self, :font_size, after_write: ->(value) { @text.toggle_selection_font_format('size', value == FONT_SIZE_PROMPT ? 13 : value) }]
82
117
  }
83
118
 
84
119
  combobox {
85
- grid row: 0, column: 2, column_weight: 1
120
+ grid row: 1, column: column_index += 1, column_weight: 1
86
121
  readonly true
87
122
  text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value) }]
88
123
  }
89
124
 
90
125
  combobox {
91
- grid row: 0, column: 3, column_weight: 1
126
+ grid row: 1, column: column_index += 1, column_weight: 1
92
127
  readonly true
93
128
  text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'white' : value) }]
94
129
  }
95
130
 
96
131
  separator {
97
- grid row: 0, column: 4, column_weight: 0
132
+ grid row: 1, column: column_index += 1, column_weight: 0
98
133
  orient 'vertical'
99
134
  }
100
135
 
101
136
  button {
102
- grid row: 0, column: 5, column_weight: 0
137
+ grid row: 1, column: column_index += 1, column_weight: 0
103
138
  text 'B'
104
139
  style font: {weight: 'bold'}
105
140
 
@@ -109,7 +144,7 @@ class HelloText
109
144
  }
110
145
 
111
146
  button {
112
- grid row: 0, column: 6, column_weight: 0
147
+ grid row: 1, column: column_index += 1, column_weight: 0
113
148
  text 'I'
114
149
  style font: {slant: 'italic'}
115
150
 
@@ -119,7 +154,7 @@ class HelloText
119
154
  }
120
155
 
121
156
  button {
122
- grid row: 0, column: 7, column_weight: 0
157
+ grid row: 1, column: column_index += 1, column_weight: 0
123
158
  text 'U'
124
159
  style font: {underline: true}
125
160
 
@@ -129,12 +164,12 @@ class HelloText
129
164
  }
130
165
 
131
166
  separator {
132
- grid row: 0, column: 8, column_weight: 0
167
+ grid row: 1, column: column_index += 1, column_weight: 0
133
168
  orient 'vertical'
134
169
  }
135
170
 
136
171
  button {
137
- grid row: 0, column: 9, column_weight: 0
172
+ grid row: 1, column: column_index += 1, column_weight: 0
138
173
  image File.expand_path("images/cut.png", __dir__), subsample: 32
139
174
 
140
175
  on('command') do
@@ -143,7 +178,7 @@ class HelloText
143
178
  }
144
179
 
145
180
  button {
146
- grid row: 0, column: 10, column_weight: 0
181
+ grid row: 1, column: column_index += 1, column_weight: 0
147
182
  image File.expand_path("images/copy.png", __dir__), subsample: 32
148
183
 
149
184
  on('command') do
@@ -152,7 +187,7 @@ class HelloText
152
187
  }
153
188
 
154
189
  button {
155
- grid row: 0, column: 11, column_weight: 0
190
+ grid row: 1, column: column_index += 1, column_weight: 0
156
191
  image File.expand_path("images/paste.png", __dir__), subsample: 32
157
192
 
158
193
  on('command') do
@@ -161,12 +196,12 @@ class HelloText
161
196
  }
162
197
 
163
198
  separator {
164
- grid row: 0, column: 12, column_weight: 0
199
+ grid row: 1, column: column_index += 1, column_weight: 0
165
200
  orient 'vertical'
166
201
  }
167
202
 
168
203
  button {
169
- grid row: 0, column: 13, column_weight: 1
204
+ grid row: 1, column: column_index += 1, column_weight: 0
170
205
  image File.expand_path("images/undo.png", __dir__), subsample: 32
171
206
 
172
207
  on('command') do
@@ -175,45 +210,34 @@ class HelloText
175
210
  }
176
211
 
177
212
  button {
178
- grid row: 0, column: 14, column_weight: 1
213
+ grid row: 1, column: column_index += 1, column_weight: 0
179
214
  image File.expand_path("images/redo.png", __dir__), subsample: 32
180
215
 
181
216
  on('command') do
182
217
  @text.edit_redo
183
218
  end
184
219
  }
220
+
221
+ separator {
222
+ grid row: 1, column: column_index += 1, column_weight: 0
223
+ orient 'vertical'
224
+ }
225
+
226
+ button {
227
+ grid row: 1, column: column_index += 1, column_weight: 0
228
+ image File.expand_path("images/picture.png", __dir__), subsample: 32
229
+
230
+ on('command') do
231
+ @text.get_open_file_to_insert_image
232
+ end
233
+ }
185
234
  }
186
235
 
187
236
  @text = text {
188
237
  grid row: 1, column: 0, row_weight: 1
189
238
  wrap 'word'
190
239
  undo true
191
- text <<~MULTI_LINE_STRING
192
- 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.
193
-
194
- 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.
195
-
196
- 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)."
197
-
198
- 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.
199
-
200
-
201
- 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".
202
-
203
- 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".
204
-
205
- 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."
206
-
207
- Meanwhile, a counter-petition supporting Burns garnered over 20,000 signatures.
208
-
209
- "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."
210
-
211
- 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.
212
-
213
- "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.
214
-
215
- The original petition has since been removed.
216
- MULTI_LINE_STRING
240
+ value <=> [self, :document]
217
241
  }
218
242
  }.open
219
243
  end
Binary file
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-tk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.28
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
@@ -215,6 +215,7 @@ files:
215
215
  - lib/glimmer/dsl/tk/attribute_expression.rb
216
216
  - lib/glimmer/dsl/tk/bind_expression.rb
217
217
  - lib/glimmer/dsl/tk/block_attribute_expression.rb
218
+ - lib/glimmer/dsl/tk/built_in_dialog_expression.rb
218
219
  - lib/glimmer/dsl/tk/data_binding_expression.rb
219
220
  - lib/glimmer/dsl/tk/dsl.rb
220
221
  - lib/glimmer/dsl/tk/format_expression.rb
@@ -243,6 +244,7 @@ files:
243
244
  - lib/glimmer/tk/variable_owner.rb
244
245
  - lib/glimmer/tk/widget_proxy.rb
245
246
  - samples/elaborate/meta_sample.rb
247
+ - samples/hello/hello_built_in_dialog.rb
246
248
  - samples/hello/hello_button.rb
247
249
  - samples/hello/hello_checkbutton.rb
248
250
  - samples/hello/hello_combobox.rb
@@ -258,6 +260,7 @@ files:
258
260
  - samples/hello/hello_notebook.rb
259
261
  - samples/hello/hello_radiobutton.rb
260
262
  - samples/hello/hello_root.rb
263
+ - samples/hello/hello_separator.rb
261
264
  - samples/hello/hello_spinbox.rb
262
265
  - samples/hello/hello_text.rb
263
266
  - samples/hello/hello_world.rb
@@ -272,7 +275,9 @@ files:
272
275
  - samples/hello/images/netherlands.png
273
276
  - samples/hello/images/norway.png
274
277
  - samples/hello/images/paste.png
278
+ - samples/hello/images/picture.png
275
279
  - samples/hello/images/redo.png
280
+ - samples/hello/images/search.png
276
281
  - samples/hello/images/undo.png
277
282
  - samples/hello/images/usa.png
278
283
  homepage: http://github.com/AndyObtiva/glimmer-dsl-tk