-
Notifications
You must be signed in to change notification settings - Fork 0
/
06_2_Padding_TheGridGeometryManager.rb
181 lines (151 loc) · 3.79 KB
/
06_2_Padding_TheGridGeometryManager.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# coding: utf-8
# Copyright (C) 2019 Mark D. Blackwell.
require 'tk'
require 'tkextlib/tile'
module ::Padding
module GraphicalHelper
def f_content
$f_content_private ||= begin
f = ::Tk::Tile::Frame.new root
f.grid sticky: :wnes
end
end
def root
$root_private ||= begin
tell_tk_which_encoding_to_use
::TkRoot.new
end
end
def weights_column_and_row_default_set_up(*args)
first = 0
args.reverse_each do |e|
::TkGrid.columnconfigure e, first, weight: 1
::TkGrid. rowconfigure e, first, weight: 1
end
nil
end
private
def tell_tk_which_encoding_to_use
::Tk::Encoding.encoding = ''.encoding
nil
end
end
end
module ::Padding
module GraphicalObjects
def b_cancel
@b_cancel_private ||= begin
b = ::Tk::Tile::Button.new f_content
b.text 'Cancel'
end
end
def b_okay
@b_okay_private ||= begin
b = ::Tk::Tile::Button.new f_content
b.text 'Okay'
end
end
def ch_one
@ch_one_private ||= begin
checked = 1
c = ::Tk::Tile::CheckButton.new f_content
c.onvalue checkbutton_value_when_selected
c.text 'One'
c.variable ::TkVariable.new checked
end
end
def ch_three
@ch_three_private ||= begin
checked = 1
c = ::Tk::Tile::CheckButton.new f_content
c.onvalue checkbutton_value_when_selected
c.text 'Three'
c.variable ::TkVariable.new checked
end
end
def ch_two
@ch_two_private ||= begin
unchecked = 0
c = ::Tk::Tile::CheckButton.new f_content
c.onvalue checkbutton_value_when_selected
c.text 'Two'
c.variable ::TkVariable.new unchecked
end
end
def e_name
@e_name_private ||= ::Tk::Tile::Entry.new f_content
end
def f_frame_inner
@f_frame_inner_private ||= begin
f = ::Tk::Tile::Frame.new f_content
f.borderwidth 5
f.height 100
f.relief :sunken
f.width 200
end
end
def l_label_name
@l_label_name_private ||= begin
l = ::Tk::Tile::Label.new f_content
l.text 'Name'
end
end
end
end
module ::Padding
module Graphical
extend GraphicalHelper
extend GraphicalObjects
extend self
def main
f_content.padding '3 3 12 12'
weights_column_and_row_set_up
# Set up cell behavior:
column_0_set_up
column_1_set_up
column_2_set_up
column_3_set_up
column_4_set_up
::Tk.mainloop
nil
end
private
def checkbutton_value_when_selected
1
end
def column_0_set_up
f_frame_inner.grid column: 0, row: 0, columnspan: 3, rowspan: 2, sticky: :wnes
ch_one .grid column: 0, row: 3
nil
end
def column_1_set_up
ch_two .grid column: 1, row: 3
nil
end
def column_2_set_up
ch_three .grid column: 2, row: 3
nil
end
def column_3_set_up
l_label_name .grid column: 3, row: 0, columnspan: 2, sticky: :wn, padx: 5
e_name .grid column: 3, row: 1, columnspan: 2, sticky: :wne, padx: 5, pady: 5
b_okay .grid column: 3, row: 3
nil
end
def column_4_set_up
b_cancel .grid column: 4, row: 3
nil
end
def weights_column_and_row_set_up
weights_column_and_row_default_set_up root
::TkGrid.columnconfigure f_content, 0, weight: 3
::TkGrid.columnconfigure f_content, 1, weight: 3
::TkGrid.columnconfigure f_content, 2, weight: 3
::TkGrid.columnconfigure f_content, 3, weight: 1
::TkGrid.columnconfigure f_content, 4, weight: 1
::TkGrid. rowconfigure f_content, 1, weight: 1
nil
end
end
end
::Padding::Graphical.main