Maximum value level that can be displayed by the bar
min-value
float
r/w/en
Minimum value level that can be displayed by the bar
mode
Gtk.LevelBarMode
r/w/en
The mode of the value indicator displayed by the bar
value
float
r/w/en
Currently filled value level of the level bar
Signals
Name
Short Description
offset-changed
Emitted when an offset specified on the bar changes value as an effect to Gtk.LevelBar.add_offset_value() being called.
例子
代码:
#!/usr/bin/env python3# Created by xiaosanyu at 16/7/14# section 110# # author: xiaosanyu# website: yuxiaosan.tk \# http://blog.youkuaiyun.com/a87b01c14# created: 16/7/14
TITLE = "LevelBar"
DESCRIPTION = """
The Gtk.LevelBar is a bar widget that can be used as a level indicator.
Typical use cases are displaying the strength of a password, or showing the charge level of a battery.
"""import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, Gio, GLib
classLevelBarWindow(Gtk.Window):def__init__(self, *args, **kwargs):
Gtk.Window.__init__(self, title="LevelBar Example")
self.set_size_request(250, 200)
box = Gtk.VBox(spacing=6)
self.lb = Gtk.LevelBar(min_value=0, max_value=100, value=0, inverted=False, mode=Gtk.LevelBarMode.CONTINUOUS)
box.pack_start(self.lb, False, False, 0)
self.add(box)
GLib.timeout_add(100, self.timeout)
deftimeout(self):
max_value = self.lb.get_max_value()
self.lb.set_value(self.lb.get_value() % max_value + 1)
returnTruedefmain():
win = LevelBarWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()