glimmer-dsl-tk 0.0.35 → 0.0.36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +221 -3
- data/VERSION +1 -1
- data/glimmer-dsl-tk.gemspec +0 -0
- data/lib/glimmer/dsl/tk/widget_expression.rb +1 -1
- data/lib/glimmer/tk/root_proxy.rb +1 -0
- data/lib/glimmer/tk/text_proxy.rb +0 -5
- data/lib/glimmer/tk/toplevel_proxy.rb +24 -0
- data/lib/glimmer/tk/widget_proxy.rb +8 -2
- data/samples/hello/hello_checkbutton.rb +1 -1
- data/samples/hello/hello_toplevel.rb +178 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 808f3c088481b9a8feedbccfcab17a2b37046493141bcce5677871f90e28046e
|
4
|
+
data.tar.gz: 1f433efd48c50a6b95f61cf8bae8617c44d8bbdfe9ee8b68e4c7d0bc868e5028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e0e8067624c6493dbd33bd151b885da42e04a443ef702a65abd10578c47ae22fc12f19d114ce2c345aa9bfc57c3332fa90a6ec758b7606ad62a354363b8fa27
|
7
|
+
data.tar.gz: c29b2b44399613bd15df154ee9986807ae121fcef57ff37448014ef36cc825fe6aa80e7ae28cee02d77cbdf15893ff82ea06390ca8e46394ccd6abffdeafb21a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.36
|
4
|
+
|
5
|
+
- Hello, Toplevel! (Custom Window and Custom Dialog)
|
6
|
+
- Support `mac_style` attribute under `toplevel`
|
7
|
+
- Support registering multiple general event listeners on widgets (previously, later event listener registrations replaced former ones)
|
8
|
+
- Support `escapable true` property under `root` and `toplevel` to close on hitting ESCAPE button
|
9
|
+
|
3
10
|
## 0.0.35
|
4
11
|
|
5
12
|
- Improved Meta-Sample by utilizing Ruby from `RbConfig.ruby`
|
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.
|
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.36
|
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)
|
@@ -84,6 +84,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
84
84
|
- [Notebook Frame](#notebook-frame)
|
85
85
|
- [Icon Photo](#icon-photo)
|
86
86
|
- [Root Background](#root-background)
|
87
|
+
- [Toplevel Mac Style](#toplevel-mac-style)
|
87
88
|
- [Text Defaults](#text-defaults)
|
88
89
|
- [The Grid Geometry Manager](#the-grid-geometry-manager)
|
89
90
|
- [Data-Binding](#data-binding)
|
@@ -105,6 +106,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
105
106
|
- [Hello, Radiobutton!](#hello-radiobutton)
|
106
107
|
- [Hello, Frame!](#hello-frame)
|
107
108
|
- [Hello, Root!](#hello-root)
|
109
|
+
- [Hello, Toplevel!](#hello-toplevel)
|
108
110
|
- [Hello, Notebook!](#hello-notebook)
|
109
111
|
- [Hello, Label!](#hello-label)
|
110
112
|
- [Hello, Message Box!](#hello-message-box)
|
@@ -159,7 +161,7 @@ gem install glimmer-dsl-tk
|
|
159
161
|
|
160
162
|
Add the following to `Gemfile`:
|
161
163
|
```
|
162
|
-
gem 'glimmer-dsl-tk', '~> 0.0.
|
164
|
+
gem 'glimmer-dsl-tk', '~> 0.0.36'
|
163
165
|
```
|
164
166
|
|
165
167
|
And, then run:
|
@@ -479,6 +481,20 @@ root {
|
|
479
481
|
|
480
482
|
`root` `background` color attribute is automatically set to `'#ececec'` on the Mac to avoid having a non-native-looking light-colored background.
|
481
483
|
|
484
|
+
#### Toplevel Mac Style
|
485
|
+
|
486
|
+
Mac has special support for mac styles in Tk `toplevel` via the `mac_style` attribute, which can receive 1 to 2 arguments. `mac_style`'s first argument (`mac_class`) and second argument (`mac_attribute_list`) can be chosen from this page:
|
487
|
+
|
488
|
+
https://wiki.tcl-lang.org/page/MacWindowStyle
|
489
|
+
|
490
|
+
Behind the scenes, `mac_style` automatically calls out to:
|
491
|
+
|
492
|
+
```ruby
|
493
|
+
Tk.tk_call("::tk::unsupported::MacWindowStyle", "style", tk_toplevel_widget, mac_class, mac_attribute_list)
|
494
|
+
```
|
495
|
+
|
496
|
+
More details can be found at the [Hello, Toplevel!](#hello-toplevel) sample.
|
497
|
+
|
482
498
|
#### Text Defaults
|
483
499
|
|
484
500
|
`text` widget has these defaults:
|
@@ -1333,7 +1349,7 @@ Glimmer app:
|
|
1333
1349
|
|
1334
1350
|
### Hello, Root!
|
1335
1351
|
|
1336
|
-
Glimmer code (from [samples/hello/
|
1352
|
+
Glimmer code (from [samples/hello/hello_root.rb](samples/hello/hello_root.rb)):
|
1337
1353
|
|
1338
1354
|
```ruby
|
1339
1355
|
require 'glimmer-dsl-tk'
|
@@ -1385,6 +1401,208 @@ Glimmer app:
|
|
1385
1401
|
|
1386
1402
|
![glimmer dsl tk screenshot sample hello root bye](images/glimmer-dsl-tk-screenshot-sample-hello-root-bye.png)
|
1387
1403
|
|
1404
|
+
### Hello, Toplevel!
|
1405
|
+
|
1406
|
+
`toplevel` widgets represent windows nested under `root`, which can be modeless (custom windows) or modal (dialogs that take the focus away from the owning window behind them until closed).
|
1407
|
+
|
1408
|
+
Mac has special support for mac styles in Tk `toplevel` via the `mac_style` attribute, which can receive 1 to 2 arguments. `mac_style`'s first argument (`mac_class`) and second argument (`mac_attribute_list`) can be chosen from this page:
|
1409
|
+
|
1410
|
+
https://wiki.tcl-lang.org/page/MacWindowStyle
|
1411
|
+
|
1412
|
+
Glimmer code (from [samples/hello/hello_toplevel.rb](samples/hello/hello_toplevel.rb)):
|
1413
|
+
|
1414
|
+
```ruby
|
1415
|
+
require 'glimmer-dsl-tk'
|
1416
|
+
|
1417
|
+
include Glimmer
|
1418
|
+
|
1419
|
+
def toplevel_content
|
1420
|
+
frame {
|
1421
|
+
label {
|
1422
|
+
text "This is a fully custom toplevel, meaning you can add any widgets here!\nYou can press the ESCAPE button on the keyboard to close."
|
1423
|
+
}
|
1424
|
+
separator
|
1425
|
+
checkbutton {
|
1426
|
+
text 'This is a checkbutton'
|
1427
|
+
}
|
1428
|
+
radiobutton {
|
1429
|
+
text 'This is a radiobutton'
|
1430
|
+
}
|
1431
|
+
}
|
1432
|
+
end
|
1433
|
+
|
1434
|
+
root { |root_window|
|
1435
|
+
title 'Hello, Toplevel!'
|
1436
|
+
|
1437
|
+
button {
|
1438
|
+
text 'Nested Window'
|
1439
|
+
|
1440
|
+
on('command') do
|
1441
|
+
toplevel(root_window) {
|
1442
|
+
title 'Custom Window'
|
1443
|
+
escapable true
|
1444
|
+
x 150
|
1445
|
+
y 180
|
1446
|
+
width 500
|
1447
|
+
height 200
|
1448
|
+
minsize 500, 100
|
1449
|
+
maxsize 1000, 300
|
1450
|
+
|
1451
|
+
toplevel_content
|
1452
|
+
}
|
1453
|
+
end
|
1454
|
+
}
|
1455
|
+
|
1456
|
+
button {
|
1457
|
+
text 'Transparent Window'
|
1458
|
+
|
1459
|
+
on('command') do
|
1460
|
+
toplevel(root_window) {
|
1461
|
+
title 'Transparent Window'
|
1462
|
+
escapable true
|
1463
|
+
alpha 0.85
|
1464
|
+
width 250
|
1465
|
+
height 100
|
1466
|
+
resizable false, false # not resizable horizontally or vertically
|
1467
|
+
|
1468
|
+
frame {
|
1469
|
+
label {
|
1470
|
+
text "This is a transparent window\nYou can hit ESCAPE to close."
|
1471
|
+
anchor 'center'
|
1472
|
+
}
|
1473
|
+
}
|
1474
|
+
}
|
1475
|
+
end
|
1476
|
+
}
|
1477
|
+
|
1478
|
+
button {
|
1479
|
+
text 'Fullscreen Window'
|
1480
|
+
|
1481
|
+
on('command') do
|
1482
|
+
toplevel(root_window) {
|
1483
|
+
title 'Fullscreen Window'
|
1484
|
+
escapable true
|
1485
|
+
fullscreen true
|
1486
|
+
|
1487
|
+
frame {
|
1488
|
+
label {
|
1489
|
+
text "This is a fullscreen window\nYou can hit ESCAPE to close."
|
1490
|
+
anchor 'center'
|
1491
|
+
}
|
1492
|
+
}
|
1493
|
+
}
|
1494
|
+
end
|
1495
|
+
}
|
1496
|
+
|
1497
|
+
if OS.mac?
|
1498
|
+
# Mac has special support for mac styles in Tk `toplevel`
|
1499
|
+
# `mac_style` first argument (`mac_class`) and second argument (`mac_attribute_list`) can be chosen from this page: https://wiki.tcl-lang.org/page/MacWindowStyle
|
1500
|
+
|
1501
|
+
button {
|
1502
|
+
text 'Mac Plain (No-Button-Modeless) Window'
|
1503
|
+
|
1504
|
+
on('command') do
|
1505
|
+
toplevel(root_window) { |t|
|
1506
|
+
title 'Mac Plain (No-Button-Modeless) Window'
|
1507
|
+
escapable true
|
1508
|
+
mac_style 'plain'
|
1509
|
+
|
1510
|
+
toplevel_content
|
1511
|
+
}
|
1512
|
+
end
|
1513
|
+
}
|
1514
|
+
|
1515
|
+
button {
|
1516
|
+
text 'Mac Floating (Close-Button-Modeless) Window'
|
1517
|
+
|
1518
|
+
on('command') do
|
1519
|
+
toplevel(root_window) { |t|
|
1520
|
+
title 'Mac Floating (Close-Button-Modeless) Window'
|
1521
|
+
escapable true
|
1522
|
+
mac_style 'floating'
|
1523
|
+
|
1524
|
+
toplevel_content
|
1525
|
+
}
|
1526
|
+
end
|
1527
|
+
}
|
1528
|
+
|
1529
|
+
button {
|
1530
|
+
text 'Mac Document (All-Button-Modeless) Window'
|
1531
|
+
|
1532
|
+
on('command') do
|
1533
|
+
toplevel(root_window) { |t|
|
1534
|
+
title 'Mac Document (All-Button-Modeless) Window'
|
1535
|
+
escapable true
|
1536
|
+
mac_style 'document'
|
1537
|
+
|
1538
|
+
toplevel_content
|
1539
|
+
}
|
1540
|
+
end
|
1541
|
+
}
|
1542
|
+
|
1543
|
+
button {
|
1544
|
+
text 'Mac Utility (Close-Button-Modal) Dialog'
|
1545
|
+
|
1546
|
+
on('command') do
|
1547
|
+
toplevel(root_window) { |t|
|
1548
|
+
title 'Mac Utility (Close-Button-Modal) Dialog'
|
1549
|
+
escapable true
|
1550
|
+
mac_style 'utility'
|
1551
|
+
|
1552
|
+
toplevel_content
|
1553
|
+
}
|
1554
|
+
end
|
1555
|
+
}
|
1556
|
+
|
1557
|
+
button {
|
1558
|
+
text 'Mac Utility with Attribute List (All-Button-Modal) Dialog'
|
1559
|
+
|
1560
|
+
on('command') do
|
1561
|
+
toplevel(root_window) { |t|
|
1562
|
+
title 'Mac Utility with Attribute List (All-Button-Modal) Dialog'
|
1563
|
+
escapable true
|
1564
|
+
mac_style 'utility', 'closeBox collapseBox resizable horizontalZoom verticalZoom sideTitlebar'
|
1565
|
+
|
1566
|
+
toplevel_content
|
1567
|
+
}
|
1568
|
+
end
|
1569
|
+
}
|
1570
|
+
end
|
1571
|
+
}.open
|
1572
|
+
```
|
1573
|
+
|
1574
|
+
Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
1575
|
+
|
1576
|
+
```
|
1577
|
+
ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_toplevel'"
|
1578
|
+
```
|
1579
|
+
|
1580
|
+
Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
1581
|
+
|
1582
|
+
```
|
1583
|
+
ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_toplevel.rb
|
1584
|
+
```
|
1585
|
+
|
1586
|
+
Glimmer app:
|
1587
|
+
|
1588
|
+
![glimmer dsl tk screenshot sample hello toplevel 1](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel.png)
|
1589
|
+
|
1590
|
+
![glimmer dsl tk screenshot sample hello toplevel 2](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-custom-window.png)
|
1591
|
+
|
1592
|
+
![glimmer dsl tk screenshot sample hello toplevel 3](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-transparent-window.png)
|
1593
|
+
|
1594
|
+
![glimmer dsl tk screenshot sample hello toplevel 4](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-fullscreen-window.png)
|
1595
|
+
|
1596
|
+
![glimmer dsl tk screenshot sample hello toplevel 5](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-plain-window.png)
|
1597
|
+
|
1598
|
+
![glimmer dsl tk screenshot sample hello toplevel 6](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-floating-window.png)
|
1599
|
+
|
1600
|
+
![glimmer dsl tk screenshot sample hello toplevel 7](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-document-window.png)
|
1601
|
+
|
1602
|
+
![glimmer dsl tk screenshot sample hello toplevel 8](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-utility-window.png)
|
1603
|
+
|
1604
|
+
![glimmer dsl tk screenshot sample hello toplevel 9](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-utility-with-attribute-list-window.png)
|
1605
|
+
|
1388
1606
|
### Hello, Notebook!
|
1389
1607
|
|
1390
1608
|
Glimmer code (from [samples/hello/hello_notebook.rb](samples/hello/hello_notebook.rb)):
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.36
|
data/glimmer-dsl-tk.gemspec
CHANGED
Binary file
|
@@ -33,7 +33,7 @@ module Glimmer
|
|
33
33
|
|
34
34
|
def can_interpret?(parent, keyword, *args, &block)
|
35
35
|
!EXCLUDED_KEYWORDS.include?(keyword) and
|
36
|
-
Glimmer::Tk::WidgetProxy.widget_exists?(keyword)
|
36
|
+
Glimmer::Tk::WidgetProxy.widget_exists?(keyword) and
|
37
37
|
(parent.respond_to?(:tk) or args.first.respond_to?(:tk))
|
38
38
|
end
|
39
39
|
|
@@ -432,16 +432,11 @@ module Glimmer
|
|
432
432
|
self.wrap = 'none'
|
433
433
|
self.padx = 5
|
434
434
|
self.pady = 5
|
435
|
-
# on('Modified') { apply_all_tag }
|
436
435
|
end
|
437
436
|
|
438
437
|
def clone_font(font)
|
439
438
|
::TkFont.new(Hash[font.actual])
|
440
439
|
end
|
441
|
-
|
442
|
-
# def apply_all_tag
|
443
|
-
# @tk.tag_add(ALL_TAG, '1.0', 'end')
|
444
|
-
# end
|
445
440
|
end
|
446
441
|
end
|
447
442
|
end
|
@@ -32,6 +32,19 @@ module Glimmer
|
|
32
32
|
DEFAULT_HEIGHT = 95
|
33
33
|
|
34
34
|
attr_reader :tk
|
35
|
+
attr_accessor :escapable
|
36
|
+
alias escapable? escapable
|
37
|
+
|
38
|
+
def post_add_content
|
39
|
+
if escapable?
|
40
|
+
on('KeyPress') do |event|
|
41
|
+
if event.keysym == 'Escape'
|
42
|
+
grab_release
|
43
|
+
destroy
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
35
48
|
|
36
49
|
def has_attribute?(attribute, *args)
|
37
50
|
%w[width height x y].include?(attribute.to_s) || super
|
@@ -114,6 +127,17 @@ module Glimmer
|
|
114
127
|
destroy
|
115
128
|
end
|
116
129
|
end
|
130
|
+
|
131
|
+
def mac_style=(mac_class, mac_attribute_list = nil)
|
132
|
+
if OS.mac?
|
133
|
+
@mac_style = [mac_class, mac_attribute_list]
|
134
|
+
::Tk.tk_call("::tk::unsupported::MacWindowStyle", "style", @tk, *@mac_style.compact)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def mac_style
|
139
|
+
@mac_style
|
140
|
+
end
|
117
141
|
end
|
118
142
|
end
|
119
143
|
end
|
@@ -460,14 +460,20 @@ module Glimmer
|
|
460
460
|
parent_proxy.handle_listener(listener_name, &listener) if parent_proxy
|
461
461
|
# TODO return a listener registration object that has a deregister method
|
462
462
|
else
|
463
|
+
@listeners ||= {}
|
463
464
|
begin
|
464
|
-
@
|
465
|
+
@listeners[listener_name] ||= []
|
466
|
+
@tk.bind(listener_name) { |event| @listeners[listener_name].each {|l| l.call(event)} } if @listeners[listener_name].empty?
|
467
|
+
@listeners[listener_name] << listener
|
465
468
|
rescue => e
|
469
|
+
@listeners.delete(listener_name)
|
466
470
|
Glimmer::Config.logger.debug {"Unable to bind to #{listener_name} .. attempting to surround with <>"}
|
467
471
|
Glimmer::Config.logger.debug {e.full_message}
|
468
472
|
listener_name = "<#{listener_name}" if !listener_name.start_with?('<')
|
469
473
|
listener_name = "#{listener_name}>" if !listener_name.end_with?('>')
|
470
|
-
@
|
474
|
+
@listeners[listener_name] ||= []
|
475
|
+
@tk.bind(listener_name) { |event| @listeners[listener_name].each {|l| l.call(event)} } if @listeners[listener_name].empty?
|
476
|
+
@listeners[listener_name] << listener
|
471
477
|
end
|
472
478
|
end
|
473
479
|
end
|
@@ -0,0 +1,178 @@
|
|
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
|
+
def toplevel_content
|
27
|
+
frame {
|
28
|
+
label {
|
29
|
+
text "This is a fully custom toplevel, meaning you can add any widgets here!\nYou can press the ESCAPE button on the keyboard to close."
|
30
|
+
}
|
31
|
+
separator
|
32
|
+
checkbutton {
|
33
|
+
text 'This is a checkbutton'
|
34
|
+
}
|
35
|
+
radiobutton {
|
36
|
+
text 'This is a radiobutton'
|
37
|
+
}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
root { |root_window|
|
42
|
+
title 'Hello, Toplevel!'
|
43
|
+
|
44
|
+
button {
|
45
|
+
text 'Nested Window'
|
46
|
+
|
47
|
+
on('command') do
|
48
|
+
toplevel(root_window) {
|
49
|
+
title 'Custom Window'
|
50
|
+
escapable true
|
51
|
+
x 150
|
52
|
+
y 180
|
53
|
+
width 500
|
54
|
+
height 200
|
55
|
+
minsize 500, 100
|
56
|
+
maxsize 1000, 300
|
57
|
+
|
58
|
+
toplevel_content
|
59
|
+
}
|
60
|
+
end
|
61
|
+
}
|
62
|
+
|
63
|
+
button {
|
64
|
+
text 'Transparent Window'
|
65
|
+
|
66
|
+
on('command') do
|
67
|
+
toplevel(root_window) {
|
68
|
+
title 'Transparent Window'
|
69
|
+
escapable true
|
70
|
+
alpha 0.85
|
71
|
+
width 250
|
72
|
+
height 100
|
73
|
+
resizable false, false # not resizable horizontally or vertically
|
74
|
+
|
75
|
+
frame {
|
76
|
+
label {
|
77
|
+
text "This is a transparent window\nYou can hit ESCAPE to close."
|
78
|
+
anchor 'center'
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
end
|
83
|
+
}
|
84
|
+
|
85
|
+
button {
|
86
|
+
text 'Fullscreen Window'
|
87
|
+
|
88
|
+
on('command') do
|
89
|
+
toplevel(root_window) {
|
90
|
+
title 'Fullscreen Window'
|
91
|
+
escapable true
|
92
|
+
fullscreen true
|
93
|
+
|
94
|
+
frame {
|
95
|
+
label {
|
96
|
+
text "This is a fullscreen window\nYou can hit ESCAPE to close."
|
97
|
+
anchor 'center'
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
end
|
102
|
+
}
|
103
|
+
|
104
|
+
if OS.mac?
|
105
|
+
# Mac has special support for mac styles in Tk `toplevel`
|
106
|
+
# `mac_style` first argument (`mac_class`) and second argument (`mac_attribute_list`) can be chosen from this page: https://wiki.tcl-lang.org/page/MacWindowStyle
|
107
|
+
|
108
|
+
button {
|
109
|
+
text 'Mac Plain (No-Button-Modeless) Window'
|
110
|
+
|
111
|
+
on('command') do
|
112
|
+
toplevel(root_window) { |t|
|
113
|
+
title 'Mac Plain (No-Button-Modeless) Window'
|
114
|
+
escapable true
|
115
|
+
mac_style 'plain'
|
116
|
+
|
117
|
+
toplevel_content
|
118
|
+
}
|
119
|
+
end
|
120
|
+
}
|
121
|
+
|
122
|
+
button {
|
123
|
+
text 'Mac Floating (Close-Button-Modeless) Window'
|
124
|
+
|
125
|
+
on('command') do
|
126
|
+
toplevel(root_window) { |t|
|
127
|
+
title 'Mac Floating (Close-Button-Modeless) Window'
|
128
|
+
escapable true
|
129
|
+
mac_style 'floating'
|
130
|
+
|
131
|
+
toplevel_content
|
132
|
+
}
|
133
|
+
end
|
134
|
+
}
|
135
|
+
|
136
|
+
button {
|
137
|
+
text 'Mac Document (All-Button-Modeless) Window'
|
138
|
+
|
139
|
+
on('command') do
|
140
|
+
toplevel(root_window) { |t|
|
141
|
+
title 'Mac Document (All-Button-Modeless) Window'
|
142
|
+
escapable true
|
143
|
+
mac_style 'document'
|
144
|
+
|
145
|
+
toplevel_content
|
146
|
+
}
|
147
|
+
end
|
148
|
+
}
|
149
|
+
|
150
|
+
button {
|
151
|
+
text 'Mac Utility (Close-Button-Modal) Dialog'
|
152
|
+
|
153
|
+
on('command') do
|
154
|
+
toplevel(root_window) { |t|
|
155
|
+
title 'Mac Utility (Close-Button-Modal) Dialog'
|
156
|
+
escapable true
|
157
|
+
mac_style 'utility'
|
158
|
+
|
159
|
+
toplevel_content
|
160
|
+
}
|
161
|
+
end
|
162
|
+
}
|
163
|
+
|
164
|
+
button {
|
165
|
+
text 'Mac Utility with Attribute List (All-Button-Modal) Dialog'
|
166
|
+
|
167
|
+
on('command') do
|
168
|
+
toplevel(root_window) { |t|
|
169
|
+
title 'Mac Utility with Attribute List (All-Button-Modal) Dialog'
|
170
|
+
escapable true
|
171
|
+
mac_style 'utility', 'closeBox collapseBox resizable horizontalZoom verticalZoom sideTitlebar'
|
172
|
+
|
173
|
+
toplevel_content
|
174
|
+
}
|
175
|
+
end
|
176
|
+
}
|
177
|
+
end
|
178
|
+
}.open
|
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.
|
4
|
+
version: 0.0.36
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- samples/hello/hello_separator.rb
|
266
266
|
- samples/hello/hello_spinbox.rb
|
267
267
|
- samples/hello/hello_text.rb
|
268
|
+
- samples/hello/hello_toplevel.rb
|
268
269
|
- samples/hello/hello_world.rb
|
269
270
|
- samples/hello/images/align-center.png
|
270
271
|
- samples/hello/images/align-left.png
|