glimmer-dsl-tk 0.0.34 → 0.0.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +464 -21
- data/VERSION +1 -1
- data/bin/girb_runner.rb +1 -1
- data/glimmer-dsl-tk.gemspec +0 -0
- data/lib/glimmer/dsl/tk/widget_expression.rb +1 -1
- data/lib/glimmer/tk/menu_item_proxy.rb +144 -0
- data/lib/glimmer/tk/menu_proxy.rb +48 -0
- data/lib/glimmer/tk/root_proxy.rb +1 -16
- data/lib/glimmer/tk/text_proxy.rb +25 -37
- data/lib/glimmer/tk/toplevel_proxy.rb +40 -0
- data/lib/glimmer/tk/widget_proxy.rb +18 -8
- data/lib/glimmer-dsl-tk.rb +4 -0
- data/samples/elaborate/meta_sample.rb +1 -1
- data/samples/hello/hello_checkbutton.rb +1 -1
- data/samples/hello/hello_menu_bar.rb +183 -0
- data/samples/hello/hello_text.rb +9 -9
- data/samples/hello/hello_toplevel.rb +178 -0
- metadata +6 -2
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.38
|
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)
|
@@ -55,8 +55,9 @@ NOTE: Glimmer DSL for Tk is currently in early alpha mode (incomplete). Please h
|
|
55
55
|
|
56
56
|
Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
57
57
|
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
|
58
|
-
- [glimmer-dsl-libui](https://github.com/AndyObtiva/glimmer-dsl-libui): Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)
|
59
58
|
- [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
|
59
|
+
- [glimmer-dsl-libui](https://github.com/AndyObtiva/glimmer-dsl-libui): Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)
|
60
|
+
- [glimmer-dsl-gtk](https://github.com/AndyObtiva/glimmer-dsl-gtk): Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library)
|
60
61
|
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
|
61
62
|
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
|
62
63
|
|
@@ -81,8 +82,10 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
81
82
|
- [Image Attribute](#image-attribute)
|
82
83
|
- [Frame Padding](#frame-padding)
|
83
84
|
- [Notebook Frame](#notebook-frame)
|
85
|
+
- [Menu Item Accelerator](#menu-item-accelerator)
|
84
86
|
- [Icon Photo](#icon-photo)
|
85
87
|
- [Root Background](#root-background)
|
88
|
+
- [Toplevel Mac Style](#toplevel-mac-style)
|
86
89
|
- [Text Defaults](#text-defaults)
|
87
90
|
- [The Grid Geometry Manager](#the-grid-geometry-manager)
|
88
91
|
- [Data-Binding](#data-binding)
|
@@ -104,6 +107,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
104
107
|
- [Hello, Radiobutton!](#hello-radiobutton)
|
105
108
|
- [Hello, Frame!](#hello-frame)
|
106
109
|
- [Hello, Root!](#hello-root)
|
110
|
+
- [Hello, Toplevel!](#hello-toplevel)
|
107
111
|
- [Hello, Notebook!](#hello-notebook)
|
108
112
|
- [Hello, Label!](#hello-label)
|
109
113
|
- [Hello, Message Box!](#hello-message-box)
|
@@ -117,10 +121,12 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
117
121
|
- [Hello, Drag and Drop!](#hello-drag-and-drop)
|
118
122
|
- [Hello, Built-in Dialog!](#hello-built-in-dialog)
|
119
123
|
- [Hello, Separator!](#hello-separator)
|
124
|
+
- [Hello, Menu Bar!](#hello-menu-bar)
|
120
125
|
- [Applications](#applications)
|
121
126
|
- [Glimmer Tk Calculator](#glimmer-tk-calculator)
|
122
127
|
- [Y3network Ruby UI](#y3network-ruby-ui)
|
123
128
|
- [CryptoPunks GUI](#cryptopunks-gui)
|
129
|
+
- [Circule](#circule)
|
124
130
|
- [Process](#process)
|
125
131
|
- [Resources](#resources)
|
126
132
|
- [Help](#help)
|
@@ -143,6 +149,13 @@ For example, on the Mac, you can:
|
|
143
149
|
- Run: `rvm install 3.0.2 --enable-shared --enable-pthread --with-tk --with-tcl`
|
144
150
|
- Run: `gem install tk -v0.4.0`
|
145
151
|
|
152
|
+
For example, on Windows, you can follow the [instructions over here](https://tkdocs.com/tutorial/install.html), specifically the following:
|
153
|
+
- Install Ruby+Devkit (including MSYS/MINGW toolchains) through Windows Installer: https://rubyinstaller.org/downloads/
|
154
|
+
- Install the ActiveTcl Windows package from [ActiveState.com](https://activestate.com)
|
155
|
+
- Follow this instruction: "First, Ruby needs to find the tcl86t.dll and tk86t.dll shared libraries. These are located in C:\ActiveTcl\bin. Make a copy of them somewhere Ruby can find them, e.g. C:\Ruby26\bin."
|
156
|
+
- Setup environment variables TCL_LIBRARY=C:\ActiveTcl\lib\tcl8.6 & TK_LIBRARY=C:\ActiveTcl\lib\tk8.6
|
157
|
+
- Run: `gem install tk -v0.4.0`
|
158
|
+
|
146
159
|
Afterwards, if you open `irb`, you should be able to run `require 'tk'` successfully.
|
147
160
|
|
148
161
|
## Setup
|
@@ -158,7 +171,7 @@ gem install glimmer-dsl-tk
|
|
158
171
|
|
159
172
|
Add the following to `Gemfile`:
|
160
173
|
```
|
161
|
-
gem 'glimmer-dsl-tk', '~> 0.0.
|
174
|
+
gem 'glimmer-dsl-tk', '~> 0.0.38'
|
162
175
|
```
|
163
176
|
|
164
177
|
And, then run:
|
@@ -282,10 +295,13 @@ keyword(args) | attributes | event bindings & callbacks
|
|
282
295
|
`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
|
283
296
|
`list` | `selectmode`, `selection` | None
|
284
297
|
`message_box(type: , message: , detail: , title: , icon: , default: , parent: )` | None | None
|
298
|
+
`menu(label: nil) (label is nil if nested under root/toplevel for menu bar)` | None | None
|
299
|
+
`menu_item(style = :command, label: , underline: )` (style also can be `:radiobutton`, `:checkbutton`, or `:separator`) | `state`, `accelerator`, `selection` & `variable` (if `:radiobutton` or `:checkbutton`) | `command`
|
285
300
|
`notebook` | None | None
|
286
301
|
`radiobutton` | `text`, `variable` (Boolean), `image` (optional keyword args: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`), `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `value` (default: `text`) | `command {}`
|
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'`
|
302
|
+
`root` | `title`, `iconphoto`, `background`, `alpha`, `escapable`, `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'`
|
288
303
|
`separator` | `orient` (`'horizontal' (default) or 'vertical'`) | None
|
304
|
+
`toplevel` | `title`, `iconphoto`, `background`, `alpha`, `escapable`, `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'`
|
289
305
|
`text` | `value`, [many more attributes](https://tcl.tk/man/tcl8.6/TkCmd/text.htm#M116) | `'modified'`, `'selection'`, `'insert_mark_moved'` (alias: `'insert_mark_move', 'InsertMarkMove', 'InsertMarkMoved'`)
|
290
306
|
|
291
307
|
Options for `get_open_file` and `get_multiple_open_file` include:
|
@@ -349,12 +365,12 @@ The `text` widget is enhanced by [Glimmer DSL for Tk](https://rubygems.org/gems/
|
|
349
365
|
- `add_font_format(region_start, region_end, font_option, value)`
|
350
366
|
- `remove_font_format(region_start, region_end, font_option, value)`
|
351
367
|
- `toggle_font_format(region_start, region_end, font_option, value)`
|
352
|
-
- `add_selection_format(option, value, no_selection_default: :insert_word)`: adds format to selection. If there is no selection, then applies format to current insert mark word.
|
353
|
-
- `remove_selection_format(option, value, no_selection_default: :insert_word)`
|
354
|
-
- `toggle_selection_format(option, value, no_selection_default: :insert_word)`: toggles format on selection. If there is no selection, then toggles format on current insert mark word.
|
355
|
-
- `add_selection_font_format(font_option, value, no_selection_default: :insert_word)`
|
356
|
-
- `remove_selection_font_format(font_option, value, no_selection_default: :insert_word)`
|
357
|
-
- `toggle_selection_font_format(font_option, value, no_selection_default: :insert_word)`
|
368
|
+
- `add_selection_format(option, value, no_selection_default: :insert_word, focus: true)`: adds format to selection. If there is no selection, then applies format to current insert mark word.
|
369
|
+
- `remove_selection_format(option, value, no_selection_default: :insert_word, focus: true)`
|
370
|
+
- `toggle_selection_format(option, value, no_selection_default: :insert_word, focus: true)`: toggles format on selection. If there is no selection, then toggles format on current insert mark word.
|
371
|
+
- `add_selection_font_format(font_option, value, no_selection_default: :insert_word, focus: true)`
|
372
|
+
- `remove_selection_font_format(font_option, value, no_selection_default: :insert_word, focus: true)`
|
373
|
+
- `toggle_selection_font_format(font_option, value, no_selection_default: :insert_word, focus: true)`
|
358
374
|
- `text#insert_image(text_index, *image_args)`: inserts image into `text` `value` content at `text_index` location (e.g. `'insert'`)
|
359
375
|
- `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
|
360
376
|
|
@@ -363,6 +379,9 @@ The `:no_selection_default` keyword arg to `*_selection_*` methods determines wh
|
|
363
379
|
- `:insert_letter`: current letter for insert mark
|
364
380
|
- `:none`: no behavior when no selection is in place
|
365
381
|
|
382
|
+
The `:focus` keyword arg defaults to `true` to indicate that the `text` widget should automatically grab focus after formatting modification.
|
383
|
+
Also, the `:focus` keyword arg can have an integer value representing number of milliseconds after which to grab focus once the formatting modification is done. This helps in special situations like when making the formatting modification from a combobox, which takes a while before relinquishing focus, so adding `100` millisecond delay helps ensure the `text` widget grabs focus after modification. Check [Hello, Text!](#hello-text) for an example of that.
|
384
|
+
|
366
385
|
Available options:
|
367
386
|
|
368
387
|
- `background`
|
@@ -450,6 +469,10 @@ Frames have a padding of `15` all around by default to produce more user-friendl
|
|
450
469
|
|
451
470
|
When nesting `frame` under `notebook`, you can pass a `:text` keyword argument to indicate the tab title.
|
452
471
|
|
472
|
+
#### Menu Item Accelerator
|
473
|
+
|
474
|
+
`menu_item` `accelerator` is automatically bound to the `command` set inside `menu_item` content (no need to do manual binding as per [Tk docs](https://tkdocs.com/tutorial/menus.html)).
|
475
|
+
|
453
476
|
#### Icon Photo
|
454
477
|
|
455
478
|
The `iconphoto` attribute on `root` is set to the Glimmer icon by default if no icon photo is supplied.
|
@@ -478,6 +501,20 @@ root {
|
|
478
501
|
|
479
502
|
`root` `background` color attribute is automatically set to `'#ececec'` on the Mac to avoid having a non-native-looking light-colored background.
|
480
503
|
|
504
|
+
#### Toplevel Mac Style
|
505
|
+
|
506
|
+
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:
|
507
|
+
|
508
|
+
https://wiki.tcl-lang.org/page/MacWindowStyle
|
509
|
+
|
510
|
+
Behind the scenes, `mac_style` automatically calls out to:
|
511
|
+
|
512
|
+
```ruby
|
513
|
+
Tk.tk_call("::tk::unsupported::MacWindowStyle", "style", tk_toplevel_widget, mac_class, mac_attribute_list)
|
514
|
+
```
|
515
|
+
|
516
|
+
More details can be found at the [Hello, Toplevel!](#hello-toplevel) sample.
|
517
|
+
|
481
518
|
#### Text Defaults
|
482
519
|
|
483
520
|
`text` widget has these defaults:
|
@@ -736,7 +773,6 @@ More details can be found in the [Hello, Button!](#hello-button) sample below.
|
|
736
773
|
## Gotchas
|
737
774
|
|
738
775
|
- Setting `background` attribute on `frame` or `label` does not work in `'aqua'` theme on the Mac (only in `'classic'` theme)
|
739
|
-
- `text` widget does not track `KeyPress`/`KeyRelease` events perfectly (installed via `on()` listener keyword). It seems that when all text is deleted, it stops tracking key presses/releases until a number of new lines have been added to `text` `value` attribute
|
740
776
|
|
741
777
|
## Samples
|
742
778
|
|
@@ -1333,7 +1369,7 @@ Glimmer app:
|
|
1333
1369
|
|
1334
1370
|
### Hello, Root!
|
1335
1371
|
|
1336
|
-
Glimmer code (from [samples/hello/
|
1372
|
+
Glimmer code (from [samples/hello/hello_root.rb](samples/hello/hello_root.rb)):
|
1337
1373
|
|
1338
1374
|
```ruby
|
1339
1375
|
require 'glimmer-dsl-tk'
|
@@ -1385,6 +1421,208 @@ Glimmer app:
|
|
1385
1421
|
|
1386
1422
|
![glimmer dsl tk screenshot sample hello root bye](images/glimmer-dsl-tk-screenshot-sample-hello-root-bye.png)
|
1387
1423
|
|
1424
|
+
### Hello, Toplevel!
|
1425
|
+
|
1426
|
+
`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).
|
1427
|
+
|
1428
|
+
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:
|
1429
|
+
|
1430
|
+
https://wiki.tcl-lang.org/page/MacWindowStyle
|
1431
|
+
|
1432
|
+
Glimmer code (from [samples/hello/hello_toplevel.rb](samples/hello/hello_toplevel.rb)):
|
1433
|
+
|
1434
|
+
```ruby
|
1435
|
+
require 'glimmer-dsl-tk'
|
1436
|
+
|
1437
|
+
include Glimmer
|
1438
|
+
|
1439
|
+
def toplevel_content
|
1440
|
+
frame {
|
1441
|
+
label {
|
1442
|
+
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."
|
1443
|
+
}
|
1444
|
+
separator
|
1445
|
+
checkbutton {
|
1446
|
+
text 'This is a checkbutton'
|
1447
|
+
}
|
1448
|
+
radiobutton {
|
1449
|
+
text 'This is a radiobutton'
|
1450
|
+
}
|
1451
|
+
}
|
1452
|
+
end
|
1453
|
+
|
1454
|
+
root { |root_window|
|
1455
|
+
title 'Hello, Toplevel!'
|
1456
|
+
|
1457
|
+
button {
|
1458
|
+
text 'Nested Window'
|
1459
|
+
|
1460
|
+
on('command') do
|
1461
|
+
toplevel(root_window) {
|
1462
|
+
title 'Custom Window'
|
1463
|
+
escapable true
|
1464
|
+
x 150
|
1465
|
+
y 180
|
1466
|
+
width 500
|
1467
|
+
height 200
|
1468
|
+
minsize 500, 100
|
1469
|
+
maxsize 1000, 300
|
1470
|
+
|
1471
|
+
toplevel_content
|
1472
|
+
}
|
1473
|
+
end
|
1474
|
+
}
|
1475
|
+
|
1476
|
+
button {
|
1477
|
+
text 'Transparent Window'
|
1478
|
+
|
1479
|
+
on('command') do
|
1480
|
+
toplevel(root_window) {
|
1481
|
+
title 'Transparent Window'
|
1482
|
+
escapable true
|
1483
|
+
alpha 0.85
|
1484
|
+
width 250
|
1485
|
+
height 100
|
1486
|
+
resizable false, false # not resizable horizontally or vertically
|
1487
|
+
|
1488
|
+
frame {
|
1489
|
+
label {
|
1490
|
+
text "This is a transparent window\nYou can hit ESCAPE to close."
|
1491
|
+
anchor 'center'
|
1492
|
+
}
|
1493
|
+
}
|
1494
|
+
}
|
1495
|
+
end
|
1496
|
+
}
|
1497
|
+
|
1498
|
+
button {
|
1499
|
+
text 'Fullscreen Window'
|
1500
|
+
|
1501
|
+
on('command') do
|
1502
|
+
toplevel(root_window) {
|
1503
|
+
title 'Fullscreen Window'
|
1504
|
+
escapable true
|
1505
|
+
fullscreen true
|
1506
|
+
|
1507
|
+
frame {
|
1508
|
+
label {
|
1509
|
+
text "This is a fullscreen window\nYou can hit ESCAPE to close."
|
1510
|
+
anchor 'center'
|
1511
|
+
}
|
1512
|
+
}
|
1513
|
+
}
|
1514
|
+
end
|
1515
|
+
}
|
1516
|
+
|
1517
|
+
if OS.mac?
|
1518
|
+
# Mac has special support for mac styles in Tk `toplevel`
|
1519
|
+
# `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
|
1520
|
+
|
1521
|
+
button {
|
1522
|
+
text 'Mac Plain (No-Button-Modeless) Window'
|
1523
|
+
|
1524
|
+
on('command') do
|
1525
|
+
toplevel(root_window) { |t|
|
1526
|
+
title 'Mac Plain (No-Button-Modeless) Window'
|
1527
|
+
escapable true
|
1528
|
+
mac_style 'plain'
|
1529
|
+
|
1530
|
+
toplevel_content
|
1531
|
+
}
|
1532
|
+
end
|
1533
|
+
}
|
1534
|
+
|
1535
|
+
button {
|
1536
|
+
text 'Mac Floating (Close-Button-Modeless) Window'
|
1537
|
+
|
1538
|
+
on('command') do
|
1539
|
+
toplevel(root_window) { |t|
|
1540
|
+
title 'Mac Floating (Close-Button-Modeless) Window'
|
1541
|
+
escapable true
|
1542
|
+
mac_style 'floating'
|
1543
|
+
|
1544
|
+
toplevel_content
|
1545
|
+
}
|
1546
|
+
end
|
1547
|
+
}
|
1548
|
+
|
1549
|
+
button {
|
1550
|
+
text 'Mac Document (All-Button-Modeless) Window'
|
1551
|
+
|
1552
|
+
on('command') do
|
1553
|
+
toplevel(root_window) { |t|
|
1554
|
+
title 'Mac Document (All-Button-Modeless) Window'
|
1555
|
+
escapable true
|
1556
|
+
mac_style 'document'
|
1557
|
+
|
1558
|
+
toplevel_content
|
1559
|
+
}
|
1560
|
+
end
|
1561
|
+
}
|
1562
|
+
|
1563
|
+
button {
|
1564
|
+
text 'Mac Utility (Close-Button-Modal) Dialog'
|
1565
|
+
|
1566
|
+
on('command') do
|
1567
|
+
toplevel(root_window) { |t|
|
1568
|
+
title 'Mac Utility (Close-Button-Modal) Dialog'
|
1569
|
+
escapable true
|
1570
|
+
mac_style 'utility'
|
1571
|
+
|
1572
|
+
toplevel_content
|
1573
|
+
}
|
1574
|
+
end
|
1575
|
+
}
|
1576
|
+
|
1577
|
+
button {
|
1578
|
+
text 'Mac Utility with Attribute List (All-Button-Modal) Dialog'
|
1579
|
+
|
1580
|
+
on('command') do
|
1581
|
+
toplevel(root_window) { |t|
|
1582
|
+
title 'Mac Utility with Attribute List (All-Button-Modal) Dialog'
|
1583
|
+
escapable true
|
1584
|
+
mac_style 'utility', 'closeBox collapseBox resizable horizontalZoom verticalZoom sideTitlebar'
|
1585
|
+
|
1586
|
+
toplevel_content
|
1587
|
+
}
|
1588
|
+
end
|
1589
|
+
}
|
1590
|
+
end
|
1591
|
+
}.open
|
1592
|
+
```
|
1593
|
+
|
1594
|
+
Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
1595
|
+
|
1596
|
+
```
|
1597
|
+
ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_toplevel'"
|
1598
|
+
```
|
1599
|
+
|
1600
|
+
Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
1601
|
+
|
1602
|
+
```
|
1603
|
+
ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_toplevel.rb
|
1604
|
+
```
|
1605
|
+
|
1606
|
+
Glimmer app:
|
1607
|
+
|
1608
|
+
![glimmer dsl tk screenshot sample hello toplevel 1](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel.png)
|
1609
|
+
|
1610
|
+
![glimmer dsl tk screenshot sample hello toplevel 2](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-custom-window.png)
|
1611
|
+
|
1612
|
+
![glimmer dsl tk screenshot sample hello toplevel 3](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-transparent-window.png)
|
1613
|
+
|
1614
|
+
![glimmer dsl tk screenshot sample hello toplevel 4](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-fullscreen-window.png)
|
1615
|
+
|
1616
|
+
![glimmer dsl tk screenshot sample hello toplevel 5](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-plain-window.png)
|
1617
|
+
|
1618
|
+
![glimmer dsl tk screenshot sample hello toplevel 6](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-floating-window.png)
|
1619
|
+
|
1620
|
+
![glimmer dsl tk screenshot sample hello toplevel 7](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-document-window.png)
|
1621
|
+
|
1622
|
+
![glimmer dsl tk screenshot sample hello toplevel 8](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-utility-window.png)
|
1623
|
+
|
1624
|
+
![glimmer dsl tk screenshot sample hello toplevel 9](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-utility-with-attribute-list-window.png)
|
1625
|
+
|
1388
1626
|
### Hello, Notebook!
|
1389
1627
|
|
1390
1628
|
Glimmer code (from [samples/hello/hello_notebook.rb](samples/hello/hello_notebook.rb)):
|
@@ -1972,28 +2210,28 @@ class HelloText
|
|
1972
2210
|
|
1973
2211
|
column_index = -1
|
1974
2212
|
|
1975
|
-
combobox {
|
2213
|
+
combobox { |cb|
|
1976
2214
|
grid row: 1, column: column_index += 1, column_weight: 1
|
1977
2215
|
readonly true
|
1978
|
-
text <=> [self, :font_family, after_write: ->(value) { @text.toggle_selection_font_format('family', value == FONT_FAMILY_PROMPT ? 'Courier New' : value) }]
|
2216
|
+
text <=> [self, :font_family, after_write: ->(value) { @text.toggle_selection_font_format('family', value == FONT_FAMILY_PROMPT ? 'Courier New' : value, focus: 100) }]
|
1979
2217
|
}
|
1980
2218
|
|
1981
2219
|
combobox {
|
1982
2220
|
grid row: 1, column: column_index += 1, column_weight: 1
|
1983
2221
|
readonly true
|
1984
|
-
text <=> [self, :font_size, after_write: ->(value) { @text.toggle_selection_font_format('size', value == FONT_SIZE_PROMPT ? 13 : value) }]
|
2222
|
+
text <=> [self, :font_size, after_write: ->(value) { @text.toggle_selection_font_format('size', value == FONT_SIZE_PROMPT ? 13 : value, focus: 100) }]
|
1985
2223
|
}
|
1986
2224
|
|
1987
2225
|
combobox {
|
1988
2226
|
grid row: 1, column: column_index += 1, column_weight: 1
|
1989
2227
|
readonly true
|
1990
|
-
text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value) }]
|
2228
|
+
text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value, focus: 100) }]
|
1991
2229
|
}
|
1992
2230
|
|
1993
2231
|
combobox {
|
1994
2232
|
grid row: 1, column: column_index += 1, column_weight: 1
|
1995
2233
|
readonly true
|
1996
|
-
text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'white' : value) }]
|
2234
|
+
text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'white' : value, focus: 100) }]
|
1997
2235
|
}
|
1998
2236
|
|
1999
2237
|
separator {
|
@@ -2149,10 +2387,6 @@ class HelloText
|
|
2149
2387
|
undo true
|
2150
2388
|
value <=> [self, :document]
|
2151
2389
|
|
2152
|
-
on('KeyPress') do |event|
|
2153
|
-
show_find_dialog if (event.keysym == 'f') && ((OS.mac? && event.state == 8) || (!OS.mac? && event.state == 4))
|
2154
|
-
end
|
2155
|
-
|
2156
2390
|
on('InsertMarkMoved') do
|
2157
2391
|
self.font_family = @text.applied_font_format_value('family')
|
2158
2392
|
self.font_size = @text.applied_font_format_value('size')
|
@@ -2165,6 +2399,10 @@ class HelloText
|
|
2165
2399
|
@justify_center_button.default = @text.applied_format_value('justify') == 'center' ? 'active' : 'normal'
|
2166
2400
|
@justify_right_button.default = @text.applied_format_value('justify') == 'right' ? 'active' : 'normal'
|
2167
2401
|
end
|
2402
|
+
|
2403
|
+
on('KeyPress') do |event|
|
2404
|
+
show_find_dialog if (event.keysym == 'f') && ((OS.mac? && event.state == 8) || (!OS.mac? && event.state == 4))
|
2405
|
+
end
|
2168
2406
|
}
|
2169
2407
|
}
|
2170
2408
|
@root.open
|
@@ -2699,6 +2937,203 @@ Glimmer app:
|
|
2699
2937
|
|
2700
2938
|
![glimmer dsl tk screenshot sample hello separator](images/glimmer-dsl-tk-screenshot-sample-hello-separator.png)
|
2701
2939
|
|
2940
|
+
### Hello, Menu Bar!
|
2941
|
+
|
2942
|
+
Glimmer code (from [samples/hello/hello_menu_bar.rb](samples/hello/hello_menu_bar.rb)):
|
2943
|
+
|
2944
|
+
```ruby
|
2945
|
+
require 'glimmer-dsl-tk'
|
2946
|
+
|
2947
|
+
include Glimmer
|
2948
|
+
|
2949
|
+
COLORS = [:white, :red, :yellow, :green, :blue, :magenta, :gray, :black]
|
2950
|
+
|
2951
|
+
Tk::Tile::Style.theme_use "classic" # this enables setting background on label just for demo purposes
|
2952
|
+
|
2953
|
+
root { |r|
|
2954
|
+
title 'Hello, Menu Bar!'
|
2955
|
+
|
2956
|
+
@label = label {
|
2957
|
+
grid row_weight: 1, column_weight: 1
|
2958
|
+
text 'Check Out The Menu Bar Above!'
|
2959
|
+
font size: 50
|
2960
|
+
anchor 'center'
|
2961
|
+
}
|
2962
|
+
|
2963
|
+
menu {
|
2964
|
+
menu(label: 'File', underline: 0) {
|
2965
|
+
menu_item(label: 'New', underline: 0) {
|
2966
|
+
accelerator 'Command+N'
|
2967
|
+
|
2968
|
+
on('command') do
|
2969
|
+
message_box(parent: r, title: 'New', message: 'New file created.')
|
2970
|
+
end
|
2971
|
+
}
|
2972
|
+
menu_item(label: 'Open...', underline: 0) {
|
2973
|
+
accelerator 'Command+O'
|
2974
|
+
|
2975
|
+
on('command') do
|
2976
|
+
message_box(parent: r, title: 'Open', message: 'Opening File...')
|
2977
|
+
end
|
2978
|
+
}
|
2979
|
+
menu(label: 'Open Recent', underline: 5) {
|
2980
|
+
menu_item(label: 'File 1') {
|
2981
|
+
on('command') do
|
2982
|
+
message_box(parent: r, title: 'File 1', message: 'File 1 Contents')
|
2983
|
+
end
|
2984
|
+
}
|
2985
|
+
menu_item(label: 'File 2') {
|
2986
|
+
on('command') do
|
2987
|
+
message_box(parent: r, title: 'File 2', message: 'File 2 Contents')
|
2988
|
+
end
|
2989
|
+
}
|
2990
|
+
}
|
2991
|
+
menu_item(:separator)
|
2992
|
+
menu_item(label: 'Exit', underline: 1) {
|
2993
|
+
on('command') do
|
2994
|
+
exit(0)
|
2995
|
+
end
|
2996
|
+
}
|
2997
|
+
}
|
2998
|
+
menu(label: 'Edit', underline: 0) {
|
2999
|
+
menu_item(label: 'Cut', underline: 2) {
|
3000
|
+
accelerator 'Command+X'
|
3001
|
+
}
|
3002
|
+
menu_item(label: 'Copy', underline: 0) {
|
3003
|
+
accelerator 'Command+C'
|
3004
|
+
}
|
3005
|
+
menu_item(label: 'Paste', underline: 0) {
|
3006
|
+
accelerator 'Command+V'
|
3007
|
+
}
|
3008
|
+
}
|
3009
|
+
menu(label: 'Options', underline: 0) {
|
3010
|
+
menu_item(:checkbutton, label: 'Enabled', underline: 0) {
|
3011
|
+
on('command') do
|
3012
|
+
@select_one_menu.children.each { |menu_item| menu_item.state = menu_item.state == 'disabled' ? 'normal' : 'disabled' }
|
3013
|
+
@select_multiple_menu.children.each { |menu_item| menu_item.state = menu_item.state == 'disabled' ? 'normal' : 'disabled' }
|
3014
|
+
end
|
3015
|
+
}
|
3016
|
+
@select_one_menu = menu(label: 'Select One', underline: 0) {
|
3017
|
+
menu_item(:radiobutton, label: 'Option 1') {
|
3018
|
+
state 'disabled'
|
3019
|
+
}
|
3020
|
+
menu_item(:radiobutton, label: 'Option 2') {
|
3021
|
+
state 'disabled'
|
3022
|
+
}
|
3023
|
+
menu_item(:radiobutton, label: 'Option 3') {
|
3024
|
+
state 'disabled'
|
3025
|
+
}
|
3026
|
+
}
|
3027
|
+
@select_multiple_menu = menu(label: 'Select Multiple', underline: 0) {
|
3028
|
+
menu_item(:checkbutton, label: 'Option 4') {
|
3029
|
+
state 'disabled'
|
3030
|
+
}
|
3031
|
+
menu_item(:checkbutton, label: 'Option 5') {
|
3032
|
+
state 'disabled'
|
3033
|
+
}
|
3034
|
+
menu_item(:checkbutton, label: 'Option 6') {
|
3035
|
+
state 'disabled'
|
3036
|
+
}
|
3037
|
+
}
|
3038
|
+
}
|
3039
|
+
menu(label: 'Format', underline: 0) {
|
3040
|
+
menu(label: 'Background Color', underline: 0) {
|
3041
|
+
COLORS.each { |color_style|
|
3042
|
+
menu_item(:radiobutton, label: color_style.to_s.split('_').map(&:capitalize).join(' ')) {
|
3043
|
+
on('command') do
|
3044
|
+
@label.background = color_style
|
3045
|
+
end
|
3046
|
+
}
|
3047
|
+
}
|
3048
|
+
}
|
3049
|
+
menu(label: 'Foreground Color', underline: 11) {
|
3050
|
+
COLORS.each { |color_style|
|
3051
|
+
menu_item(:radiobutton, label: color_style.to_s.split('_').map(&:capitalize).join(' ')) {
|
3052
|
+
on('command') do
|
3053
|
+
@label.foreground = color_style
|
3054
|
+
end
|
3055
|
+
}
|
3056
|
+
}
|
3057
|
+
}
|
3058
|
+
}
|
3059
|
+
menu(label: 'View', underline: 0) {
|
3060
|
+
menu_item(:radiobutton, label: 'Small', underline: 0) {
|
3061
|
+
accelerator 'Command+S'
|
3062
|
+
|
3063
|
+
on('command') do
|
3064
|
+
@label.font = {size: 25}
|
3065
|
+
end
|
3066
|
+
}
|
3067
|
+
menu_item(:radiobutton, label: 'Medium', underline: 0) {
|
3068
|
+
accelerator 'Command+M'
|
3069
|
+
selection true
|
3070
|
+
|
3071
|
+
on('command') do
|
3072
|
+
@label.font = {size: 50}
|
3073
|
+
end
|
3074
|
+
}
|
3075
|
+
menu_item(:radiobutton, label: 'Large', underline: 0) {
|
3076
|
+
accelerator 'Command+L'
|
3077
|
+
|
3078
|
+
on('command') do
|
3079
|
+
@label.font = {size: 75}
|
3080
|
+
end
|
3081
|
+
}
|
3082
|
+
}
|
3083
|
+
menu(label: 'Help', underline: 0) {
|
3084
|
+
menu_item(label: 'Manual', underline: 0) {
|
3085
|
+
accelerator 'Command+Shift+M'
|
3086
|
+
|
3087
|
+
on('command') do
|
3088
|
+
message_box(parent: r, title: 'Manual', message: 'Manual Contents')
|
3089
|
+
end
|
3090
|
+
}
|
3091
|
+
menu_item(label: 'Tutorial', underline: 0) {
|
3092
|
+
accelerator 'Command+Shift+T'
|
3093
|
+
|
3094
|
+
on('command') do
|
3095
|
+
message_box(parent: r, title: 'Tutorial', message: 'Tutorial Contents')
|
3096
|
+
end
|
3097
|
+
}
|
3098
|
+
menu_item(:separator)
|
3099
|
+
menu_item(label: 'Report an Issue...', underline: 0) {
|
3100
|
+
on('command') do
|
3101
|
+
message_box(parent: r, title: 'Report an Issue', message: 'Reporting an issue...')
|
3102
|
+
end
|
3103
|
+
}
|
3104
|
+
}
|
3105
|
+
}
|
3106
|
+
}.open
|
3107
|
+
```
|
3108
|
+
|
3109
|
+
Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
3110
|
+
|
3111
|
+
```
|
3112
|
+
ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_menu_bar'"
|
3113
|
+
```
|
3114
|
+
|
3115
|
+
Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
3116
|
+
|
3117
|
+
```
|
3118
|
+
ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_menu_bar.rb
|
3119
|
+
```
|
3120
|
+
|
3121
|
+
Glimmer app:
|
3122
|
+
|
3123
|
+
![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar.png)
|
3124
|
+
|
3125
|
+
![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-file.png)
|
3126
|
+
|
3127
|
+
![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-edit.png)
|
3128
|
+
|
3129
|
+
![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-options.png)
|
3130
|
+
|
3131
|
+
![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-format.png)
|
3132
|
+
|
3133
|
+
![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-view.png)
|
3134
|
+
|
3135
|
+
![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-help.png)
|
3136
|
+
|
2702
3137
|
## Applications
|
2703
3138
|
|
2704
3139
|
### Glimmer Tk Calculator
|
@@ -2721,6 +3156,14 @@ https://github.com/AndyObtiva/cryptopunks-gui
|
|
2721
3156
|
|
2722
3157
|
![CryptoPunks GUI Screenshot](https://raw.githubusercontent.com/AndyObtiva/cryptopunks-gui/master/screenshots/cryptopunks-gui-screenshot.png)
|
2723
3158
|
|
3159
|
+
### Circule
|
3160
|
+
|
3161
|
+
Generate an icon of overlapping circles derived from a hash.
|
3162
|
+
|
3163
|
+
https://gitlab.com/fjc/circule
|
3164
|
+
|
3165
|
+
[Demo Video](https://gitlab.com/fjc/circule/-/raw/master/circule-demo.mp4)
|
3166
|
+
|
2724
3167
|
## Process
|
2725
3168
|
|
2726
3169
|
[Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.38
|
data/bin/girb_runner.rb
CHANGED
@@ -27,7 +27,7 @@ require_relative '../lib/glimmer-dsl-tk'
|
|
27
27
|
|
28
28
|
include Glimmer
|
29
29
|
|
30
|
-
GIRB_RUNNER_EXIT_FILE = "#{
|
30
|
+
GIRB_RUNNER_EXIT_FILE = "#{Dir.home}/.girb_runner_exit"
|
31
31
|
FileUtils.rm_rf GIRB_RUNNER_EXIT_FILE
|
32
32
|
|
33
33
|
@exit_method = method(:exit)
|
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
|
|