/GTK3 - SpinButton
gem install gtk3
SpinButton
Gtk.SpinButon에서 두 개의 화살표 중 하나를 클릭하여 표시되는 값을 늘립니다.값을 직접 입력할 수도 있습니다.
require 'gtk3'
class SpinButtonWindow < Gtk::Window
attr_accessor :spinbutton
def initialize
super
set_title "SpinButton Demo"
set_border_width 10
hbox = Gtk::Box.new(:horizontal, 10)
add hbox
adjustment = Gtk::Adjustment.new(0, 0, 100, 1, 10, 0)
@spinbutton = Gtk::SpinButton.new(adjustment)
hbox.pack_start(spinbutton)
check_numeric = Gtk::CheckButton.new("Numeric")
check_numeric.signal_connect("toggled"){|b| on_numeric_toggled b}
hbox.pack_start(check_numeric)
check_ifvalid = Gtk::CheckButton.new("If Valid")
check_ifvalid.signal_connect("toggled"){|b| on_ifvalid_toggled b}
hbox.pack_start(check_ifvalid)
end
def on_numeric_toggled(button)
spinbutton.set_numeric(button.active?)
end
def on_ifvalid_toggled(button)
policy = if button.active?
Gtk::SpinButtonUpdatePolicy::IF_VALID
else
Gtk::SpinButtonUpdatePolicy::ALWAYS
end
spinbutton.set_update_policy(policy)
end
end
win = SpinButtonWindow.new
win.signal_connect("destroy"){ Gtk.main_quit }
win.show_all
Gtk.main
require 'gtk3'
class SpinButtonWindow < Gtk::Window
attr_accessor :spinbutton
def initialize
super
set_title "SpinButton Demo"
set_border_width 10
hbox = Gtk::Box.new(:horizontal, 10)
add hbox
adjustment = Gtk::Adjustment.new(0, 0, 100, 1, 10, 0)
@spinbutton = Gtk::SpinButton.new(adjustment)
hbox.pack_start(spinbutton)
check_numeric = Gtk::CheckButton.new("Numeric")
check_numeric.signal_connect("toggled"){|b| on_numeric_toggled b}
hbox.pack_start(check_numeric)
check_ifvalid = Gtk::CheckButton.new("If Valid")
check_ifvalid.signal_connect("toggled"){|b| on_ifvalid_toggled b}
hbox.pack_start(check_ifvalid)
end
def on_numeric_toggled(button)
spinbutton.set_numeric(button.active?)
end
def on_ifvalid_toggled(button)
policy = if button.active?
Gtk::SpinButtonUpdatePolicy::IF_VALID
else
Gtk::SpinButtonUpdatePolicy::ALWAYS
end
spinbutton.set_update_policy(policy)
end
end
win = SpinButtonWindow.new
win.signal_connect("destroy"){ Gtk.main_quit }
win.show_all
Gtk.main
Reference
이 문제에 관하여(/GTK3 - SpinButton), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kojix2/items/4119dccfb1bc6026c7ff텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)