tk_paradise 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +387 -0
  3. data/doc/README.gen +325 -0
  4. data/lib/tk_paradise/base/base.rb +63 -0
  5. data/lib/tk_paradise/examples/001_dialog_box_example.rb +21 -0
  6. data/lib/tk_paradise/examples/002_draw_tiny_box.rb +22 -0
  7. data/lib/tk_paradise/examples/003_fun_with_cursors.rb +82 -0
  8. data/lib/tk_paradise/examples/004_hello_world_example.rb +23 -0
  9. data/lib/tk_paradise/examples/005_key_press_event_example.rb +21 -0
  10. data/lib/tk_paradise/examples/006_multiple_buttons.rb +30 -0
  11. data/lib/tk_paradise/examples/007_packing_example_in_tk.rb +28 -0
  12. data/lib/tk_paradise/examples/008_pig_latin_example.rb +70 -0
  13. data/lib/tk_paradise/examples/009_scrollbar_example.rb +44 -0
  14. data/lib/tk_paradise/examples/010_telnet_client.rb +106 -0
  15. data/lib/tk_paradise/examples/011_thermostat_example.rb +60 -0
  16. data/lib/tk_paradise/examples/012_tk_menu_example.rb +23 -0
  17. data/lib/tk_paradise/examples/013_tk_popup.rb +61 -0
  18. data/lib/tk_paradise/examples/014_tk_slider.rb +63 -0
  19. data/lib/tk_paradise/examples/015_choose_colour_example.rb +22 -0
  20. data/lib/tk_paradise/examples/016_spin_box_example.rb +28 -0
  21. data/lib/tk_paradise/examples/017_combo_box_example.rb +46 -0
  22. data/lib/tk_paradise/examples/018_tk_list_box_example.rb +18 -0
  23. data/lib/tk_paradise/examples/019_tk_curves.rb +33 -0
  24. data/lib/tk_paradise/examples/advanced/0001_example_showing_move_method.rb +32 -0
  25. data/lib/tk_paradise/examples/advanced/0019_tk_curves.rb +0 -0
  26. data/lib/tk_paradise/tk_classes/label.rb +18 -0
  27. data/lib/tk_paradise/tk_classes/root.rb +24 -0
  28. data/lib/tk_paradise/tk_paradise.rb +154 -0
  29. data/lib/tk_paradise/version/version.rb +19 -0
  30. data/lib/tk_paradise.rb +5 -0
  31. data/tk_paradise.gemspec +42 -0
  32. metadata +106 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 41c562db03ac8b8e742ebcd2b60b91ff8cd12d7c348b72f511638a4812cad6f2
