/GTK3 - ProgressBar
gem install gtk3
# frozen_string_literal: true
require 'gtk3'
class ProgressBarWindow < Gtk::Window
attr_accessor :progressbar, :activity_mode
def initialize
super
self.title = 'ProgressBar Demo'
self.border_width = 10
vbox = Gtk::Box.new(:vertical, 6)
add vbox
@progressbar = Gtk::ProgressBar.new
vbox.pack_start progressbar
button = Gtk::CheckButton.new('Show text')
button.signal_connect('toggled') { |b| on_show_text_toggled b }
vbox.pack_start button
button = Gtk::CheckButton.new('Activity mode')
button.signal_connect('toggled') { |b| on_activity_mode_toggled b }
vbox.pack_start button
button = Gtk::CheckButton.new('Right to Left')
button.signal_connect('toggled') { |b| on_right_to_left_toggled b }
vbox.pack_start button
timeout_id = GLib::Timeout.add(50) { on_timeout }
end
def on_show_text_toggled(button)
show_text = button.active?
text = show_text ? 'some text' : ''
progressbar.text = text
progressbar.show_text = show_text
end
def on_activity_mode_toggled(button)
@activity_mode = button.active?
if activity_mode
progressbar.pulse
else
progressbar.set_fraction 0
end
end
def on_right_to_left_toggled(button)
value = button.active?
progressbar.set_inverted value
end
def on_timeout
if activity_mode
progressbar.pulse
else
new_value = progressbar.fraction + 0.01
new_value = 0 if new_value > 1
progressbar.fraction = new_value
end
end
end
win = ProgressBarWindow.new
win.signal_connect('destroy') { Gtk.main_quit }
win.show_all
Gtk.main
Python version
Reference
이 문제에 관하여(/GTK3 - ProgressBar), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kojix2/items/9de19677bc4db6445931텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)