-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09_2_AlertAndConfirmationDialogs_StandardDialogs_WindowsAndDialogs.rb
130 lines (106 loc) · 2.36 KB
/
09_2_AlertAndConfirmationDialogs_StandardDialogs_WindowsAndDialogs.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
# coding: utf-8
# Copyright (C) 2019 Mark D. Blackwell.
require 'tk'
require 'tkextlib/tile'
module ::AlertAndConfirmationDialogs
module About
extend self
def details
@details_private ||= begin
relevant = group.drop 1
relevant.map {|e| e.center width}.join "\n"
end
end
def program
@program_private ||= group.first.center width
end
private
def group
@group_private ||= raw.lines.map(&:strip)
end
def raw
@raw_private ||= <<END_RAW
Program-name Program-version
Copyright (c) Year Developer-name
License
Contact: Developer-email
END_RAW
end
def width
@width_private ||= group.map(&:length).max
end
end
end
module ::AlertAndConfirmationDialogs
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 ::AlertAndConfirmationDialogs
module GraphicalObjects
def f_frame_inner
@f_frame_inner_private ||= begin
f = ::Tk::Tile::Frame.new f_content
f.height 100
f.width 200
f.grid
end
end
end
end
module ::AlertAndConfirmationDialogs
module Graphical
extend GraphicalHelper
extend GraphicalObjects
extend self
def main
f_content.padding '3 3 3 3'
weights_column_and_row_set_up
f_frame_inner
raise_later
::Tk.mainloop
nil
end
private
def lambda_about
@lambda_about_private ||= ::Kernel.lambda do
::Tk.messageBox message: About.program, detail: About.details
nil
end
end
def raise_later
milliseconds = 1000
::Tk.after milliseconds, lambda_about
nil
end
def weights_column_and_row_set_up
weights_column_and_row_default_set_up f_content, root
nil
end
end
end
::AlertAndConfirmationDialogs::Graphical.main