本文整理汇总了Python中gi.repository.Gtk.Adjustment方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.Adjustment方法的具体用法?Python Gtk.Adjustment怎么用?Python Gtk.Adjustment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.Adjustment方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Adjustment [as 别名]
def __init__(self, shell_player):
super().__init__()
self.set_orientation(Gtk.Orientation.HORIZONTAL)
self.adjustment = Gtk.Adjustment(0, 0, 10, 1, 10, 0)
self.set_adjustment(self.adjustment)
self.set_hexpand(True)
self.set_draw_value(False)
self.set_sensitive(False)
self.shell_player = shell_player
self.dragging = self.drag_moved = False
self.connect('button-press-event', slider_press_callback)
self.connect('motion-notify-event', slider_moved_callback)
self.connect('button-release-event', slider_release_callback)
self.connect('focus-out-event', slider_release_callback)
self.changed_callback_id = self.connect('value-changed',
slider_changed_callback)
self.set_size_request(150, -1)
self.show_all()
示例2: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Adjustment [as 别名]
def __init__(
self,
text,
option_name,
default=0,
min_value=0,
max_value=1000,
increment=1,
**kwargs
):
Option.__init__(self, text, option_name, **kwargs)
value = Option.config.read(option_name, default=default)
value = int(value)
self.spin_button = Gtk.SpinButton()
adjustment = Gtk.Adjustment(value, min_value, max_value, increment, 10, 0)
self.spin_button.set_adjustment(adjustment)
self.spin_button.set_value(value)
self.spin_button.set_numeric(True)
self.spin_button.set_update_policy(Gtk.SpinButtonUpdatePolicy.IF_VALID)
self.pack_start(self.spin_button, True, True, 0)
示例3: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Adjustment [as 别名]
def __init__(self, name, *args, **kwargs):
"""
:param str name: The name of this option.
:param str description: The description of this option.
:param default: The default value of this option.
:param str display_name: The name to display in the UI to the user for this option.
:param adjustment: The adjustment details of the options value.
:type adjustment: :py:class:`Gtk.Adjustment`
"""
self.adjustment = kwargs.pop('adjustment', Gtk.Adjustment(0, -0x7fffffff, 0x7fffffff, 1, 10, 0))
super(ClientOptionInteger, self).__init__(name, *args, **kwargs)
示例4: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Adjustment [as 别名]
def __init__(self, req, backend, width):
"""
Creates the Gtk.Adjustment and the related label. Loads the current
period.
@param req: a Requester
@param backend: a backend object
@param width: the width of the Gtk.Label object
"""
super().__init__()
self.backend = backend
self.req = req
self._populate_gtk(width)
self._connect_signals()
示例5: _populate_gtk
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Adjustment [as 别名]
def _populate_gtk(self, width):
"""Creates the gtk widgets
@param width: the width of the Gtk.Label object
"""
period_label = Gtk.Label(label=_("Check for new tasks every"))
period_label.set_alignment(xalign=0, yalign=0.5)
period_label.set_line_wrap(True)
period_label.set_size_request(width=width, height=-1)
self.pack_start(period_label, False, True, 0)
align = Gtk.Alignment.new(0, 0.5, 1, 0)
align.set_padding(0, 0, 10, 0)
self.pack_start(align, False, True, 0)
period = self.backend.get_parameters()['period']
self.adjustment = Gtk.Adjustment(value=period,
lower=1,
upper=120,
step_incr=1,
page_incr=0,
page_size=0)
self.period_spin = Gtk.SpinButton(adjustment=self.adjustment,
climb_rate=0.3,
digits=0)
self.minutes_label = Gtk.Label()
self.update_minutes_label()
self.minutes_label.set_alignment(xalign=0, yalign=0.5)
self.pack_start(self.minutes_label, False, True, 0)
align.add(self.period_spin)
self.show_all()
示例6: do_set_property
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Adjustment [as 别名]
def do_set_property(self, pspec, value):
if value["type"] == "check":
self.toggle_renderer.set_active(value["value"])
self.set_property("mode", Gtk.CellRendererMode.ACTIVATABLE)
elif value["type"] == "spin":
adjustment = Gtk.Adjustment(value=int(value["value"]),
lower=value["min"],
upper=value["max"],
step_increment=1)
self.spin_renderer.set_property("adjustment", adjustment)
self.spin_renderer.set_property("text", str(value["value"]))
self.set_property("mode", Gtk.CellRendererMode.EDITABLE)
elif value["type"] == "text":
self.text_renderer.set_property("text", value["value"])
self.set_property("mode", Gtk.CellRendererMode.EDITABLE)
elif value["type"] == "combo":
liststore = Gtk.ListStore(str)
for choice in value["choices"]:
liststore.append([choice])
self.combo_renderer.set_property("model", liststore)
self.combo_renderer.set_property("text", value["value"])
self.set_property("mode", Gtk.CellRendererMode.EDITABLE)
elif value["type"] == "button":
self.button_renderer.set_property("text", "")
setattr(self, pspec.name, value)
示例7: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Adjustment [as 别名]
def __init__(self, min=0, max=100, value=0, step=1, page_step=5):
adjustment = Gtk.Adjustment(value=value, lower=min, upper=max, step_increment=step, page_increment=page_step, page_size=0)
Gtk.SpinButton.__init__(self, adjustment=adjustment)
示例8: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Adjustment [as 别名]
def __init__( # pylint: disable=too-many-arguments
self,
display_name, key,
callback,
init_value,
min_value, max_value,
step_increment,
page_increment,
page_size
):
adjustment = Gtk.Adjustment(
value=init_value,
lower=min_value,
upper=max_value,
step_increment=step_increment,
page_increment=page_increment,
page_size=page_size
)
spinbutton = Gtk.SpinButton(
adjustment=adjustment,
)
spinbutton.set_numeric(True)
spinbutton.set_update_policy(Gtk.SpinButtonUpdatePolicy.IF_VALID)
super().__init__(
display_name=display_name,
key=key,
callback=callback,
value_widget=spinbutton
)
示例9: adjust_frame_position
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Adjustment [as 别名]
def adjust_frame_position(self, *args):
""" Select how to align the frame on screen.
"""
win_aspect_ratio = float(self.c_win.get_allocated_width()) / self.c_win.get_allocated_height()
if win_aspect_ratio <= float(self.c_frame.get_property("ratio")):
prop = "yalign"
else:
prop = "xalign"
val = self.c_frame.get_property(prop)
button = Gtk.SpinButton()
button.set_adjustment(Gtk.Adjustment(lower=0.0, upper=1.0, step_increment=0.01))
button.set_digits(2)
button.set_value(val)
button.connect("value-changed", self.update_frame_position, prop)
popup = Gtk.Dialog(title = _("Adjust alignment of slides in projector screen"), transient_for = self.p_win)
popup.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)
box = popup.get_content_area()
box.add(button)
popup.show_all()
response = popup.run()
popup.destroy()
# revert if we cancelled
if response == Gtk.ResponseType.CANCEL:
self.c_frame.set_property(prop, val)
else:
self.config.set('content', prop, str(button.get_value()))
示例10: on_discount_clicked
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Adjustment [as 别名]
def on_discount_clicked(self, button):
dialog = Gtk.Dialog("Discount percentage",
self.builder.get_object('general'),
Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.OK)
)
adj = Gtk.Adjustment(0, 0, 100, 1, 1)
spin = Gtk.SpinButton()
spin.set_adjustment(adj)
hbox = Gtk.HBox()
hbox.pack_start(spin, True, True, 0)
hbox.pack_start(Gtk.Label(' % ', True, True, 0), False, False, 0)
hbox.show_all()
dialog.vbox.pack_start(hbox, False, False, 0)
result = dialog.run()
if result == Gtk.ResponseType.OK:
val = spin.get_value()
total = self.total_credit_entry.get_float()
discount = (val*total)/100
self.discount_entry.set_text(str(discount))
dialog.destroy()
示例11: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Adjustment [as 别名]
def __init__(self, parent, current_file, gcolor):
Gtk.Dialog.__init__(self, "Pick a Color", parent, 0,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.OK))
self.set_default_size(150, 100)
box = self.get_content_area()
box.set_border_width(10)
box.set_spacing(10)
sat_box = Gtk.Box(spacing=10, orientation=Gtk.Orientation.HORIZONTAL)
light_box = Gtk.Box(spacing=10, orientation=Gtk.Orientation.HORIZONTAL)
self.colorchooser = Gtk.ColorChooserWidget(show_editor=True)
self.colorchooser.set_use_alpha(False)
self.colorchooser.set_rgba(gcolor)
r, g, b, _ = list(map(lambda x: round(x*100*2.55), gcolor))
hue, light, sat = util.rgb_to_hls(r, g, b)
self.sat_lbl = Gtk.Label('Saturation')
self.light_lbl = Gtk.Label('Light ')
sat_range = Gtk.Adjustment(0, 0, 1, 0.1, 0.1, 0)
self.sat_slider = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL,
adjustment=sat_range)
self.sat_slider.set_value(-sat)
self.sat_slider.set_digits(2)
self.sat_slider.connect('value-changed', self.slider_changed, 'sat')
light_range = Gtk.Adjustment(5, 0, 255, 1, 10, 0)
self.light_slider = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL,
adjustment=light_range)
self.light_slider.set_value(light)
self.light_slider.connect('value-changed',
self.slider_changed, 'light')
box.add(self.colorchooser)
sat_box.pack_start(self.sat_lbl, True, True, 0)
sat_box.pack_start(self.sat_slider, True, True, 0)
light_box.pack_start(self.light_lbl, True, True, 0)
light_box.pack_start(self.light_slider, True, True, 0)
box.add(light_box)
box.add(sat_box)
self.show_all()
示例12: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Adjustment [as 别名]
def __init__(self, controller):
super( SimulatorWindow, self ).__init__()
self.controller = controller
self.elapsed = 0.0
self.epoch = 0
self.throttleval = 0.0
self.loadval = 0.0
self.committedThrottleVal = 0.0
self.dt = 1.0 / simconstants.SIMFREQ
self.va = 0.0
self.vb = 0.0
self.vc = 0.0
self.connect('destroy', lambda w: Gtk.main_quit())
self.set_default_size(1024, 800)
vbox = Gtk.VBox()
self.add(vbox)
self.table = GraphTable()
vbox.pack_start( self.table, True, True, 0 )
self.table.add_row( "omega", 0.05 )
self.table.add_row( "theta", 5 )
self.table.add_row( "va", 3 )
self.table.add_row( "ia", 3 )
self.table.add_row( "bemf", 4 )
self.table.add_row( "torque", 50 )
self.table.add_row( "errors", 5 )
hbox = Gtk.HBox()
self.pwm = self.add_label( "throttle (%): ", hbox )
adj1 = Gtk.Adjustment(0.0, 0.0, 101.0, 0.1, 1.0, 1.0)
self.throttlescale = Gtk.HScale()
self.throttlescale.set_adjustment( adj1 )
self.throttlescale.set_digits(1)
self.throttlescale.set_draw_value(True)
hbox.pack_start( self.throttlescale, True, True, 0 )
self.throttlescale.connect( "change-value", self.change_throttle )
self.load = self.add_label( "load (Nm): ", hbox )
adj2 = Gtk.Adjustment(0.0, 0.0, 5.0, 0.01, 1.0, 1.0)
self.loadscale = Gtk.HScale()
self.loadscale.set_adjustment( adj2 )
self.loadscale.set_digits(2)
self.loadscale.set_draw_value(True)
hbox.pack_start( self.loadscale, True, True, 0 )
self.loadscale.connect( "change-value", self.change_load )
vbox.pack_start(hbox, False, False, 0)
self.sim = Simulator()
GObject.timeout_add( 1, self.callback )
self.show_all()