glimmer-dsl-tk 0.0.7 → 0.0.8

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: 7048451aa588f11c433d93073beb1a3eda6d03877e076ed9a3c23d432746e492
4
- data.tar.gz: 4797910066441f8d0bf8960ca5bc3732ea39d6b0bd4103a3246349921a133bde
3
+ metadata.gz: 2f18bce2ab82f0e85d106d99e6508490b69172f1039e38d0e0208cf6a5ca70e6
4
+ data.tar.gz: '0779ed4a739d7ffa4e7c6d6b2556fe365741715165ff5c1bf7f9bc6456ba3443'
5
5
  SHA512:
6
- metadata.gz: 3d25ea1d5a2c22ecc11fcc526cf264c207e21bbb018a1e05627aee01d6ce50aa8f9ce94a7fc57f0546221c0db9ab9bba46dc91a10c9ab0329de73bf7c9d56241
7
- data.tar.gz: eccf58d86c03fb9b0383180025a7cc30d31f9b2dd98cfa36d422592170fbe01266d4a0487e020e241e69637e17754361207524a51a487b62494cd963fc6fb829
6
+ metadata.gz: 7cd74eff8e24f8152aa11c562fe410bc46a6d45193e7797afff970113eabd6604f3e0adee55882fc9b2e019bd36185ed95befc56f8376925c5292b7383814fa2
7
+ data.tar.gz: 98ba6609fd143106c4f9a66a5ed006742c53775bdb155bfe98be6b905aeecec8fb61690e9642113f7790c19d31006ef3fe4309a9d6b71bc703a02517a577128f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.8
4
+
5
+ - Fix issue #5 (https://github.com/AndyObtiva/glimmer-dsl-tk/issues/5)
6
+ - Support `iconphoto` attribute on `root` widget, intelligently accepting a direct image path or `TkPhotoImage` object
7
+ - Set `root` `iconphoto` attribute to Glimmer icon by default if not set in an application.
8
+ - Provide `iconphoto` code example in README
9
+ - Upgrade to glimmer 2.1.1
10
+
3
11
  ## 0.0.7
4
12
 
5
13
  - Upgraded to tk 0.4.0
data/README.md CHANGED
@@ -1,6 +1,5 @@
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.7
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Tk 0.0.8
2
2
  ## MRI Ruby Desktop Development GUI Library
3
- GUI Library
4
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-tk.svg)](http://badge.fury.io/rb/glimmer-dsl-tk)
5
4
  [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-tk/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-tk?branch=master)
6
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/ce2853efdbecf6ebdc73/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-tk/maintainability)
@@ -37,10 +36,10 @@ root {
37
36
  }.open
38
37
  ```
39
38
 
40
- Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
39
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
41
40
 
42
41
  ```
43
- ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_world.rb'"
42
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_world'"
44
43
  ```
45
44
 
46
45
  Glimmer app:
@@ -61,9 +60,10 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
61
60
  - [Ruby](https://www.ruby-lang.org/en/): On Windows, obtain from the Ruby [download page](https://www.ruby-lang.org/en/downloads/). On the Mac and Linux, it is more convenient to just use [RVM](http://rvm.io) and follow the [RVM Tk instructions](https://rvm.io/integration/tk).
62
61
 
63
62
  For example, on the Mac, you can:
64
- - Install the ActiveTcl Mac package from [ActiveState.com](ActiveState.com)
63
+ - Install the ActiveTcl Mac package from [ActiveState.com](https://activestate.com)
65
64
  - Install [RVM](https://rvm.io/) by running `\curl -sSL https://get.rvm.io | bash -s stable` (and run `curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -` if needed for mentioned security reasons)
66
65
  - Run: `rvm install 2.7.1 --enable-shared --enable-pthread --with-tk --with-tcl`
66
+ - Run: `gem install tk -v0.4.0`
67
67
 
68
68
  Afterwards, if you open `irb`, you should be able to run `require 'tk'` successfully.
69
69
 
