本文整理汇总了Python中sugar3.graphics.toolbutton.ToolButton.set_can_focus方法的典型用法代码示例。如果您正苦于以下问题:Python ToolButton.set_can_focus方法的具体用法?Python ToolButton.set_can_focus怎么用?Python ToolButton.set_can_focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.toolbutton.ToolButton
的用法示例。
在下文中一共展示了ToolButton.set_can_focus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IntensitySelector
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_can_focus [as 别名]
class IntensitySelector(Gtk.ToolItem):
__gsignals__ = {
'changed': (GObject.SignalFlags.RUN_LAST, None, ([])), }
def __init__(self, value_range, default_value, default_image):
Gtk.ToolItem.__init__(self)
self._palette_invoker = ToolInvoker()
self.palette = None
self._values = value_range
self._palette_invoker.attach_tool(self)
# theme the buttons, can be removed if add the style to the sugar css
# these are the same values used in gtk-widgets.css.em
if style.zoom(100) == 100:
subcell_size = 15
default_padding = 6
else:
subcell_size = 11
default_padding = 4
hbox = Gtk.HBox()
vbox = Gtk.VBox()
self.add(vbox)
# add a vbox to set the padding up and down
vbox.pack_start(hbox, True, True, default_padding)
self._size_down = ToolButton('go-previous-paired')
self._palette_invoker.attach_tool(self._size_down)
self._size_down.set_can_focus(False)
self._size_down.connect('clicked', self.__value_changed_cb, False)
hbox.pack_start(self._size_down, False, False, 5)
# TODO: default?
self._default_value = default_value
self._value = self._default_value
self.image_wrapper = Gtk.EventBox()
self._intensityImage = Gtk.Image()
self.image_wrapper.add(self._intensityImage)
self.image_wrapper.show()
self._intensityImage.set_from_file(default_image)
self._intensityImage.show()
self._palette_invoker.attach_widget(self.image_wrapper)
hbox.pack_start(self.image_wrapper, False, False, 10)
self._size_up = ToolButton('go-next-paired')
self._palette_invoker.attach_tool(self._size_up)
self._size_up.set_can_focus(False)
self._size_up.connect('clicked', self.__value_changed_cb, True)
hbox.pack_start(self._size_up, False, False, 5)
radius = 2 * subcell_size
theme_up = "GtkButton {border-radius:0px %dpx %dpx 0px;}" % (radius,
radius)
css_provider_up = Gtk.CssProvider()
css_provider_up.load_from_data(theme_up)
style_context = self._size_up.get_style_context()
style_context.add_provider(css_provider_up,
Gtk.STYLE_PROVIDER_PRIORITY_USER)
theme_down = "GtkButton {border-radius: %dpx 0px 0px %dpx;}" % (radius,
radius)
css_provider_down = Gtk.CssProvider()
css_provider_down.load_from_data(theme_down)
style_context = self._size_down.get_style_context()
style_context.add_provider(css_provider_down,
Gtk.STYLE_PROVIDER_PRIORITY_USER)
self.show_all()
def __destroy_cb(self, **args):
if self._palette_invoker is not None:
self._palette_invoker.detach()
def __value_changed_cb(self, button, increase):
if self._value in self._values:
i = self._values.index(self._value)
if increase:
if i < len(self._values) - 1:
i += 1
else:
if i > 0:
i -= 1
else:
i = self._values.index(self._default_value)
self._value = self._values[i]
self._size_down.set_sensitive(i != 0)
self._size_up.set_sensitive(i < len(self._values) - 1)
self.emit('changed')
def set_value(self, val):
#.........这里部分代码省略.........