glimmer-dsl-tk 0.0.1 → 0.0.6
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 +483 -14
- data/VERSION +1 -1
- data/bin/girb +10 -0
- data/bin/girb_runner.rb +26 -0
- data/lib/glimmer-dsl-tk.rb +3 -3
- data/lib/glimmer/data_binding/tk/list_selection_binding.rb +75 -0
- data/lib/glimmer/data_binding/tk/widget_binding.rb +28 -0
- data/lib/glimmer/dsl/tk/bind_expression.rb +36 -0
- data/lib/glimmer/dsl/tk/block_attribute_expression.rb +41 -0
- data/lib/glimmer/dsl/tk/data_binding_expression.rb +33 -0
- data/lib/glimmer/dsl/tk/dsl.rb +3 -0
- data/lib/glimmer/dsl/tk/list_selection_data_binding_expression.rb +60 -0
- data/lib/glimmer/dsl/tk/widget_expression.rb +8 -2
- data/lib/glimmer/tk/button_proxy.rb +35 -0
- data/lib/glimmer/tk/entry_proxy.rb +38 -0
- data/lib/glimmer/tk/frame_proxy.rb +42 -0
- data/lib/glimmer/tk/label_proxy.rb +40 -0
- data/lib/glimmer/tk/list_proxy.rb +60 -0
- data/lib/glimmer/tk/notebook_proxy.rb +45 -0
- data/lib/glimmer/tk/root_proxy.rb +2 -2
- data/lib/glimmer/tk/widget_proxy.rb +163 -37
- data/samples/hello/hello_combo.rb +61 -0
- data/samples/hello/hello_computed.rb +75 -0
- data/samples/hello/hello_computed/contact.rb +21 -0
- data/samples/hello/hello_list_multi_selection.rb +69 -0
- data/samples/hello/hello_list_single_selection.rb +60 -0
- data/samples/hello/hello_tab.rb +48 -0
- data/samples/hello/hello_world.rb +2 -0
- metadata +71 -130
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a698eb9785a297545f7c879869fffe03d02df435bad1fb171b85d1af19341fdd
|
4
|
+
data.tar.gz: e71786ce5dcb1690106cbedab23f65db7e309fa9883a68a9485f6125a277b07a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 856e889c04d9f487bfb3360615af33caf1d58192835bac629278ebf1fef47e1d3c16bb6ab0a8e5e1f7f8314bfd2a5c953452512e4515c0e1986de65db8d9df90
|
7
|
+
data.tar.gz: b6e1d0612e66b63d73e1c613712c3d3e1a6c4ff4eb7352e7e7c248a6012fe480f533530b14c525a68585bdd89ecb05a95c0030f83511ae9cd4484fc95980d950
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.6
|
4
|
+
|
5
|
+
- Upgraded to tk 0.3.0
|
6
|
+
|
7
|
+
## 0.0.5
|
8
|
+
|
9
|
+
- Label text data-binding
|
10
|
+
- Entry text data-binding
|
11
|
+
- The `grid` geometry manager
|
12
|
+
- Hello, Computed! sample
|
13
|
+
|
14
|
+
## 0.0.4
|
15
|
+
|
16
|
+
- `list` custom widget (since listbox is not tile themed yet in Tk)
|
17
|
+
- `girb` (Glimmer IRB)
|
18
|
+
- Hello, List Single Selection! sample
|
19
|
+
- Hello, List Multi Selection! sample
|
20
|
+
|
21
|
+
## 0.0.3
|
22
|
+
|
23
|
+
- Combobox support
|
24
|
+
- Button command event observer support
|
25
|
+
- Combobox text data-binding
|
26
|
+
- Hello, Combo! sample
|
27
|
+
|
28
|
+
## 0.0.2
|
29
|
+
|
30
|
+
- Notebook/frame support
|
31
|
+
- Hello, Tab! sample
|
32
|
+
|
3
33
|
## 0.0.1
|
4
34
|
|
5
35
|
- Initial Glimmer DSL for TK implementation to support Hello, World!
|
data/README.md
CHANGED
@@ -1,22 +1,54 @@
|
|
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.6
|
2
|
+
## Ruby Desktop Development GUI Library
|
2
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-tk.svg)](http://badge.fury.io/rb/glimmer-dsl-tk)
|
4
|
+
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-tk.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-tk)
|
5
|
+
[![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
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/ce2853efdbecf6ebdc73/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-tk/maintainability)
|
3
7
|
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
8
|
|
5
|
-
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [Tk](https://www.tcl.tk/) enables desktop development with [Glimmer](https://github.com/AndyObtiva/glimmer).
|
9
|
+
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [Tk](https://www.tcl.tk/) enables desktop development with [Glimmer](https://github.com/AndyObtiva/glimmer) in [Ruby](https://github.com/ruby/ruby).
|
6
10
|
|
7
|
-
[Tcl/Tk](https://www.tcl.tk/) has evolved into a practical desktop GUI toolkit due to gaining
|
11
|
+
[Tcl/Tk](https://www.tcl.tk/) has evolved into a practical desktop GUI toolkit due to gaining truly native looking themed widgets on Mac, Windows, and Linux in [Tk version 8.5](https://www.tcl.tk/software/tcltk/8.5.html#:~:text=Highlights%20of%20Tk%208.5&text=Font%20rendering%3A%20Now%20uses%20anti,and%20window%20layout%2C%20and%20more.).
|
8
12
|
|
9
|
-
Additionally, Ruby 3.0 supports truly parallel multi-threading, making both [MRI](https://github.com/ruby/ruby) and [Tk](https://www.tcl.tk/) finally viable for support in [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development GUI Library).
|
13
|
+
Additionally, [Ruby](https://www.ruby-lang.org/en/) 3.0 Ractor (formerly known as [Guilds](https://olivierlacan.com/posts/concurrency-in-ruby-3-with-guilds/)) supports truly parallel multi-threading, making both [MRI](https://github.com/ruby/ruby) and [Tk](https://www.tcl.tk/) finally viable for support in [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development GUI Library) as an alternative to [JRuby on SWT](https://github.com/AndyObtiva/glimmer-dsl-swt).
|
10
14
|
|
11
|
-
[
|
15
|
+
The trade-off is that while [SWT](https://www.eclipse.org/swt/) provides a plethora of high quality reusable widgets for the Enterprise (such as [Nebula](https://www.eclipse.org/nebula/)), [Tk](https://www.tcl.tk/) enables very fast app startup time via [MRI Ruby](https://www.ruby-lang.org/en/).
|
16
|
+
|
17
|
+
[Glimmer](https://github.com/AndyObtiva/glimmer) aims to provide a DSL similar to the [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) to enable more productive desktop development in Ruby with:
|
12
18
|
- Declarative DSL syntax that visually maps to the GUI widget hierarchy
|
13
19
|
- Convention over configuration via smart defaults and automation of low-level details
|
14
20
|
- Requiring the least amount of syntax possible to build GUI
|
21
|
+
- Bidirectional Data-Binding to declaratively wire and automatically synchronize GUI with Business Models
|
22
|
+
- Custom Widget support
|
15
23
|
- Scaffolding for new custom widgets, apps, and gems
|
16
24
|
- Native-Executable packaging on Mac, Windows, and Linux
|
17
25
|
|
26
|
+
**Hello, World!**
|
27
|
+
|
28
|
+
Glimmer code (from [samples/hello/hello_world.rb](samples/hello/hello_world.rb)):
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
root {
|
32
|
+
label {
|
33
|
+
text 'Hello, World!'
|
34
|
+
}
|
35
|
+
}.open
|
36
|
+
```
|
37
|
+
|
38
|
+
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
39
|
+
|
40
|
+
```
|
41
|
+
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_world.rb'"
|
42
|
+
```
|
43
|
+
|
44
|
+
Glimmer app:
|
45
|
+
|
46
|
+
![glimmer dsl tk screenshot sample hello world](images/glimmer-dsl-tk-screenshot-sample-hello-world.png)
|
47
|
+
|
48
|
+
NOTE: Glimmer DSL for Tk is in alpha mode. 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.
|
49
|
+
|
18
50
|
Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
19
|
-
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (Desktop GUI
|
51
|
+
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop GUI)
|
20
52
|
- [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
|
21
53
|
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
|
22
54
|
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
|
@@ -46,7 +78,7 @@ gem install glimmer-dsl-tk
|
|
46
78
|
|
47
79
|
Add the following to `Gemfile`:
|
48
80
|
```
|
49
|
-
gem 'glimmer-dsl-tk', '~> 0.0.
|
81
|
+
gem 'glimmer-dsl-tk', '~> 0.0.6'
|
50
82
|
```
|
51
83
|
|
52
84
|
And, then run:
|
@@ -54,13 +86,235 @@ And, then run:
|
|
54
86
|
bundle
|
55
87
|
```
|
56
88
|
|
57
|
-
##
|
89
|
+
## Girb (Glimmer IRB)
|
90
|
+
|
91
|
+
You can run the `girb` command (`bin/girb` if you cloned the project locally):
|
92
|
+
|
93
|
+
```
|
94
|
+
girb
|
95
|
+
```
|
96
|
+
|
97
|
+
This gives you `irb` with the `glimmer-dsl-tk` gem loaded and the `Glimmer` module mixed into the main object for easy experimentation with GUI.
|
98
|
+
|
99
|
+
## Tk Concepts
|
100
|
+
|
101
|
+
Here is a summary taken from the official [Tk Concepts Tutorial](https://tkdocs.com/tutorial/concepts.html)
|
102
|
+
|
103
|
+
Tk Concepts consist of:
|
104
|
+
- [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).
|
105
|
+
- [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.
|
106
|
+
- [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.
|
107
|
+
|
108
|
+
Learn more at the official [Tk Concepts Tutorial](https://tkdocs.com/tutorial/concepts.html)
|
109
|
+
|
110
|
+
## Glimmer GUI DSL Concepts
|
111
|
+
|
112
|
+
The Glimmer GUI DSL provides a declarative syntax for [Tk](https://www.tcl.tk/) that:
|
113
|
+
- Supports smart defaults (e.g. grid layout on most widgets)
|
114
|
+
- Automates wiring of widgets (e.g. nesting a label under a toplevel root or adding a frame to a notebook)
|
115
|
+
- Hides lower-level details (e.g. main loop is started automatically when opening a window)
|
116
|
+
- Nests widgets according to their visual hierarchy
|
117
|
+
- Requires the minimum amount of syntax needed to describe an app's GUI
|
118
|
+
|
119
|
+
The Glimmer GUI DSL follows these simple concepts in mapping from Tk syntax:
|
120
|
+
- **Widget Keyword**: Any Tk widget (e.g. `Tk::Tile::Label`) or toplevel window (e.g. `TkRoot`) may be declared by its lower-case underscored name without the namespace (e.g. `label` or `root`). This is called a keyword and is represented in the Glimmer GUI DSL by a Ruby method behind the scenes.
|
121
|
+
- **Args**: Any keyword method may optionally take arguments surrounded by parentheses (e.g. a `frame` nested under a `notebook` may receive tab options like `frame(text: 'Users')`, which gets used behind the scenes by Tk code such as `notebook.add tab, text: 'Users'`)
|
122
|
+
- **Content/Options Block**: Any keyword may optionally be followed by a Ruby curly-brace block containing nested widgets (content) and attributes (options). Attributes are simply Tk option keywords followed by arguments and no block (e.g. `title 'Hello, World!'` under a `root`)
|
123
|
+
|
124
|
+
Example of an app written in [Tk](https://www.tcl.tk/) imperative syntax:
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
root = TkRoot.new
|
128
|
+
root.title = 'Hello, Tab!'
|
129
|
+
|
130
|
+
notebook = ::Tk::Tile::Notebook.new(root).grid
|
131
|
+
|
132
|
+
tab1 = ::Tk::Tile::Frame.new(notebook).grid
|
133
|
+
notebook.add tab1, text: 'English'
|
134
|
+
label1 = ::Tk::Tile::Label.new(tab1).grid
|
135
|
+
label1.text = 'Hello, World!'
|
136
|
+
|
137
|
+
tab2 = ::Tk::Tile::Frame.new(notebook).grid
|
138
|
+
notebook.add tab2, text: 'French'
|
139
|
+
label2 = ::Tk::Tile::Label.new(tab2).grid
|
140
|
+
label2.text = 'Bonjour, Univers!'
|
141
|
+
|
142
|
+
root.mainloop
|
143
|
+
```
|
144
|
+
|
145
|
+
Example of the same app written in [Glimmer](https://github.com/AndyObtiva/glimmer) declarative syntax:
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
root {
|
149
|
+
title 'Hello, Tab!'
|
150
|
+
|
151
|
+
notebook {
|
152
|
+
frame(text: 'English') {
|
153
|
+
label {
|
154
|
+
text 'Hello, World!'
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
frame(text: 'French') {
|
159
|
+
label {
|
160
|
+
text 'Bonjour, Univers!'
|
161
|
+
}
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}.open
|
165
|
+
```
|
166
|
+
|
167
|
+
## The Grid Geometry Manager
|
168
|
+
|
169
|
+
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.
|
170
|
+
|
171
|
+
Example:
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
label {
|
175
|
+
grid column: 0, row: 2, sticky: 'w'
|
176
|
+
text 'Year of Birth: '
|
177
|
+
}
|
178
|
+
entry {
|
179
|
+
grid column: 1, row: 2
|
180
|
+
width 15
|
181
|
+
text bind(@contact, :year_of_birth)
|
182
|
+
}
|
183
|
+
```
|
184
|
+
|
185
|
+
More details can be found in the [Hello, Computed!](#hello-computed) sample below.
|
186
|
+
|
187
|
+
## Bidirectional Data-Binding
|
188
|
+
|
189
|
+
Glimmer supports bidirectional data-binding via the `bind` keyword, which takes a model and an attribute.
|
190
|
+
|
191
|
+
### Combo Data-Binding
|
192
|
+
|
193
|
+
Example:
|
194
|
+
|
195
|
+
This assumes a `Person` model with a `country` attribute representing their current country and a `country_options` attribute representing available options for the country attribute.
|
196
|
+
|
197
|
+
```ruby
|
198
|
+
combobox {
|
199
|
+
state 'readonly'
|
200
|
+
text bind(person, :country)
|
201
|
+
}
|
202
|
+
```
|
203
|
+
|
204
|
+
That code sets the `values` of the `combobox` to the `country_options` property on the `person` model (data-binding attribute + "_options" by convention).
|
205
|
+
It also binds the `text` selection of the `combobox` to the `country` property on the `person` model.
|
206
|
+
|
207
|
+
It automatically handles all the Tk plumbing behind the scenes, such as using `TkVariable` and setting `combobox` `values` from `person.country_options` by convention (attribute_name + "_options").
|
208
|
+
|
209
|
+
More details can be found in the [Hello, Combo!](#hello-combo) sample below.
|
210
|
+
|
211
|
+
### List Single Selection Data-Binding
|
212
|
+
|
213
|
+
Tk does not support a native themed listbox, so Glimmer implements its own `list` widget on top of `Tk::Tile::Treeview`. It is set to single selection via selectmode 'browse'.
|
214
|
+
|
215
|
+
Example:
|
216
|
+
|
217
|
+
This assumes a `Person` model with a `country` attribute representing their current country and a `country_options` attribute representing available options for the country attribute.
|
218
|
+
|
219
|
+
```ruby
|
220
|
+
list {
|
221
|
+
selectmode 'browse'
|
222
|
+
text bind(person, :country)
|
223
|
+
}
|
224
|
+
```
|
225
|
+
|
226
|
+
That code binds the `items` text of the `list` to the `country_options` property on the `person` model (data-binding attribute + "_options" by convention).
|
227
|
+
It also binds the `selection` text of the `list` to the `country` property on the `person` model.
|
228
|
+
|
229
|
+
It automatically handles all the Tk plumbing behind the scenes.
|
230
|
+
|
231
|
+
More details can be found in the [Hello, List Single Selection!](#hello-list-single-selection) sample below.
|
232
|
+
|
233
|
+
### List Multi Selection Data-Binding
|
234
|
+
|
235
|
+
Tk does not support a native themed listbox, so Glimmer implements its own `list` widget on top of `Tk::Tile::Treeview`. It is set to multi selection by default.
|
236
|
+
|
237
|
+
Example:
|
238
|
+
|
239
|
+
This assumes a `Person` model with a `provinces` attribute representing their current country and a `provinces_options` attribute representing available options for the provinces attribute.
|
240
|
+
|
241
|
+
```ruby
|
242
|
+
list {
|
243
|
+
text bind(person, :provinces)
|
244
|
+
}
|
245
|
+
```
|
246
|
+
|
247
|
+
That code binds the `items` text of the `list` to the `provinces_options` property on the `person` model (data-binding attribute + "_options" by convention).
|
248
|
+
It also binds the `selection` text of the `list` to the `provinces` property on the `person` model.
|
249
|
+
|
250
|
+
It automatically handles all the Tk plumbing behind the scenes.
|
251
|
+
|
252
|
+
More details can be found in the [Hello, List Multi Selection!](#hello-list-multi-selection) sample below.
|
253
|
+
|
254
|
+
### Label Data-Binding
|
255
|
+
|
256
|
+
Example:
|
257
|
+
|
258
|
+
This assumes a `Person` model with a `country` attribute.
|
259
|
+
|
260
|
+
```ruby
|
261
|
+
label {
|
262
|
+
text bind(person, :country)
|
263
|
+
}
|
264
|
+
```
|
265
|
+
|
266
|
+
That code binds the `textvariable` value of the `label` to the `country` property on the `person` model.
|
267
|
+
|
268
|
+
It automatically handles all the Tk plumbing behind the scenes.
|
58
269
|
|
59
|
-
|
270
|
+
More details can be found in the [Hello, Computed!](#hello-computed) sample below.
|
271
|
+
|
272
|
+
### Entry Data-Binding
|
273
|
+
|
274
|
+
Example:
|
275
|
+
|
276
|
+
This assumes a `Person` model with a `country` attribute.
|
277
|
+
|
278
|
+
```ruby
|
279
|
+
entry {
|
280
|
+
text bind(person, :country)
|
281
|
+
}
|
282
|
+
```
|
283
|
+
|
284
|
+
That code binds the `textvariable` value of the `entry` to the `country` property on the `person` model.
|
285
|
+
|
286
|
+
It automatically handles all the Tk plumbing behind the scenes.
|
287
|
+
|
288
|
+
More details can be found in the [Hello, Computed!](#hello-computed) sample below.
|
289
|
+
|
290
|
+
## Command Observer
|
291
|
+
|
292
|
+
Buttons can set a `command` option to trigger when the user clicks the button. This may be done with the `command` keyword, passing in a block directly (no need for `proc` as per Tk)
|
293
|
+
|
294
|
+
Example:
|
295
|
+
|
296
|
+
```ruby
|
297
|
+
button {
|
298
|
+
text "Reset Selection"
|
299
|
+
command {
|
300
|
+
person.reset_country
|
301
|
+
}
|
302
|
+
}
|
303
|
+
```
|
304
|
+
|
305
|
+
This resets the person country.
|
306
|
+
|
307
|
+
More details can be found in the [Hello, Combo!](#hello-combo) sample below.
|
308
|
+
|
309
|
+
## Samples
|
310
|
+
|
311
|
+
### Hello, World!
|
60
312
|
|
61
313
|
Glimmer code (from [samples/hello/hello_world.rb](samples/hello/hello_world.rb)):
|
62
314
|
|
63
315
|
```ruby
|
316
|
+
include Glimmer
|
317
|
+
|
64
318
|
root {
|
65
319
|
label {
|
66
320
|
text 'Hello, World!'
|
@@ -68,16 +322,227 @@ root {
|
|
68
322
|
}.open
|
69
323
|
```
|
70
324
|
|
71
|
-
Run:
|
325
|
+
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
72
326
|
|
73
327
|
```
|
74
|
-
ruby samples/hello/hello_world.rb
|
328
|
+
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_world.rb'"
|
75
329
|
```
|
76
330
|
|
77
331
|
Glimmer app:
|
78
332
|
|
79
333
|
![glimmer dsl tk screenshot sample hello world](images/glimmer-dsl-tk-screenshot-sample-hello-world.png)
|
80
334
|
|
335
|
+
### Hello, Tab!
|
336
|
+
|
337
|
+
Glimmer code (from [samples/hello/hello_tab.rb](samples/hello/hello_tab.rb)):
|
338
|
+
|
339
|
+
```ruby
|
340
|
+
include Glimmer
|
341
|
+
|
342
|
+
root {
|
343
|
+
title 'Hello, Tab!'
|
344
|
+
|
345
|
+
notebook {
|
346
|
+
frame(text: 'English') {
|
347
|
+
label {
|
348
|
+
text 'Hello, World!'
|
349
|
+
}
|
350
|
+
}
|
351
|
+
|
352
|
+
frame(text: 'French') {
|
353
|
+
label {
|
354
|
+
text 'Bonjour, Univers!'
|
355
|
+
}
|
356
|
+
}
|
357
|
+
}
|
358
|
+
}.open
|
359
|
+
```
|
360
|
+
|
361
|
+
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
362
|
+
|
363
|
+
```
|
364
|
+
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_tab.rb'"
|
365
|
+
```
|
366
|
+
|
367
|
+
Glimmer app:
|
368
|
+
|
369
|
+
![glimmer dsl tk screenshot sample hello tab English](images/glimmer-dsl-tk-screenshot-sample-hello-tab-english.png)
|
370
|
+
![glimmer dsl tk screenshot sample hello tab French](images/glimmer-dsl-tk-screenshot-sample-hello-tab-french.png)
|
371
|
+
|
372
|
+
### Hello, Combo!
|
373
|
+
|
374
|
+
Glimmer code (from [samples/hello/hello_combo.rb](samples/hello/hello_combo.rb)):
|
375
|
+
|
376
|
+
```ruby
|
377
|
+
# ... more code precedes
|
378
|
+
root {
|
379
|
+
title 'Hello, Combo!'
|
380
|
+
|
381
|
+
combobox { |proxy|
|
382
|
+
state 'readonly'
|
383
|
+
text bind(person, :country)
|
384
|
+
}
|
385
|
+
|
386
|
+
button { |proxy|
|
387
|
+
text "Reset Selection"
|
388
|
+
command {
|
389
|
+
person.reset_country
|
390
|
+
}
|
391
|
+
}
|
392
|
+
}.open
|
393
|
+
# ... more code follows
|
394
|
+
```
|
395
|
+
|
396
|
+
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
397
|
+
|
398
|
+
```
|
399
|
+
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_combo.rb'"
|
400
|
+
```
|
401
|
+
|
402
|
+
Glimmer app:
|
403
|
+
|
404
|
+
![glimmer dsl tk screenshot sample hello combo](images/glimmer-dsl-tk-screenshot-sample-hello-combo.png)
|
405
|
+
![glimmer dsl tk screenshot sample hello combo dropdown](images/glimmer-dsl-tk-screenshot-sample-hello-combo-dropdown.png)
|
406
|
+
|
407
|
+
### Hello, List Single Selection!
|
408
|
+
|
409
|
+
Glimmer code (from [samples/hello/hello_list_single_selection.rb](samples/hello/hello_list_single_selection.rb)):
|
410
|
+
|
411
|
+
```ruby
|
412
|
+
# ... more code precedes
|
413
|
+
root {
|
414
|
+
title 'Hello, List Single Selection!'
|
415
|
+
|
416
|
+
list {
|
417
|
+
selectmode 'browse'
|
418
|
+
selection bind(person, :country)
|
419
|
+
}
|
420
|
+
|
421
|
+
button {
|
422
|
+
text "Reset Selection To Default Value"
|
423
|
+
|
424
|
+
command { person.reset_country }
|
425
|
+
}
|
426
|
+
}.open
|
427
|
+
# ... more code follows
|
428
|
+
```
|
429
|
+
|
430
|
+
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
431
|
+
|
432
|
+
```
|
433
|
+
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_list_single_selection.rb'"
|
434
|
+
```
|
435
|
+
|
436
|
+
Glimmer app:
|
437
|
+
|
438
|
+
![glimmer dsl tk screenshot sample hello list single selection](images/glimmer-dsl-tk-screenshot-sample-hello-list-single-selection.png)
|
439
|
+
|
440
|
+
### Hello, List Multi Selection!
|
441
|
+
|
442
|
+
Glimmer code (from [samples/hello/hello_list_multi_selection.rb](samples/hello/hello_list_multi_selection.rb)):
|
443
|
+
|
444
|
+
```ruby
|
445
|
+
# ... more code precedes
|
446
|
+
root {
|
447
|
+
title 'Hello, List Multi Selection!'
|
448
|
+
|
449
|
+
list {
|
450
|
+
selection bind(person, :provinces)
|
451
|
+
}
|
452
|
+
|
453
|
+
button {
|
454
|
+
text "Reset Selection To Defaults"
|
455
|
+
|
456
|
+
command { person.reset_provinces }
|
457
|
+
}
|
458
|
+
}.open
|
459
|
+
# ... more code follows
|
460
|
+
```
|
461
|
+
|
462
|
+
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
463
|
+
|
464
|
+
```
|
465
|
+
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_list_multi_selection.rb'"
|
466
|
+
```
|
467
|
+
|
468
|
+
Glimmer app:
|
469
|
+
|
470
|
+
![glimmer dsl tk screenshot sample hello list multi selection](images/glimmer-dsl-tk-screenshot-sample-hello-list-multi-selection.png)
|
471
|
+
|
472
|
+
### Hello, Computed!
|
473
|
+
|
474
|
+
Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_computed.rb)):
|
475
|
+
|
476
|
+
```ruby
|
477
|
+
# ... more code precedes
|
478
|
+
root {
|
479
|
+
title 'Hello, Computed!'
|
480
|
+
|
481
|
+
frame {
|
482
|
+
grid column: 0, row: 0, padx: 5, pady: 5
|
483
|
+
|
484
|
+
label {
|
485
|
+
grid column: 0, row: 0, sticky: 'w'
|
486
|
+
text 'First Name: '
|
487
|
+
}
|
488
|
+
entry {
|
489
|
+
grid column: 1, row: 0
|
490
|
+
width 15
|
491
|
+
text bind(@contact, :first_name)
|
492
|
+
}
|
493
|
+
|
494
|
+
label {
|
495
|
+
grid column: 0, row: 1, sticky: 'w'
|
496
|
+
text 'Last Name: '
|
497
|
+
}
|
498
|
+
entry {
|
499
|
+
grid column: 1, row: 1
|
500
|
+
width 15
|
501
|
+
text bind(@contact, :last_name)
|
502
|
+
}
|
503
|
+
|
504
|
+
label {
|
505
|
+
grid column: 0, row: 2, sticky: 'w'
|
506
|
+
text 'Year of Birth: '
|
507
|
+
}
|
508
|
+
entry {
|
509
|
+
grid column: 1, row: 2
|
510
|
+
width 15
|
511
|
+
text bind(@contact, :year_of_birth)
|
512
|
+
}
|
513
|
+
|
514
|
+
label {
|
515
|
+
grid column: 0, row: 3, sticky: 'w'
|
516
|
+
text 'Name: '
|
517
|
+
}
|
518
|
+
label {
|
519
|
+
grid column: 1, row: 3, sticky: 'w'
|
520
|
+
text bind(@contact, :name, computed_by: [:first_name, :last_name])
|
521
|
+
}
|
522
|
+
|
523
|
+
label {
|
524
|
+
grid column: 0, row: 4, sticky: 'w'
|
525
|
+
text 'Age: '
|
526
|
+
}
|
527
|
+
label {
|
528
|
+
grid column: 1, row: 4, sticky: 'w'
|
529
|
+
text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
|
530
|
+
}
|
531
|
+
}
|
532
|
+
}.open
|
533
|
+
# ... more code follows
|
534
|
+
```
|
535
|
+
|
536
|
+
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
537
|
+
|
538
|
+
```
|
539
|
+
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_computed.rb'"
|
540
|
+
```
|
541
|
+
|
542
|
+
Glimmer app:
|
543
|
+
|
544
|
+
![glimmer dsl tk screenshot sample hello computed](images/glimmer-dsl-tk-screenshot-sample-hello-computed.png)
|
545
|
+
|
81
546
|
## Help
|
82
547
|
|
83
548
|
### Issues
|
@@ -90,9 +555,13 @@ You may submit [issues](https://github.com/AndyObtiva/glimmer/issues) on [GitHub
|
|
90
555
|
|
91
556
|
If you need live help, try to [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
92
557
|
|
93
|
-
##
|
558
|
+
## Process
|
559
|
+
|
560
|
+
[Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
|
561
|
+
|
562
|
+
## Planned Features and Feature Suggestions
|
94
563
|
|
95
|
-
These features have been suggested. You might see them in a future version of Glimmer. You are welcome to contribute more feature suggestions.
|
564
|
+
These features have been planned or suggested. You might see them in a future version of Glimmer DSL for Tk. You are welcome to contribute more feature suggestions.
|
96
565
|
|
97
566
|
[TODO.md](TODO.md)
|
98
567
|
|
@@ -108,7 +577,7 @@ These features have been suggested. You might see them in a future version of Gl
|
|
108
577
|
|
109
578
|
* [Andy Maleh](https://github.com/AndyObtiva) (Founder)
|
110
579
|
|
111
|
-
[Click here to view contributor commits.](https://github.com/AndyObtiva/glimmer-dsl-
|
580
|
+
[Click here to view contributor commits.](https://github.com/AndyObtiva/glimmer-dsl-tk/graphs/contributors)
|
112
581
|
|
113
582
|
## License
|
114
583
|
|