-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gladiator-scratchpad
81 lines (62 loc) · 1.34 KB
/
.gladiator-scratchpad
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
require 'glimmer-dsl-swt'
include Glimmer
class Person
class << self
def default_greeting=(greeting)
@@default_greeting = greeting
end
def default_greeting
@@default_greeting
end
end
def initialize(last_name)
@last_name = last_name
end
def last_name
@last_name
end
end
people = []
shell { |window|
text "Glimmer"
row_layout(:vertical) {
fill true
}
label {
text "What is the default greeting?"
}
@default_greeting_combo = combo(:read_only) {
items ['Hello', 'Hi', 'Howdy', 'Aloha', "What's Up"]
text 'Hello'
on_widget_selected do
Person.default_greeting = @default_greeting_combo.text
end
}
label {
text "What is your last name?"
}
@last_name_text = text {
}
button {
text 'Add'
on_widget_selected do
people << Person.new(@last_name_text.text)
@last_names_label.text = "#{@last_names_label.text}\n#{@last_name_text.text}"
@last_name_text.text = ''
window.pack # resize window to fit new content
end
}
@last_names_label = label {
}
button {
text 'Greet'
on_widget_selected do
@greeting_label.text = people.map do |person|
"#{Person.default_greeting}, #{person.last_name}!"
end.join("\n")
window.pack
end
}
@greeting_label = label {
}
}.open