The Gtk.Adjustment that contains the current value of this range object
fill-level
float
r/w/en
The fill level.
inverted
bool
r/w/en
Invert direction slider moves to increase range value
lower-stepper-sensitivity
Gtk.SensitivityType
r/w/en
The sensitivity policy for the stepper that points to the adjustment’s lower side
restrict-to-fill-level
bool
r/w/en
Whether to restrict the upper boundary to the fill level.
round-digits
int
r/w/en
The number of digits to round the value to.
show-fill-level
bool
r/w/en
Whether to display a fill level indicator graphics on trough.
upper-stepper-sensitivity
Gtk.SensitivityType
r/w/en
The sensitivity policy for the stepper that points to the adjustment’s upper side
Signals
Name
Short Description
adjust-bounds
Emitted before clamping a value, to give the application a chance to adjust the bounds.
change-value
The Gtk.Range ::change-value signal is emitted when a scroll action is performed on a range.
move-slider
Virtual function that moves the slider.
value-changed
Emitted when the range value changes.
Gtk.Scale
Gtk.Scale滑动条或刻度尺
继承关系
Gtk.Scale是Gtk.Range的直接子类
Methods
方法修饰词
方法名及参数
static
new (orientation, adjustment)
static
new_with_range (orientation, min, max, step)
add_mark (value, position, markup)
clear_marks ()
get_digits ()
get_draw_value ()
get_has_origin ()
get_layout ()
get_layout_offsets ()
get_value_pos ()
set_digits (digits)
set_draw_value (draw_value)
set_has_origin (has_origin)
set_value_pos (pos)
Virtual Methods
do_draw_value ()
do_format_value (value)
do_get_layout_offsets ()
Properties
Name
Type
Flags
Short Description
digits
int
r/w/en
The number of decimal places that are displayed in the value
draw-value
bool
r/w/en
Whether the current value is displayed as a string next to the slider
has-origin
bool
r/w/en
Whether the scale has an origin
value-pos
Gtk.PositionType
r/w/en
The position in which the current value is displayed
Signals
Name
Short Description
format-value
Signal which allows you to change how the scale value is displayed.
例子
代码:
#!/usr/bin/env python3# Created by xiaosanyu at 16/7/14# section 118# # author: xiaosanyu# website: yuxiaosan.tk \# http://blog.csdn.net/a87b01c14# created: 16/7/14
TITLE = "Scale"
DESCRIPTION = """
A Gtk.Scale is a slider control used to select a numeric value. To use it,
you’ll probably want to investigate the methods on its base class,
Gtk.Range, in addition to the methods for Gtk.Scale itself.
"""import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, Gio, GLib
classScaleWindow(Gtk.Window):def__init__(self, *args, **kwargs):
Gtk.Window.__init__(self, title="Scale Example")
self.set_size_request(250, 200)
box = Gtk.VBox(spacing=6)
ad1 = Gtk.Adjustment(value=50, lower=0, upper=100, step_increment=1, page_increment=1,
page_size=0)
ad2 = Gtk.Adjustment(value=50, lower=0, upper=100, step_increment=1, page_increment=1,
page_size=0)
scale1 = Gtk.Scale(adjustment=ad1)
scale1.set_show_fill_level(True)
box.pack_start(scale1, False, False, 0)
scale2 = Gtk.Scale(adjustment=ad2)
for i in [x * 10for x in range(11)]:
scale2.add_mark(i, Gtk.PositionType.BOTTOM)
box.pack_start(scale2, False, False, 0)
self.add(box)
defmain():
win = ScaleWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()