@@ -80,7 +80,7 @@ gem install glimmer-dsl-tk
80
80
 
81
81
  Add the following to `Gemfile`:
82
82
  ```
83
- gem 'glimmer-dsl-tk', '~> 0.0.7'
83
+ gem 'glimmer-dsl-tk', '~> 0.0.8'
84
84
  ```
85
85
 
86
86
  And, then run:
@@ -166,6 +166,36 @@ root {
166
166
  }.open
167
167
  ```
168
168
 
169
+ ### Smart Defaults and Convensions
170
+
171
+ #### Grid Layout
172
+
173
+ `grid` layout is the default on most widgets (which support it).
174
+
175
+ #### Icon Photo
176
+
177
+ The `iconphoto` attribute on `root` is set to the Glimmer icon by default if no icon photo is supplied.
178
+
179
+ Otherwise, [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk) is smart enough to accept an image path directly (no need to wrap with `TkPhotoImage`)
180
+
181
+ Example with direct image path (you may copy/paste in [`girb`](#girb-glimmer-irb)):
182
+
183
+ ```ruby
184
+ root {
185
+ title 'Title'
186
+ iconphoto 'icons/glimmer.png'
187
+ }.open
188
+ ```
189
+
190
+ Example with `TkPhotoImage` object (you may copy/paste in [`girb`](#girb-glimmer-irb)):
191
+
192
+ ```ruby
193
+ root {
194
+ title 'Title'
195
+ iconphoto TkPhotoImage.new(file: 'icons/glimmer.png')
196
+ }.open
197
+ ```
198
+
169
199
  ## The Grid Geometry Manager
170
200
 
171
201
  The Grid Geometry Manager is supported via the `grid` keyword just as per the [Tk documentation](https://tkdocs.com/tutorial/grid.html), except by nesting under the widget it concerns.
@@ -324,10 +354,16 @@ root {
324
354
  }.open
325
355
  ```
326
356
 
327
- Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
357
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
358
+
359
+ ```
360
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_world'"
361
+ ```
362
+
363
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
328
364
 
329
365
  ```
330
- ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_world.rb'"
366
+ ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_world'"
331
367
  ```
332
368
 
333
369
  Glimmer app:
@@ -360,10 +396,16 @@ root {
360
396
  }.open
361
397
  ```
362
398
 
363
- Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
399
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
400
+
401
+ ```
402
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_tab'"
403
+ ```
404
+
405
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
364
406
 
365
407
  ```
366
- ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_tab.rb'"
408
+ ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_tab'"
367
409
  ```
368
410
 
369
411
  Glimmer app:
@@ -395,10 +437,16 @@ root {
395
437
  # ... more code follows
396
438
  ```
397
439
 
398
- Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
440
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
399
441
 
400
442
  ```
401
- ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_combo.rb'"
443
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_combo'"
444
+ ```
445
+
446
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
447
+
448
+ ```
449
+ ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_combo'"
402
450
  ```
403
451
 
404
452
  Glimmer app:
