glimmer-dsl-tk 0.0.32 → 0.0.36

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,178 @@
1
+ # Copyright (c) 2020-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer-dsl-tk'
23
+
24
+ include Glimmer
25
+
26
+ def toplevel_content
27
+ frame {
28
+ label {
29
+ text "This is a fully custom toplevel, meaning you can add any widgets here!\nYou can press the ESCAPE button on the keyboard to close."
30
+ }
31
+ separator
32
+ checkbutton {
33
+ text 'This is a checkbutton'
34
+ }
35
+ radiobutton {
36
+ text 'This is a radiobutton'
37
+ }
38
+ }
39
+ end
40
+
41
+ root { |root_window|
42
+ title 'Hello, Toplevel!'
43
+
44
+ button {
45
+ text 'Nested Window'
46
+
47
+ on('command') do
48
+ toplevel(root_window) {
49
+ title 'Custom Window'
50
+ escapable true
51
+ x 150
52
+ y 180
53
+ width 500
54
+ height 200
55
+ minsize 500, 100
56
+ maxsize 1000, 300
57
+
58
+ toplevel_content
59
+ }
60
+ end
61
+ }
62
+
63
+ button {
64
+ text 'Transparent Window'
65
+
66
+ on('command') do
67
+ toplevel(root_window) {
68
+ title 'Transparent Window'
69
+ escapable true
70
+ alpha 0.85
71
+ width 250
72
+ height 100
73
+ resizable false, false # not resizable horizontally or vertically
74
+
75
+ frame {
76
+ label {
77
+ text "This is a transparent window\nYou can hit ESCAPE to close."
78
+ anchor 'center'
79
+ }
80
+ }
81
+ }
82
+ end
83
+ }
84
+
85
+ button {
86
+ text 'Fullscreen Window'
87
+
88
+ on('command') do
89
+ toplevel(root_window) {
90
+ title 'Fullscreen Window'
91
+ escapable true
92
+ fullscreen true
93
+
94
+ frame {
95
+ label {
96
+ text "This is a fullscreen window\nYou can hit ESCAPE to close."
97
+ anchor 'center'
98
+ }
99
+ }
100
+ }
101
+ end
102
+ }
103
+
104
+ if OS.mac?
105
+ # Mac has special support for mac styles in Tk `toplevel`
106
+ # `mac_style` first argument (`mac_class`) and second argument (`mac_attribute_list`) can be chosen from this page: https://wiki.tcl-lang.org/page/MacWindowStyle
107
+
108
+ button {
109
+ text 'Mac Plain (No-Button-Modeless) Window'
110
+
111
+ on('command') do
112
+ toplevel(root_window) { |t|
113
+ title 'Mac Plain (No-Button-Modeless) Window'
114
+ escapable true
115
+ mac_style 'plain'
116
+
117
+ toplevel_content
118
+ }
119
+ end
120
+ }
121
+
122
+ button {
123
+ text 'Mac Floating (Close-Button-Modeless) Window'
124
+
125
+ on('command') do
126
+ toplevel(root_window) { |t|
127
+ title 'Mac Floating (Close-Button-Modeless) Window'
128
+ escapable true
129
+ mac_style 'floating'
130
+
131
+ toplevel_content
132
+ }
133
+ end
134
+ }
135
+
136
+ button {
137
+ text 'Mac Document (All-Button-Modeless) Window'
138
+
139
+ on('command') do
140
+ toplevel(root_window) { |t|
141
+ title 'Mac Document (All-Button-Modeless) Window'
142
+ escapable true
143
+ mac_style 'document'
144
+
145
+ toplevel_content
146
+ }
147
+ end
148
+ }
149
+
150
+ button {
151
+ text 'Mac Utility (Close-Button-Modal) Dialog'
152
+
153
+ on('command') do
154
+ toplevel(root_window) { |t|
155
+ title 'Mac Utility (Close-Button-Modal) Dialog'
156
+ escapable true
157
+ mac_style 'utility'
158
+
159
+ toplevel_content
160
+ }
161
+ end
162
+ }
163
+
164
+ button {
165
+ text 'Mac Utility with Attribute List (All-Button-Modal) Dialog'
166
+
167
+ on('command') do
168
+ toplevel(root_window) { |t|
169
+ title 'Mac Utility with Attribute List (All-Button-Modal) Dialog'
170
+ escapable true
171
+ mac_style 'utility', 'closeBox collapseBox resizable horizontalZoom verticalZoom sideTitlebar'
172
+
173
+ toplevel_content
174
+ }
175
+ end
176
+ }
177
+ end
178
+ }.open
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-tk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.32
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-29 00:00:00.000000000 Z
11
+ date: 2021-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -265,6 +265,7 @@ files:
265
265
  - samples/hello/hello_separator.rb
266
266
  - samples/hello/hello_spinbox.rb
267
267
  - samples/hello/hello_text.rb
268
+ - samples/hello/hello_toplevel.rb
268
269
  - samples/hello/hello_world.rb
269
270
  - samples/hello/images/align-center.png
270
271
  - samples/hello/images/align-left.png