/GTK3 - Button
gem install gtk3
Button
"Click me"button was clicked
"Open"button was clicked
Closing applicationrequire 'gtk3'
class ButtonWindow < Gtk::Window
def initialize
super
set_title 'Button Demo'
set_border_width 10
hbox = Gtk::Box.new(:horizontal, spacing = 6)
add(hbox)
button = Gtk::Button.new(label: 'Click Me')
button.signal_connect('clicked') { on_click_me_clicked }
hbox.pack_start(button)
button = Gtk::Button.new(mnemonic: '_Open')
button.signal_connect('clicked') { on_open_clicked }
hbox.pack_start(button)
button = Gtk::Button.new(mnemonic: '_Close')
button.signal_connect('clicked') { on_close_clicked }
hbox.pack_start(button)
end
def on_click_me_clicked
puts '"Click me" button was clicked'
end
def on_open_clicked
puts '"Open" button was clicked'
end
def on_close_clicked
puts 'Closing application'
Gtk.main_quit
end
end
win = ButtonWindow.new
win.signal_connect('destroy') { Gtk.main_quit }
win.show_all
Gtk.main
require 'gtk3'
class ButtonWindow < Gtk::Window
def initialize
super
set_title 'Button Demo'
set_border_width 10
hbox = Gtk::Box.new(:horizontal, spacing = 6)
add(hbox)
button = Gtk::Button.new(label: 'Click Me')
button.signal_connect('clicked') { on_click_me_clicked }
hbox.pack_start(button)
button = Gtk::Button.new(mnemonic: '_Open')
button.signal_connect('clicked') { on_open_clicked }
hbox.pack_start(button)
button = Gtk::Button.new(mnemonic: '_Close')
button.signal_connect('clicked') { on_close_clicked }
hbox.pack_start(button)
end
def on_click_me_clicked
puts '"Click me" button was clicked'
end
def on_open_clicked
puts '"Open" button was clicked'
end
def on_close_clicked
puts 'Closing application'
Gtk.main_quit
end
end
win = ButtonWindow.new
win.signal_connect('destroy') { Gtk.main_quit }
win.show_all
Gtk.main
Reference
이 문제에 관하여(/GTK3 - Button), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kojix2/items/c37f48bff8daf740d992텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)