@@ -429,10 +477,16 @@ root {
429
477
  # ... more code follows
430
478
  ```
431
479
 
432
- Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
480
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
433
481
 
434
482
  ```
435
- ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_list_single_selection.rb'"
483
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_list_single_selection'"
484
+ ```
485
+
486
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
487
+
488
+ ```
489
+ ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_list_single_selection'"
436
490
  ```
437
491
 
438
492
  Glimmer app:
@@ -461,10 +515,16 @@ root {
461
515
  # ... more code follows
462
516
  ```
463
517
 
464
- Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
518
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
519
+
520
+ ```
521
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_list_multi_selection'"
522
+ ```
523
+
524
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
465
525
 
466
526
  ```
467
- ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_list_multi_selection.rb'"
527
+ ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_list_multi_selection'"
468
528
  ```
469
529
 
470
530
  Glimmer app:
@@ -535,10 +595,16 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
535
595
  # ... more code follows
536
596
  ```
537
597
 
538
- Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
598
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
599
+
600
+ ```
601
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_computed'"
602
+ ```
603
+
604
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
539
605
 
540
606
  ```
541
- ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_computed.rb'"
607
+ ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_computed'"
542
608
  ```
543
609
 
544
610
  Glimmer app:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
data/icons/glimmer.png ADDED
Binary file
@@ -40,6 +40,11 @@ module Glimmer
40
40
  args = [parent] + args unless parent.nil?
41
41
  Glimmer::Tk::RootProxy.new(*args)
42
42
  end
43
+
44
+ def add_content(parent, keyword, *args, &block)
45
+ super
46
+ parent.post_add_content
47
+ end
43
48
  end
44
49
  end
45
50
  end
@@ -41,7 +41,7 @@ module Glimmer
41
41
  Glimmer::Tk::WidgetProxy.create(keyword, parent, args, &block)
42
42
  end
43
43
 
44
- def add_content(parent, &block)
44
+ def add_content(parent, keyword, *args, &block)
45
45
  super
46
46
  parent.post_add_content
47
47
  end
@@ -27,11 +27,14 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class RootProxy < WidgetProxy
30
-
31
30
  def initialize(*args)
32
31
  @tk = ::TkRoot.new
33
32
  end
34
33
 
34
+ def post_add_content
35
+ set_attribute('iconphoto', File.expand_path('../../../icons/glimmer.png', __dir__)) if @tk.iconphoto.nil?
36
+ end
37
+
35
38
  def open
36
39
  start_event_loop
37
40
  end
@@ -39,6 +42,17 @@ module Glimmer
39
42
  def content(&block)
40
43
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::RootExpression.new, &block)
41
44
  end
45
+
46
+ def set_attribute(attribute, *args)
47
+ if attribute.to_s == 'iconphoto'
48
+ if args.size == 1 && args.first.is_a?(String)
49
+ args[0] = ::TkPhotoImage.new(file: args.first)
50
+ end
51
+ super
52
+ else
53
+ super
54
+ end
55
+ end
42
56
 
43
57
  # Starts Tk mainloop
44
58
  def start_event_loop
@@ -116,15 +116,7 @@ module Glimmer
116
116
  end
117
117
 
118
118
  def tk_widget_has_attribute_getter_setter?(attribute)
119
- result = nil
120
- begin
121
- # TK Widget currently doesn't support respond_to? properly, so I have to resort to this trick for now
122
- @tk.send(attribute, @tk.send(attribute))
123
- result = true
124
- rescue => e
125
- result = false
126
- end
127
- result
119
+ @tk.respond_to?(attribute)
128
120
  end
129
121
 
130
122
  def has_attribute?(attribute, *args)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-tk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-15 00:00:00.000000000 Z
11
+ date: 2021-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.3
19
+ version: 2.1.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.3
26
+ version: 2.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tk
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -120,14 +120,14 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: 0.10.0
123
+ version: 0.13.1
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: 0.10.0
130
+ version: 0.13.1
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: coveralls
133
133
  requirement: !ruby/object:Gem::Requirement
@@ -186,6 +186,7 @@ files:
186
186
  - VERSION
187
187
  - bin/girb
188
188
  - bin/girb_runner.rb
189
+ - icons/glimmer.png
189
190
  - lib/glimmer-dsl-tk.rb
190
191
  - lib/glimmer/data_binding/tk/list_selection_binding.rb
191
192
  - lib/glimmer/data_binding/tk/widget_binding.rb
@@ -220,6 +221,7 @@ post_install_message:
220
221
  rdoc_options: []
221
222
  require_paths:
222
223
  - lib
224
+ - "."
223
225
  required_ruby_version: !ruby/object:Gem::Requirement
224
226
  requirements:
225
227
  - - ">="
@@ -231,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
233
  - !ruby/object:Gem::Version
232
234
  version: '0'
233
235
  requirements: []
234
- rubygems_version: 3.1.2
236
+ rubygems_version: 3.2.22
235
237
  signing_key:
236
238
  specification_version: 4
237
239
  summary: Glimmer DSL for Tk