glimmer-dsl-tk 0.0.48 → 0.0.52
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/LICENSE.txt +1 -1
- data/README.md +252 -22
- data/VERSION +1 -1
- data/bin/girb +1 -1
- data/bin/girb_runner.rb +1 -1
- data/glimmer-dsl-tk.gemspec +0 -0
- data/lib/glimmer/data_binding/tk/list_selection_binding.rb +1 -1
- data/lib/glimmer/data_binding/tk/one_time_observer.rb +1 -1
- data/lib/glimmer/data_binding/tk/widget_binding.rb +1 -1
- data/lib/glimmer/dsl/tk/attribute_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/bind_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/block_attribute_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/built_in_dialog_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/dsl.rb +1 -1
- data/lib/glimmer/dsl/tk/format_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/list_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/message_box_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/on_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/root_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/shine_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/tk/widget_expression.rb +1 -1
- data/lib/glimmer/tk/checkbutton_proxy.rb +1 -1
- data/lib/glimmer/tk/combobox_proxy.rb +1 -1
- data/lib/glimmer/tk/drag_and_drop_event.rb +21 -0
- data/lib/glimmer/tk/draggable_and_droppable.rb +1 -1
- data/lib/glimmer/tk/entry_proxy.rb +1 -1
- data/lib/glimmer/tk/frame_proxy.rb +1 -1
- data/lib/glimmer/tk/label_proxy.rb +1 -1
- data/lib/glimmer/tk/lbl_proxy.rb +1 -1
- data/lib/glimmer/tk/list_proxy.rb +1 -1
- data/lib/glimmer/tk/menu_item_proxy.rb +39 -12
- data/lib/glimmer/tk/menu_proxy.rb +19 -4
- data/lib/glimmer/tk/notebook_proxy.rb +1 -1
- data/lib/glimmer/tk/os.rb +1 -1
- data/lib/glimmer/tk/radiobutton_proxy.rb +1 -1
- data/lib/glimmer/tk/root_proxy.rb +1 -1
- data/lib/glimmer/tk/scrollbar_frame_proxy.rb +1 -1
- data/lib/glimmer/tk/spinbox_proxy.rb +1 -1
- data/lib/glimmer/tk/text_proxy.rb +1 -1
- data/lib/glimmer/tk/text_variable_owner.rb +1 -1
- data/lib/glimmer/tk/toplevel_proxy.rb +16 -2
- data/lib/glimmer/tk/treeview_proxy.rb +1 -1
- data/lib/glimmer/tk/variable_owner.rb +1 -1
- data/lib/glimmer/tk/widget.rb +1 -1
- data/lib/glimmer/tk/widget_proxy.rb +8 -3
- data/lib/glimmer-dsl-tk.rb +1 -1
- data/samples/elaborate/meta_sample.rb +1 -1
- data/samples/hello/hello_built_in_dialog.rb +1 -1
- data/samples/hello/hello_button.rb +1 -1
- data/samples/hello/hello_checkbutton.rb +1 -1
- data/samples/hello/hello_combobox.rb +1 -2
- data/samples/hello/hello_computed.rb +1 -1
- data/samples/hello/hello_contextual_menu.rb +192 -0
- data/samples/hello/hello_drag_and_drop.rb +1 -1
- data/samples/hello/hello_entry.rb +1 -1
- data/samples/hello/hello_frame.rb +1 -1
- data/samples/hello/hello_label.rb +1 -1
- data/samples/hello/hello_list_multi_selection.rb +1 -1
- data/samples/hello/hello_list_single_selection.rb +1 -1
- data/samples/hello/hello_menu_bar.rb +10 -2
- data/samples/hello/hello_message_box.rb +1 -1
- data/samples/hello/hello_notebook.rb +1 -1
- data/samples/hello/hello_radiobutton.rb +1 -1
- data/samples/hello/hello_root.rb +1 -1
- data/samples/hello/hello_scrollbar.rb +1 -1
- data/samples/hello/hello_scrollbar_frame.rb +1 -1
- data/samples/hello/hello_separator.rb +1 -1
- data/samples/hello/hello_spinbox.rb +1 -1
- data/samples/hello/hello_text.rb +1 -1
- data/samples/hello/hello_toplevel.rb +1 -1
- data/samples/hello/hello_world.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb2ccf0557cc7810f711f841873b281e3ffe57e67355e61825feedc287769102
|
4
|
+
data.tar.gz: 16e760a663bb0982542089d46c5ca3d959d354bb566929367cf2bde7909f29cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7906ab4bdc15f6a9c6cbe184f70ae9929adec99879091789395a9386d7e7a6572fc5b65d83c492514bdff332c29cc6cd192ac6b1d5f562e52aa15157db2a3f34
|
7
|
+
data.tar.gz: 84ea229d1961c7385b6aac6dcea591fea7db0731e99a6e5d65bcae114eed2b1218cb0665cf8762d2abad0560c1510feb347ac7eecde8a69612ce22fc98eede82
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.52
|
4
|
+
|
5
|
+
- Upgrade to glimmer 2.6.0
|
6
|
+
- Remove default height for root/toplevel (automatically calculated from children)
|
7
|
+
- Support data-binding `_options` method items on `combobox` (not just main value), thus making options update if `notify_observers(:some_attr_options)` is called
|
8
|
+
|
9
|
+
## 0.0.51
|
10
|
+
|
11
|
+
- Center application root/toplevel within screen by default (if x or y are specified, they are respected instead)
|
12
|
+
- Enhance Hello, Contextual Menu! & Hello, Menu Bar! to display a message box upon selecting a Language/Country
|
13
|
+
- Explicitly support all menu item attributes: `activebackground`, `activeforeground`, `background`, `bitmap`, `columnbreak`, `compound`, `font`, `foreground`, `hidemargin`, `indicatoron`, `menu`, `offvalue`, `onvalue`, `selectcolor`, `selectimage`, `state`, `underline`, `value`
|
14
|
+
|
15
|
+
## 0.0.50
|
16
|
+
|
17
|
+
- Support manual binding of contextual menu by passing `bind: false` option (e.g. `menu(bind: false) {...}` as demonstrated in samples/hello/hello_contextual_menu.rb)
|
18
|
+
- Support binding multiple contextual menus (they show up consecutively unless there is conditional logic to control showing them individually)
|
19
|
+
- Update Hello, Contextual Menu! to add a comment and an example about manual menu binding
|
20
|
+
- Upgrade to glimmer 2.5.4
|
21
|
+
|
22
|
+
## 0.0.49
|
23
|
+
|
24
|
+
- [API Breaking] Update menu bar support to require `menu_bar` keyword under `root` or `toplevel`
|
25
|
+
- Support contextual menu by nesting `menu` keyword under `root` or `toplevel`
|
26
|
+
|
3
27
|
## 0.0.48
|
4
28
|
|
5
29
|
- Moved `OS` class to `Glimmer::Tk::OS` to avoid clashing with os gem when installed for users
|
data/LICENSE.txt
CHANGED
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.52
|
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)
|
@@ -19,9 +19,9 @@ The trade-off is that while [SWT](https://www.eclipse.org/swt/) provides a pleth
|
|
19
19
|
- Convention over configuration via smart defaults and automation of low-level details
|
20
20
|
- Requiring the least amount of syntax possible to build GUI
|
21
21
|
- Bidirectional Data-Binding to declaratively wire and automatically synchronize GUI with Business Models
|
22
|
-
- Custom Widget support
|
23
|
-
- Scaffolding for new custom widgets, apps, and gems
|
24
|
-
- Native-Executable packaging on Mac, Windows, and Linux
|
22
|
+
- (Future Plan) Custom Widget support
|
23
|
+
- (Future Plan) Scaffolding for new custom widgets, apps, and gems
|
24
|
+
- (Future Plan) Native-Executable packaging on Mac, Windows, and Linux
|
25
25
|
|
26
26
|
**Hello, World!**
|
27
27
|
|
@@ -51,7 +51,7 @@ Glimmer app:
|
|
51
51
|
|
52
52
|
![glimmer dsl tk screenshot sample hello world](images/glimmer-dsl-tk-screenshot-sample-hello-world.png)
|
53
53
|
|
54
|
-
NOTE: Glimmer DSL for Tk is currently in early alpha mode (
|
54
|
+
NOTE: Glimmer DSL for Tk is currently in early alpha mode (only about 44% complete). If you want it developed faster, then [open an issue report](https://github.com/AndyObtiva/glimmer-dsl-tk/issues/new). I have completed some features much faster before due to [issue reports](https://github.com/AndyObtiva/glimmer-dsl-tk/issues) and [pull requests](https://github.com/AndyObtiva/glimmer-dsl-tk/pulls). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
|
55
55
|
|
56
56
|
Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems you might be interested in:
|
57
57
|
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
|
@@ -86,6 +86,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems you might be int
|
|
86
86
|
- [Icon Photo](#icon-photo)
|
87
87
|
- [Root Background](#root-background)
|
88
88
|
- [Toplevel Mac Style](#toplevel-mac-style)
|
89
|
+
- [Root/Toplevel Centered Within Screen](#root-toplevel-centered-within-screen)
|
89
90
|
- [Text Defaults](#text-defaults)
|
90
91
|
- [The Grid Geometry Manager](#the-grid-geometry-manager)
|
91
92
|
- [Data-Binding](#data-binding)
|
@@ -125,6 +126,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems you might be int
|
|
125
126
|
- [Hello, Scrollbar!](#hello-scrollbar)
|
126
127
|
- [Hello, Scrollbar Frame!](#hello-scrollbar-frame)
|
127
128
|
- [Hello, Menu Bar!](#hello-menu-bar)
|
129
|
+
- [Hello, Contextual Menu!](#hello-contextual-menu)
|
128
130
|
- [Applications](#applications)
|
129
131
|
- [Glimmer Tk Calculator](#glimmer-tk-calculator)
|
130
132
|
- [Y3network Ruby UI](#y3network-ruby-ui)
|
@@ -143,24 +145,24 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems you might be int
|
|
143
145
|
|
144
146
|
## Pre-requisites
|
145
147
|
|
146
|
-
- [Tcl/Tk](https://www.tcl.tk/): Follow the [install instructions](https://tkdocs.com/tutorial/install.html)
|
148
|
+
- [Tcl/Tk 8.6](https://www.tcl.tk/): Follow the exact instructions below (if a further reference is needed, here are the [official install instructions](https://tkdocs.com/tutorial/install.html))
|
147
149
|
- [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).
|
148
150
|
|
149
|
-
|
150
|
-
- Install the ActiveTcl Mac package from [ActiveState.com](https://activestate.com)
|
151
|
+
**Mac:**
|
152
|
+
- Install the ActiveTcl 8.6 Mac package from [ActiveState.com](https://activestate.com)
|
151
153
|
- 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)
|
152
154
|
- Run: `rvm install 3.0.2 --enable-shared --enable-pthread --with-tk --with-tcl`
|
153
155
|
- Run: `gem install tk -v0.4.0`
|
154
156
|
|
155
|
-
|
157
|
+
**Windows:**
|
156
158
|
- Install Ruby+Devkit (including MSYS/MINGW toolchains) through Windows Installer: https://rubyinstaller.org/downloads/
|
157
|
-
- Install the ActiveTcl Windows package from [ActiveState.com](https://activestate.com)
|
159
|
+
- Install the ActiveTcl 8.6 Windows package from [ActiveState.com](https://activestate.com)
|
158
160
|
- 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."
|
159
161
|
- Setup environment variables TCL_LIBRARY=C:\ActiveTcl\lib\tcl8.6 & TK_LIBRARY=C:\ActiveTcl\lib\tk8.6
|
160
162
|
- Run: `gem install tk -v0.4.0`
|
161
163
|
|
162
|
-
|
163
|
-
- Download the ActiveTcl Linux package from [ActiveState.com](https://activestate.com)
|
164
|
+
**Linux:**
|
165
|
+
- Download the ActiveTcl 8.6 Linux package from [ActiveState.com](https://activestate.com)
|
164
166
|
- Extract the tar gz file using command `tar zxvf ActiveTcl-version-number.tar.gz`
|
165
167
|
- Run included install shell script `./ActiveTcl-version-number/install.sh`
|
166
168
|
- 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)
|
@@ -171,6 +173,8 @@ Afterwards, if you open `irb`, you should be able to run `require 'tk'` successf
|
|
171
173
|
|
172
174
|
## Setup
|
173
175
|
|
176
|
+
Assuming you have all [Pre-Requisites](#pre-requisites) ready, follow these instructions to setup the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-tk).
|
177
|
+
|
174
178
|
### Option 1: Install
|
175
179
|
|
176
180
|
Run this command to install directly:
|
@@ -182,7 +186,7 @@ gem install glimmer-dsl-tk
|
|
182
186
|
|
183
187
|
Add the following to `Gemfile`:
|
184
188
|
```
|
185
|
-
gem 'glimmer-dsl-tk', '0.0.
|
189
|
+
gem 'glimmer-dsl-tk', '0.0.52'
|
186
190
|
```
|
187
191
|
|
188
192
|
And, then run:
|
@@ -208,6 +212,7 @@ Tk Concepts consist of:
|
|
208
212
|
- [Widgets](https://tkdocs.com/tutorial/concepts.html#widgets): Widgets are all the things that you see onscreen. In our example, we had a button, an entry, a few labels, and a frame. Others are things like checkboxes, tree views, scrollbars, text areas, and so on. Widgets are what are often referred to as "controls"; you'll also often see them referred to as "windows," particularly in Tk's documentation, a holdover from its X11 roots (so under that terminology, both a toplevel window and things like a button would be called windows).
|
209
213
|
- [Geometry Management](https://tkdocs.com/tutorial/concepts.html#geometry): If you've been playing around creating widgets, you've probably noticed that just by creating them, they didn't end up showing up onscreen. Having things actually put in the onscreen window, and precisely where in the window they show up is a separate step called geometry management.
|
210
214
|
- [Event Handling](https://tkdocs.com/tutorial/concepts.html#events): In Tk, as in most other user interface toolkits, there is an event loop which receives events from the operating system. These are things like button presses, keystrokes, mouse movement, window resizing, and so on.
|
215
|
+
- [Themes](https://tkdocs.com/tutorial/styles.html): Tk apps are themable. You can list available themes with `::Tk::Tile::Style.theme_names` (e.g. `["aqua", "clam", "alt", "default", "classic"]` on Mac) and select a theme with `::Tk::Tile::Style.theme_use 'theme_name'` (e.g. `::Tk::Tile::Style.theme_use 'classic'`). Theme defaults to `'clam'` in Linux and `'aqua'` in Mac.
|
211
216
|
|
212
217
|
Learn more at the official [Tk Concepts Tutorial](https://tkdocs.com/tutorial/concepts.html)
|
213
218
|
|
@@ -310,6 +315,7 @@ keyword(args) | attributes | event bindings & callbacks
|
|
310
315
|
`list` | `selectmode`, `selection` | None
|
311
316
|
`message_box(type: , message: , detail: , title: , icon: , default: , parent: )` | None | None
|
312
317
|
`menu(label: nil) (label is nil if nested under root/toplevel for menu bar)` | None | None
|
318
|
+
`menu_bar` | None | None
|
313
319
|
`menu_item(style = :command, label: , underline: )` (style also can be `:radiobutton`, `:checkbutton`, `:separator`, `:about`, `:preferences`, `:quit`, `:help`) | `state`, `accelerator`, `selection` & `variable` (if `:radiobutton` or `:checkbutton`), `image`, `compound` | `command`
|
314
320
|
`notebook` | None | None
|
315
321
|
`radiobutton` | `text`, `variable` (Boolean), `image` (optional keyword args: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`), `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `value` (default: `text`) | `command {}`
|
@@ -480,13 +486,13 @@ Check out the [Hello, Scrollbar!](#hello-scrollbar) sample for a `text` demo wit
|
|
480
486
|
|
481
487
|
#### Drag and Drop API
|
482
488
|
|
483
|
-
|
489
|
+
Thanks to the vision of [vin1antme](https://github.com/vin1antme) (contributor), drag and drop works by simply designating a widget as a draggable with attribute `drag_source true` and another widget as a droppable with attribute `drop_target true`.
|
484
490
|
|
485
|
-
Alternatively, add listeners on the
|
491
|
+
Alternatively, for advanced customization, add listeners on the draggable:
|
486
492
|
- `on('drag_start') {|event| ...}`: fires on drag start receiving an `event` arg to set `data` and configure `source`
|
487
493
|
- `on('drag_motion') {|event| ...}`: fires on drag motion receiving an `event` arg to check `event#drop_accepted`, and configure `source` and `tooltip`
|
488
494
|
|
489
|
-
And
|
495
|
+
And, add a listener on the droppable:
|
490
496
|
- `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.
|
491
497
|
|
492
498
|
These are all the available attributes on event, which is of type `DragAndDropEvent`:
|
@@ -578,6 +584,10 @@ Tk.tk_call("::tk::unsupported::MacWindowStyle", "style", tk_toplevel_widget, mac
|
|
578
584
|
|
579
585
|
More details can be found at the [Hello, Toplevel!](#hello-toplevel) sample.
|
580
586
|
|
587
|
+
#### Root/Toplevel Centered Within Screen
|
588
|
+
|
589
|
+
`root` and `toplevel` are centered within screen by default unless `x` or `y` attributes are specified, in which case, they are honored instead.
|
590
|
+
|
581
591
|
#### Text Defaults
|
582
592
|
|
583
593
|
`text` widget has these defaults:
|
@@ -616,7 +626,25 @@ More details can be found in the [Hello, Computed!](#hello-computed) sample belo
|
|
616
626
|
|
617
627
|
## Data-Binding
|
618
628
|
|
619
|
-
Glimmer supports Shine syntax bidirectional data-binding via the `<=>` operator (read-write) and unidirectional data-binding via the `<=` operator (read-only), which takes a model and an attribute (the `bind` keyword may also be used as the old-style of data-binding).
|
629
|
+
Glimmer supports Shine syntax bidirectional data-binding via the `<=>` operator (read-write) and unidirectional data-binding via the `<=` operator (read-only), which takes a model and an attribute (the `bind(model, attribute, *options)` keyword may also be used as the old-style of data-binding).
|
630
|
+
|
631
|
+
To summarize the data-binding API:
|
632
|
+
- `view_property <=> [model, attribute, *read_or_write_options]`: Bidirectional (two-way) data-binding to Model attribute accessor
|
633
|
+
- `view_property <= [model, attribute, *read_only_options]`: Unidirectional (one-way) data-binding to Model attribute reader
|
634
|
+
|
635
|
+
Data-bound model attribute can be:
|
636
|
+
- **Direct:** `Symbol` representing attribute reader/writer (e.g. `[person, :name`])
|
637
|
+
- **Nested:** `String` representing nested attribute path (e.g. `[company, 'address.street']`). That results in "nested data-binding"
|
638
|
+
- **Indexed:** `String` containing array attribute index (e.g. `[customer, 'addresses[0].street']`). That results in "indexed data-binding"
|
639
|
+
|
640
|
+
Data-binding options include:
|
641
|
+
- `before_read {|value| ...}`: performs an operation before reading data from Model to update View.
|
642
|
+
- `on_read {|value| ...}`: converts value read from Model to update the View.
|
643
|
+
- `after_read {|converted_value| ...}`: performs an operation after read from Model to update View.
|
644
|
+
- `before_write {|value| ...}`: performs an operation before writing data to Model from View.
|
645
|
+
- `on_write {|value| ...}`: converts value read from View to update the Model.
|
646
|
+
- `after_write {|converted_value| ...}`: performs an operation after writing to Model from View.
|
647
|
+
- `computed_by attribute` or `computed_by [attribute1, attribute2, ...]`: indicates model attribute is computed from specified attribute(s), thus updated when they are updated. That is known as "computed data-binding".
|
620
648
|
|
621
649
|
### Label Data-Binding
|
622
650
|
|
@@ -3232,7 +3260,7 @@ root { |r|
|
|
3232
3260
|
anchor 'center'
|
3233
3261
|
}
|
3234
3262
|
|
3235
|
-
|
3263
|
+
menu_bar {
|
3236
3264
|
# Mac-specific application menu (right next to the Apple menu)
|
3237
3265
|
if OS.mac?
|
3238
3266
|
menu(:application) {
|
@@ -3357,16 +3385,24 @@ root { |r|
|
|
3357
3385
|
menu_item(:radiobutton, label: image_name.capitalize) {
|
3358
3386
|
selection image_name == 'usa'
|
3359
3387
|
image File.expand_path("images/#{image_name}.png", __dir__)
|
3388
|
+
|
3389
|
+
on('command') do
|
3390
|
+
message_box(parent: r, title: 'Language Selection', message: "You selected the language of #{image_name.capitalize}!")
|
3391
|
+
end
|
3360
3392
|
}
|
3361
3393
|
end
|
3362
3394
|
}
|
3363
3395
|
|
3364
|
-
menu(label: 'Country', underline:
|
3396
|
+
menu(label: 'Country', underline: 0) {
|
3365
3397
|
['denmark', 'finland', 'france', 'germany', 'italy', 'mexico', 'netherlands', 'norway', 'usa'].each do |image_name|
|
3366
3398
|
menu_item(:radiobutton, label: image_name.capitalize) {
|
3367
3399
|
selection image_name == 'usa'
|
3368
3400
|
image File.expand_path("images/#{image_name}.png", __dir__)
|
3369
3401
|
compound 'left'
|
3402
|
+
|
3403
|
+
on('command') do
|
3404
|
+
message_box(parent: r, title: 'Country Selection', message: "You selected the country of #{image_name.capitalize}!")
|
3405
|
+
end
|
3370
3406
|
}
|
3371
3407
|
end
|
3372
3408
|
}
|
@@ -3496,6 +3532,200 @@ Glimmer app:
|
|
3496
3532
|
|
3497
3533
|
![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-help.png)
|
3498
3534
|
|
3535
|
+
### Hello, Contextual Menu!
|
3536
|
+
|
3537
|
+
Glimmer code (from [samples/hello/hello_contextual_menu.rb](samples/hello/hello_contextual_menu.rb)):
|
3538
|
+
|
3539
|
+
```ruby
|
3540
|
+
require 'glimmer-dsl-tk'
|
3541
|
+
|
3542
|
+
include Glimmer
|
3543
|
+
|
3544
|
+
COLORS = [:white, :red, :yellow, :green, :blue, :magenta, :gray, :black]
|
3545
|
+
|
3546
|
+
Tk::Tile::Style.theme_use 'classic' if OS.mac? # this enables setting background on label just for demo purposes
|
3547
|
+
|
3548
|
+
root { |r|
|
3549
|
+
title 'Hello, Contextual Menu!'
|
3550
|
+
|
3551
|
+
@label = label {
|
3552
|
+
grid row_weight: 1, column_weight: 1
|
3553
|
+
text 'Right-Click To Pop Up Contextual Menu!'
|
3554
|
+
font size: 50
|
3555
|
+
anchor 'center'
|
3556
|
+
}
|
3557
|
+
|
3558
|
+
# Contextual Menu is bound to mouse right-click (and CTRL-click on Mac) by default
|
3559
|
+
# (Read Comment Below for Alternative)
|
3560
|
+
menu {
|
3561
|
+
menu(label: 'Edit', underline: 0) {
|
3562
|
+
menu_item(label: 'Cut', underline: 2) {
|
3563
|
+
accelerator OS.mac? ? 'Command+X' : 'Control+X'
|
3564
|
+
}
|
3565
|
+
|
3566
|
+
menu_item(label: 'Copy', underline: 0) {
|
3567
|
+
accelerator OS.mac? ? 'Command+C' : 'Control+C'
|
3568
|
+
}
|
3569
|
+
|
3570
|
+
menu_item(label: 'Paste', underline: 0) {
|
3571
|
+
accelerator OS.mac? ? 'Command+V' : 'Control+V'
|
3572
|
+
}
|
3573
|
+
}
|
3574
|
+
|
3575
|
+
menu(label: 'Options', underline: 0) {
|
3576
|
+
menu_item(:checkbutton, label: 'Enabled', underline: 0) {
|
3577
|
+
on('command') do
|
3578
|
+
@select_one_menu.children.each { |menu_item| menu_item.state = menu_item.state == 'disabled' ? 'normal' : 'disabled' }
|
3579
|
+
@select_multiple_menu.children.each { |menu_item| menu_item.state = menu_item.state == 'disabled' ? 'normal' : 'disabled' }
|
3580
|
+
end
|
3581
|
+
}
|
3582
|
+
|
3583
|
+
@select_one_menu = menu(label: 'Select One', underline: 7) {
|
3584
|
+
menu_item(:radiobutton, label: 'Option 1') {
|
3585
|
+
state 'disabled'
|
3586
|
+
}
|
3587
|
+
menu_item(:radiobutton, label: 'Option 2') {
|
3588
|
+
state 'disabled'
|
3589
|
+
}
|
3590
|
+
menu_item(:radiobutton, label: 'Option 3') {
|
3591
|
+
state 'disabled'
|
3592
|
+
}
|
3593
|
+
}
|
3594
|
+
|
3595
|
+
@select_multiple_menu = menu(label: 'Select Multiple', underline: 7) {
|
3596
|
+
menu_item(:checkbutton, label: 'Option 4') {
|
3597
|
+
state 'disabled'
|
3598
|
+
}
|
3599
|
+
menu_item(:checkbutton, label: 'Option 5') {
|
3600
|
+
state 'disabled'
|
3601
|
+
}
|
3602
|
+
menu_item(:checkbutton, label: 'Option 6') {
|
3603
|
+
state 'disabled'
|
3604
|
+
}
|
3605
|
+
}
|
3606
|
+
}
|
3607
|
+
|
3608
|
+
menu(label: 'Language', underline: 3) {
|
3609
|
+
['denmark', 'finland', 'france', 'germany', 'italy', 'mexico', 'netherlands', 'norway', 'usa'].each do |image_name|
|
3610
|
+
menu_item(:radiobutton, label: image_name.capitalize) {
|
3611
|
+
selection image_name == 'usa'
|
3612
|
+
image File.expand_path("images/#{image_name}.png", __dir__)
|
3613
|
+
|
3614
|
+
on('command') do
|
3615
|
+
message_box(parent: r, title: 'Language Selection', message: "You selected the language of #{image_name.capitalize}!")
|
3616
|
+
end
|
3617
|
+
}
|
3618
|
+
end
|
3619
|
+
}
|
3620
|
+
|
3621
|
+
menu(label: 'Country', underline: 0) {
|
3622
|
+
['denmark', 'finland', 'france', 'germany', 'italy', 'mexico', 'netherlands', 'norway', 'usa'].each do |image_name|
|
3623
|
+
menu_item(:radiobutton, label: image_name.capitalize) {
|
3624
|
+
selection image_name == 'usa'
|
3625
|
+
image File.expand_path("images/#{image_name}.png", __dir__)
|
3626
|
+
compound 'left'
|
3627
|
+
|
3628
|
+
on('command') do
|
3629
|
+
message_box(parent: r, title: 'Country Selection', message: "You selected the country of #{image_name.capitalize}!")
|
3630
|
+
end
|
3631
|
+
}
|
3632
|
+
end
|
3633
|
+
}
|
3634
|
+
|
3635
|
+
menu(label: 'Format', underline: 3) {
|
3636
|
+
menu(label: 'Background Color', underline: 0) {
|
3637
|
+
COLORS.each { |color_style|
|
3638
|
+
menu_item(:radiobutton, label: color_style.to_s.split('_').map(&:capitalize).join(' ')) {
|
3639
|
+
on('command') do
|
3640
|
+
@label.background = color_style
|
3641
|
+
end
|
3642
|
+
}
|
3643
|
+
}
|
3644
|
+
}
|
3645
|
+
|
3646
|
+
menu(label: 'Foreground Color', underline: 11) {
|
3647
|
+
COLORS.each { |color_style|
|
3648
|
+
menu_item(:radiobutton, label: color_style.to_s.split('_').map(&:capitalize).join(' ')) {
|
3649
|
+
on('command') do
|
3650
|
+
@label.foreground = color_style
|
3651
|
+
end
|
3652
|
+
}
|
3653
|
+
}
|
3654
|
+
}
|
3655
|
+
}
|
3656
|
+
|
3657
|
+
menu(label: 'View', underline: 0) {
|
3658
|
+
menu_item(:radiobutton, label: 'Small', underline: 0) {
|
3659
|
+
accelerator 'Control+S'
|
3660
|
+
|
3661
|
+
on('command') do
|
3662
|
+
@label.font = {size: 25}
|
3663
|
+
end
|
3664
|
+
}
|
3665
|
+
|
3666
|
+
menu_item(:radiobutton, label: 'Medium', underline: 0) {
|
3667
|
+
accelerator 'Control+M'
|
3668
|
+
selection true
|
3669
|
+
|
3670
|
+
on('command') do
|
3671
|
+
@label.font = {size: 50}
|
3672
|
+
end
|
3673
|
+
}
|
3674
|
+
|
3675
|
+
menu_item(:radiobutton, label: 'Large', underline: 0) {
|
3676
|
+
accelerator 'Control+L'
|
3677
|
+
|
3678
|
+
on('command') do
|
3679
|
+
@label.font = {size: 75}
|
3680
|
+
end
|
3681
|
+
}
|
3682
|
+
}
|
3683
|
+
}
|
3684
|
+
|
3685
|
+
# You can replace `menu {` code with `menu(bind: false) {` if you want to bind manually,
|
3686
|
+
# which can be useful if you want to show menu at a specific location based on conditional logic.
|
3687
|
+
#
|
3688
|
+
# You can also repurpose a `menu_bar` as a contextual menu by declaring `@menu = menu_bar {` and
|
3689
|
+
# binding to mouse right-click.
|
3690
|
+
#
|
3691
|
+
# Example:
|
3692
|
+
#
|
3693
|
+
# @menu = menu(bind: false) {
|
3694
|
+
# menu(label: 'File', underline: 0) {
|
3695
|
+
# menu_item(label: 'Exit')
|
3696
|
+
# }
|
3697
|
+
# }
|
3698
|
+
# if OS.mac?
|
3699
|
+
# on('2') do |event|
|
3700
|
+
# @menu.popup(event.x_root, event.y_root)
|
3701
|
+
# end
|
3702
|
+
# on('Control-1') do |event|
|
3703
|
+
# @menu.popup(event.x_root, event.y_root)
|
3704
|
+
# end
|
3705
|
+
# else
|
3706
|
+
# on('3') do |event|
|
3707
|
+
# @menu.popup(event.x_root, event.y_root)
|
3708
|
+
# end
|
3709
|
+
# end
|
3710
|
+
}.open
|
3711
|
+
```
|
3712
|
+
|
3713
|
+
Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
3714
|
+
|
3715
|
+
```
|
3716
|
+
ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_contextual_menu'"
|
3717
|
+
```
|
3718
|
+
|
3719
|
+
Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
3720
|
+
|
3721
|
+
```
|
3722
|
+
ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_contextual_menu.rb
|
3723
|
+
```
|
3724
|
+
|
3725
|
+
Glimmer app:
|
3726
|
+
|
3727
|
+
![glimmer dsl tk screenshot sample hello contextual-menu](images/glimmer-dsl-tk-screenshot-sample-hello-contextual-menu.png)
|
3728
|
+
|
3499
3729
|
## Applications
|
3500
3730
|
|
3501
3731
|
### Glimmer Tk Calculator
|
@@ -3522,10 +3752,10 @@ https://github.com/cryptopunksnotdead/cryptopunks-gui
|
|
3522
3752
|
|
3523
3753
|
Generate an icon of overlapping circles derived from a hash.
|
3524
3754
|
|
3525
|
-
https://gitlab.com/fjc/circule
|
3526
|
-
|
3527
3755
|
[Demo Video](https://gitlab.com/fjc/circule/-/raw/master/circule-demo.mp4)
|
3528
3756
|
|
3757
|
+
https://gitlab.com/fjc/circule
|
3758
|
+
|
3529
3759
|
## Process
|
3530
3760
|
|
3531
3761
|
[Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
|
@@ -3570,7 +3800,7 @@ These features have been planned or suggested. You might see them in a future ve
|
|
3570
3800
|
|
3571
3801
|
[MIT](LICENSE.txt)
|
3572
3802
|
|
3573
|
-
Copyright (c) 2020-
|
3803
|
+
Copyright (c) 2020-2022 - Andy Maleh.
|
3574
3804
|
|
3575
3805
|
--
|
3576
3806
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.52
|
data/bin/girb
CHANGED
data/bin/girb_runner.rb
CHANGED
data/glimmer-dsl-tk.gemspec
CHANGED
Binary file
|
data/lib/glimmer/dsl/tk/dsl.rb
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2020-2022 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
|
+
|
1
22
|
module Glimmer
|
2
23
|
module Tk
|
3
24
|
DragAndDropEvent = Struct.new(:source, :target, :tooltip, :x_root, :y_root, :data, :drop_accepted) do
|