Class: Gtk::RadioButtonWindow
- Inherits:
-
Box
- Object
- Box
- Gtk::RadioButtonWindow
show all
- Defined in:
- lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb
Overview
Constant Summary
collapse
- TITLE =
'RadioButton Demo'
- VERTICAL_OR_HORIZONTAL =
#
VERTICAL_OR_HORIZONTAL
#
:vertical
Instance Method Summary
collapse
Methods inherited from Box
#add_space, #left_aligned_text, #text
Constructor Details
34
35
36
37
38
39
40
|
# File 'lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb', line 34
def initialize(
run_already = true
)
super(VERTICAL_OR_HORIZONTAL, 6)
reset
run if run_already
end
|
Instance Method Details
#connect_skeleton ⇒ Object
76
77
78
79
80
|
# File 'lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb', line 76
def connect_skeleton
pack_start(@button1)
pack_start(@button2)
pack_start(@button3)
end
|
#create_skeleton ⇒ Object
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb', line 62
def create_skeleton
@button1 = ::Gtk::RadioButton.new(label: '_Austria', use_underline: true)
@button1.signal_connect(:toggled) { |b| on_button_toggled(b, 1) }
@button2 = ::Gtk::RadioButton.new(member: @button1, label: '_Germany', use_underline: true)
@button2.signal_connect(:toggled) { |b| on_button_toggled(b, 2) }
@button3 = ::Gtk::RadioButton.new(member: @button1, label: 'Fr_ance', use_underline: true)
@button3.signal_connect(:toggled) { |b| on_button_toggled(b, 3) }
end
|
53
54
55
56
57
|
# File 'lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb', line 53
def on_button_toggled(button, name)
active_or_not_active = button.active? ? 'on' : 'off'
e "Button #{name} was turned #{active_or_not_active} - "\
"its text is: #{button.label}"
end
|
#reset ⇒ Object
45
46
47
48
|
# File 'lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb', line 45
def reset
set_title(TITLE) if respond_to? :set_title
set_border_width(15)
end
|
#run ⇒ Object
85
86
87
88
|
# File 'lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb', line 85
def run
create_skeleton
connect_skeleton
end
|