4
+ data.tar.gz: 9a7047c2f6d860d58b272f4293fc8e72cea2fa9db79c28882f51784ad2719004
5
+ SHA512:
6
+ metadata.gz: b52764d03655cae191a6c42623befe4ec267bfd2c094c6b53e6236ca0717a93b6b067e76c118b095c24f95aa28b82cc4d86dcfff55c8d726dc4005279ac032b3
7
+ data.tar.gz: e984bd777d9cdc79465e40c242a6c2cb1cedd1d6b75e4ec196b0c9fea92d2ee0bf09c76215255c4700f6be86a2527120bdd353fa941db0a815b4852081b0c5b2
data/README.md ADDED
@@ -0,0 +1,387 @@
1
+ [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
2
+ [![forthebadge](https://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
3
+ [![Gem Version](https://badge.fury.io/rb/tk_paradise.svg)](https://badge.fury.io/rb/tk_paradise)
4
+
5
+ This gem was <b>last updated</b> on the <span style="color: darkblue; font-weight: bold">23.12.2023</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">05:22:59</span> o'clock.
6
+
7
+ ## Create a new root entry:
8
+
9
+ TITLE = 'This is my widget'
10
+ root = TkRoot.new { title TITLE }
11
+
12
+ ## Specify width, height, then x-coordinate, then y-coordinate:
13
+
14
+ root.geometry('800x600+0+0')
15
+ root.geometry('250x150+0+0')
16
+ root.geometry("500x100") # Just width x height
17
+ root.geometry("800x500") # Just width x height
18
+ root.geometry("+300+300") # And this will only specify the x and y coordinates
19
+
20
+ ## Set the title of the root widget at a later point:
21
+
22
+ root.title('YO')
23
+
24
+ ## Set a minimal size of the root widget:
25
+
26
+ root.minsize(400, 200)
27
+
28
+ ## Make the root window invisible (so that e. g. only the menubar shows up):
29
+
30
+ root.withdraw
31
+
32
+ ## Disallow the root window from being resized:
33
+
34
+ Tk.root.resizable(false, false) # boolean value: (width, height)
35
+
36
+ ## Obtain the value of an entry:
37
+
38
+ use .get
39
+
40
+ ## Set the value of an entry:
41
+
42
+ entry.insert(0, _)
43
+
44
+ # Note that I was unable to get this to work: entry.configure(text: 'Hey there')
45
+
46
+ ## Delete the content of an entry:
47
+
48
+ entry.delete(0,'end') # Weird that 'end' is used there.
49
+
50
+ ## Create an entry (entry tag):
51
+
52
+ @entry1 = TkEntry.new(outermost_frame, textvariable: @text1) {
53
+ font(MAIN_FONT)
54
+ }
55
+
56
+ ## Set the width of an entry:
57
+
58
+ entry.configure(width: 35) # Oddly enough I have no idea what this number stands for.
59
+
60
+ ## Set the background colour of an entry:
61
+
62
+ background 'steelblue'
63
+ root.configure(background: 'black')
64
+
65
+ ## Respond to key-events for entry:
66
+
67
+ entry.bind('Key', proc {|this_key|
68
+ e "This key was pressed: `#{this_key}`"
69
+ }, '%K')
70
+
71
+ ## Change an entry dynamically:
72
+
73
+ label = TkLabel.new(top) {
74
+ text 'Hello, World!'
75
+ }
76
+
77
+ TkButton.new(top) {
78
+ text "Cancel"
79
+ command proc {
80
+ label.configure('text'=>"Goodbye, Cruel World!")
81
+ }
82
+ pack('side'=>'right', 'padx'=>10, 'pady'=>10)
83
+ }
84
+
85
+ Now when the Cancel button is pressed, the text in the label will
86
+ change immediately from ``Hello, World!'' to ``Goodbye, Cruel World!''
87
+
88
+ ## Creating buttons in Tk and via the tk_paradise gem
89
+
90
+ Use this Syntax to create a button:
91
+
92
+ TkButton.new(root, text: entry)
93
+ TkButton.new(root, text: 'is').grid("columnspan"=>3, "sticky"=>"ew")
94
+ TkButton.new(root, text: 'two').grid("row"=>1, "column"=>3, "columnspan"=>3)
95
+
96
+ ## Button is-clicked event (clicked callback):
97
+
98
+ command proc {
99
+ e 'Hello.'
100
+ }
101
+
102
+ ## Add the button to the main root:
103
+
104
+ button.pack
105
+
106
+ ## Create a new grid:
107
+
108
+ TkGrid.grid(buttons[0], buttons[1], buttons[2], columnspan: 2 )
109
+
110
+ ## Start the mainloop:
111
+
112
+ Tk.mainloop
113
+ Tk.run # Or this variant when the tk_paradise gem is used.
114
+
115
+ ## Specify font size:
116
+
117
+ root.option_add('*Font', '25')
118
+
119
+ ## Return the available fonts:
120
+
121
+ pp TkFont.names
122
+ # ["TkCaptionFont", "TkSmallCaptionFont", "TkTooltipFont",
123
+ # "TkFixedFont", "TkHeadingFont", "TkMenuFont", "TkIconFont",
124
+ # "TkTextFont", "TkDefaultFont"]
125
+
126
+ 1 TkDefaultFont: The default for all GUI items not otherwise specified.
127
+ 2 TkTextFont: Used for entry widgets, listboxes, etc.
128
+ 3 TkFixedFont: A standard fixed-width font.
129
+ 4 TkMenuFont: The font used for menu items.
130
+ 5 TkHeadingFont: The font typically used for column headings in lists and tables.
131
+ 6 TkCaptionFont: A font for window and dialog caption bars.
132
+ 7 TkSmallCaptionFont: A smaller caption font for subwindows or tool dialogs
133
+ 8 TkIconFont: A font for icon captions.
134
+ 9 TkTooltipFont: A font for tooltips.
135
+
136
+ ## Specify a font to use (font tag):
137
+
138
+ font = TkFont.new(family: 'Helvetica', size: 20, weight: 'bold')
139
+ TkLabel.new(root) { text 'Attention!'; font TkCaptionFont }
140
+
141
+ MONOSPACED_FONT = TkFont.new(family: 'Hack', size: 22, weight: 'bold')
142
+
143
+ ## Create a new tk-variable:
144
+
145
+ text1 = TkVariable.new
146
+
147
+ Note that TkVariable implements #to_a, which can be used to convert
148
+ its value into an Array.
149
+
150
+ ## How to create a label (text):
151
+
152
+ label = TkLabel.new(root) {
153
+ textvariable
154
+ borderwidth 5
155
+ font use_this_font
156
+ foreground 'red' # The foreground colour to use.
157
+ relief 'groove'
158
+ pack(side: 'right', padx: '50', pady: '50')
159
+ }
160
+
161
+ ## Draw on a canvas:
162
+
163
+ canvas = TkCanvas.new(root)
164
+
165
+ ## Multiple spanning in a grid:
166
+
167
+ .grid(row: 1, column: 3, columnspan: 3)
168
+
169
+ ## How to let the button perform an action:
170
+
171
+ button = Button.new(root, text: 'foobar) {
172
+ command proc {
173
+ puts 'I am saying '+::Colours.sfancy('hello world')+'!'
174
+ }
175
+ }
176
+
177
+ ## Padding in tk:
178
+
179
+ Use padx and pady for a grid. Example:
180
+
181
+ .grid(row: 1, column: 3, columnspan: 3, padx: 5, pady: 5)
182
+
183
+ ## Pack a tk-label:
184
+
185
+ TkLabel.new(root) {
186
+ text 'Hello, World!'
187
+ pack {
188
+ padx 25; pady 25; side 'left'
189
+ }
190
+ }
191
+
192
+ ## Make use of a scrollbar (scrollbar tag):
193
+
194
+ scrollbar = TkScrollbar.new(root).pack(side: :right, fill: :y)
195
+
196
+ command proc{|idx|
197
+ list.yview *idx
198
+ }
199
+
200
+ ## Combo box widget:
201
+
202
+ list = TkListbox.new(frame).pack
203
+ list.insert("end", "/home")
204
+ list.insert("end", "/etc/hosts")
205
+
206
+ # Or alternatively:
207
+ n = TkVariable.new
208
+ combo_box = TkCombobox.new(
209
+ root,
210
+ width: 30,
211
+ font: MONOSPACED_FONT,
212
+ textvariable: n
213
+ )
214
+ combo_box.values(%w(
215
+ aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu
216
+ ))
217
+ combo_box.grid(column: 0, row: 6)
218
+
219
+ ## How to select the current value of such a combo-box:
220
+
221
+ combo_box.current = 3 # This uses the fourth element.
222
+
223
+ ## Query / Obtain values:
224
+
225
+ This is done via the method .cget().
226
+
227
+ b.cget('text') # "OK"
228
+ b.cget('justify') # "left"
229
+ b.cget('border') # 5
230
+
231
+ Events in ruby-tk in general need to make use of .bind, in order
232
+ to tie an event to a widget.
233
+
234
+ ## mouse-over event:
235
+
236
+ image1 = TkPhotoImage.new { file "img1.gif" }
237
+ b = TkButton.new(@root) {
238
+ image image1
239
+ command proc { doit }
240
+ }
241
+ b.bind("Enter") { b.configure(image: image2) }
242
+ b.bind("Leave") { b.configure(image: image1) }
243
+
244
+ ## The configure method (configure tag):
245
+
246
+ Every widget in tk supports the .configure() method.
247
+ button.configure(text: "Goodbye, Cruel World!")
248
+
249
+ ## Creating images (image tag, img tag):
250
+
251
+ image = TkPhotoImage.new(file: 'foobar.png', height: 82)
252
+
253
+ ## Create some text:
254
+
255
+ text = TkText.new(root) { width 20; height 5 }.pack(side: :left)
256
+
257
+ ## Append onto the text-widget:
258
+
259
+ text.insert('end', 'Left in canvas')
260
+
261
+ ## Create a frame:
262
+
263
+ frame = TkFrame(root, highlightbackground: "black",
264
+ highlightthickness: 2,
265
+ bd: 0)
266
+ ## Add a button to that frame:
267
+
268
+ button = TkButton(frame, text: 'Submit', fg: 'black',
269
+ bg: 'yellow', font: (("Times New Roman"),15))
270
+
271
+ button.pack()
272
+
273
+ ## Set the width of a border around a button:
274
+
275
+ borderwidth 3
276
+ borderwidth 5
277
+
278
+ ## Set the style of a border:
279
+
280
+ Possible values include:
281
+
282
+ flat
283
+
284
+ Use it like this:
285
+
286
+ relief 'flat'
287
+ relief 'raised'
288
+ relief 'sunken'
289
+ relief 'groove'
290
+ relief 'ridge'
291
+
292
+ ## How to use TkMessage:
293
+
294
+ TkMessage.new(root) {
295
+
296
+ ## Start in the top left corner:
297
+
298
+ root.geometry('250x150+0+0')
299
+
300
+ ## How to use an open-file dialog:
301
+
302
+ Tk.getOpenFile
303
+
304
+ ## How to create a spin-button in ruby-tk (also called a spin-box):
305
+
306
+ TkSpinbox.new(root) {
307
+ ...Standard Options...
308
+ ...Widget-specific Options...
309
+ }
310
+
311
+ Such as:
312
+
313
+ TkSpinbox.new(root) {
314
+ to 250
315
+ from 0
316
+ increment 5
317
+ pack(side: 'left', padx: '50', pady: '50')
318
+ }
319
+
320
+ To center it, use:
321
+
322
+ justify :center
323
+
324
+ ## Useful links:
325
+
326
+ https://tkdocs.com/tutorial/text.html
327
+ https://www.tutorialspoint.com/ruby/ruby_tk_dialogbox.htm
328
+
329
+
330
+ ## Contact information and mandatory 2FA (no longer) coming up in 2022 / 2023
331
+
332
+ If your creative mind has ideas and specific suggestions to make this gem
333
+ more useful in general, feel free to drop me an email at any time, via:
334
+
335
+ shevy@inbox.lt
336
+
337
+ Before that email I used an email account at Google gmail, but in **2021** I
338
+ decided to slowly abandon gmail, for various reasons. In order to limit the
339
+ explanation here, allow me to just briefly state that I do not feel as if I
340
+ want to promote any Google service anymore when the user becomes the end
341
+ product (such as via data collection by upstream services, including other
342
+ proxy-services). My feeling is that this is a hugely flawed business model
343
+ to begin with, and I no longer wish to support this in any way, even if
344
+ only indirectly so, such as by using services of companies that try to
345
+ promote this flawed model.
346
+
347
+ In regards to responding to emails: please keep in mind that responding
348
+ may take some time, depending on the amount of work I may have at that
349
+ moment. So it is not that emails are ignored; it is more that I have not
350
+ (yet) found the time to read and reply. This means there may be a delay
351
+ of days, weeks and in some instances also months. There is, unfortunately,
352
+ not much I can do when I need to prioritise my time investment, but I try
353
+ to consider <b>all</b> feedback as an opportunity to improve my projects
354
+ nonetheless.
355
+
356
+ In <b>2022</b> rubygems.org decided to make 2FA mandatory for every
357
+ gem owner eventually:
358
+
359
+ see
360
+ https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html
361
+
362
+ Mandatory 2FA will eventually be extended to all rubygems.org developers and
363
+ maintainers. As I can not use 2FA, for reasons I will skip explaining here,
364
+ this means that my projects will eventually be removed, as I no longer
365
+ have any control over my projects hosted on rubygems.org (because I
366
+ can not use 2FA).
367
+
368
+ At that point, I no longer have any control what is done to my projects
369
+ since whoever is controlling the gems ecosystem took away our control
370
+ here. I am not sure at which point ruby became corporate-controlled -
371
+ that was not the case several years ago, so something has
372
+ changed.
373
+
374
+ Ruby also only allows 2FA users to participate on the issue tracker these
375
+ days:
376
+
377
+ https://bugs.ruby-lang.org/issues/18800
378
+
379
+ But this has been reverted some months ago, so it is no longer applicable.
380
+ Suffice to say that I do not think that we should only be allowed to
381
+ interact on the world wide web when some 'authority' authenticated us,
382
+ such as via mandatory 2FA, so I hope this won't come back again.
383
+
384
+ Fighting spam is a noble goal, but when it also means you lock out
385
+ real human people then this is definitely NOT a good situation
386
+ to be had.
387
+
data/doc/README.gen ADDED
@@ -0,0 +1,325 @@
1
+ DEFAULT_HEADER
2
+
3
+ ## Create a new root entry:
4
+
5
+ TITLE = 'This is my widget'
6
+ root = TkRoot.new { title TITLE }
7
+
8
+ ## Specify width, height, then x-coordinate, then y-coordinate:
9
+
10
+ root.geometry('800x600+0+0')
11
+ root.geometry('250x150+0+0')
12
+ root.geometry("500x100") # Just width x height
13
+ root.geometry("800x500") # Just width x height
14
+ root.geometry("+300+300") # And this will only specify the x and y coordinates
15
+
16
+ ## Set the title of the root widget at a later point:
17
+
18
+ root.title('YO')
19
+
20
+ ## Set a minimal size of the root widget:
21
+
22
+ root.minsize(400, 200)
23
+
24
+ ## Make the root window invisible (so that e. g. only the menubar shows up):
25
+
26
+ root.withdraw
27
+
28
+ ## Disallow the root window from being resized:
29
+
30
+ Tk.root.resizable(false, false) # boolean value: (width, height)
31
+
32
+ ## Obtain the value of an entry:
33
+
34
+ use .get
35
+
36
+ ## Set the value of an entry:
37
+
38
+ entry.insert(0, _)
39
+
40
+ # Note that I was unable to get this to work: entry.configure(text: 'Hey there')
41
+
42
+ ## Delete the content of an entry:
43
+
44
+ entry.delete(0,'end') # Weird that 'end' is used there.
45
+
46
+ ## Create an entry (entry tag):
47
+
48
+ @entry1 = TkEntry.new(outermost_frame, textvariable: @text1) {
49
+ font(MAIN_FONT)
50
+ }
51
+
52
+ ## Set the width of an entry:
53
+
54
+ entry.configure(width: 35) # Oddly enough I have no idea what this number stands for.
55
+
56
+ ## Set the background colour of an entry:
57
+
58
+ background 'steelblue'
59
+ root.configure(background: 'black')
60
+
61
+ ## Respond to key-events for entry:
62
+
63
+ entry.bind('Key', proc {|this_key|
64
+ e "This key was pressed: `#{this_key}`"
65
+ }, '%K')
66
+
67
+ ## Change an entry dynamically:
68
+
69
+ label = TkLabel.new(top) {
70
+ text 'Hello, World!'
71
+ }
72
+
73
+ TkButton.new(top) {
74
+ text "Cancel"
75
+ command proc {
76
+ label.configure('text'=>"Goodbye, Cruel World!")
77
+ }
78
+ pack('side'=>'right', 'padx'=>10, 'pady'=>10)
79
+ }
80
+
81
+ Now when the Cancel button is pressed, the text in the label will
82
+ change immediately from ``Hello, World!'' to ``Goodbye, Cruel World!''
83
+
84
+ ## Creating buttons in Tk and via the tk_paradise gem
85
+
86
+ Use this Syntax to create a button:
87
+
88
+ TkButton.new(root, text: entry)
89
+ TkButton.new(root, text: 'is').grid("columnspan"=>3, "sticky"=>"ew")
90
+ TkButton.new(root, text: 'two').grid("row"=>1, "column"=>3, "columnspan"=>3)
91
+
92
+ ## Button is-clicked event (clicked callback):
93
+
94
+ command proc {
95
+ e 'Hello.'
96
+ }
97
+
98
+ ## Add the button to the main root:
99
+
100
+ button.pack
101
+
102
+ ## Create a new grid:
103
+
104
+ TkGrid.grid(buttons[0], buttons[1], buttons[2], columnspan: 2 )
105
+
106
+ ## Start the mainloop:
107
+
108
+ Tk.mainloop
109
+ Tk.run # Or this variant when the tk_paradise gem is used.
110
+
111
+ ## Specify font size:
112
+
113
+ root.option_add('*Font', '25')
114
+
115
+ ## Return the available fonts:
116
+
117
+ pp TkFont.names
118
+ # ["TkCaptionFont", "TkSmallCaptionFont", "TkTooltipFont",
119
+ # "TkFixedFont", "TkHeadingFont", "TkMenuFont", "TkIconFont",
120
+ # "TkTextFont", "TkDefaultFont"]
121
+
122
+ 1 TkDefaultFont: The default for all GUI items not otherwise specified.
123
+ 2 TkTextFont: Used for entry widgets, listboxes, etc.
124
+ 3 TkFixedFont: A standard fixed-width font.
125
+ 4 TkMenuFont: The font used for menu items.
126
+ 5 TkHeadingFont: The font typically used for column headings in lists and tables.
127
+ 6 TkCaptionFont: A font for window and dialog caption bars.
128
+ 7 TkSmallCaptionFont: A smaller caption font for subwindows or tool dialogs
129
+ 8 TkIconFont: A font for icon captions.
130
+ 9 TkTooltipFont: A font for tooltips.
131
+
132
+ ## Specify a font to use (font tag):
133
+
134
+ font = TkFont.new(family: 'Helvetica', size: 20, weight: 'bold')
135
+ TkLabel.new(root) { text 'Attention!'; font TkCaptionFont }
136
+
137
+ MONOSPACED_FONT = TkFont.new(family: 'Hack', size: 22, weight: 'bold')
138
+
139
+ ## Create a new tk-variable:
140
+
141
+ text1 = TkVariable.new
142
+
143
+ Note that TkVariable implements #to_a, which can be used to convert
144
+ its value into an Array.
145
+
146
+ ## How to create a label (text):
147
+
148
+ label = TkLabel.new(root) {
149
+ textvariable
150
+ borderwidth 5
151
+ font use_this_font
152
+ foreground 'red' # The foreground colour to use.
153
+ relief 'groove'
154
+ pack(side: 'right', padx: '50', pady: '50')
155
+ }
156
+
157
+ ## Draw on a canvas:
158
+
159
+ canvas = TkCanvas.new(root)
160
+
161
+ ## Multiple spanning in a grid:
162
+
163
+ .grid(row: 1, column: 3, columnspan: 3)
164
+
165
+ ## How to let the button perform an action:
166
+
167
+ button = Button.new(root, text: 'foobar) {
168
+ command proc {
169
+ puts 'I am saying '+::Colours.sfancy('hello world')+'!'
170
+ }
171
+ }
172
+
173
+ ## Padding in tk:
174
+
175
+ Use padx and pady for a grid. Example:
176
+
177
+ .grid(row: 1, column: 3, columnspan: 3, padx: 5, pady: 5)
178
+
179
+ ## Pack a tk-label:
180
+
181
+ TkLabel.new(root) {
182
+ text 'Hello, World!'
183
+ pack {
184
+ padx 25; pady 25; side 'left'
185
+ }
186
+ }
187
+
188
+ ## Make use of a scrollbar (scrollbar tag):
189
+
190
+ scrollbar = TkScrollbar.new(root).pack(side: :right, fill: :y)
191
+
192
+ command proc{|idx|
193
+ list.yview *idx
194
+ }
195
+
196
+ ## Combo box widget:
197
+
198
+ list = TkListbox.new(frame).pack
199
+ list.insert("end", "/home")
200
+ list.insert("end", "/etc/hosts")
201
+
202
+ # Or alternatively:
203
+ n = TkVariable.new
204
+ combo_box = TkCombobox.new(
205
+ root,
206
+ width: 30,
207
+ font: MONOSPACED_FONT,
208
+ textvariable: n
209
+ )
210
+ combo_box.values(%w(
211
+ aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu
212
+ ))
213
+ combo_box.grid(column: 0, row: 6)
214
+
215
+ ## How to select the current value of such a combo-box:
216
+
217
+ combo_box.current = 3 # This uses the fourth element.
218
+
219
+ ## Query / Obtain values:
220
+
221
+ This is done via the method .cget().
222
+
223
+ b.cget('text') # "OK"
224
+ b.cget('justify') # "left"
225
+ b.cget('border') # 5
226
+
227
+ Events in ruby-tk in general need to make use of .bind, in order
228
+ to tie an event to a widget.
229
+
230
+ ## mouse-over event:
231
+
232
+ image1 = TkPhotoImage.new { file "img1.gif" }
233
+ b = TkButton.new(@root) {
234
+ image image1
235
+ command proc { doit }
236
+ }
237
+ b.bind("Enter") { b.configure(image: image2) }
238
+ b.bind("Leave") { b.configure(image: image1) }
239
+
240
+ ## The configure method (configure tag):
241
+
242
+ Every widget in tk supports the .configure() method.
243
+ button.configure(text: "Goodbye, Cruel World!")
244
+
245
+ ## Creating images (image tag, img tag):
246
+
247
+ image = TkPhotoImage.new(file: 'foobar.png', height: 82)
248
+
249
+ ## Create some text:
250
+
251
+ text = TkText.new(root) { width 20; height 5 }.pack(side: :left)
252
+
253
+ ## Append onto the text-widget:
254
+
255
+ text.insert('end', 'Left in canvas')
256
+
257
+ ## Create a frame:
258
+
259
+ frame = TkFrame(root, highlightbackground: "black",
260
+ highlightthickness: 2,
261
+ bd: 0)
262
+ ## Add a button to that frame:
263
+
264
+ button = TkButton(frame, text: 'Submit', fg: 'black',
265
+ bg: 'yellow', font: (("Times New Roman"),15))
266
+
267
+ button.pack()
268
+
269
+ ## Set the width of a border around a button:
270
+
271
+ borderwidth 3
272
+ borderwidth 5
273
+
274
+ ## Set the style of a border:
275
+
276
+ Possible values include:
277
+
278
+ flat
279
+
280
+ Use it like this:
281
+
282
+ relief 'flat'
283
+ relief 'raised'
284
+ relief 'sunken'
285
+ relief 'groove'
286
+ relief 'ridge'
287
+
288
+ ## How to use TkMessage:
289
+
290
+ TkMessage.new(root) {
291
+
292
+ ## Start in the top left corner:
293
+
294
+ root.geometry('250x150+0+0')
295
+
296
+ ## How to use an open-file dialog:
297
+
298
+ Tk.getOpenFile
299
+
300
+ ## How to create a spin-button in ruby-tk (also called a spin-box):
301
+
302
+ TkSpinbox.new(root) {
303
+ ...Standard Options...
304
+ ...Widget-specific Options...
305
+ }
306
+
307
+ Such as:
308
+
309
+ TkSpinbox.new(root) {
310
+ to 250
311
+ from 0
312
+ increment 5
313
+ pack(side: 'left', padx: '50', pady: '50')
314
+ }
315
+
316
+ To center it, use:
317
+
318
+ justify :center
319
+
320
+ ## Useful links:
321
+
322
+ https://tkdocs.com/tutorial/text.html
323
+ https://www.tutorialspoint.com/ruby/ruby_tk_dialogbox.htm
324
+
325
+ CONTACT_INFORMATION