当前位置: 首页>>代码示例>>Python>>正文


Python EventIcon.set_icon_name方法代码示例

本文整理汇总了Python中sugar3.graphics.icon.EventIcon.set_icon_name方法的典型用法代码示例。如果您正苦于以下问题:Python EventIcon.set_icon_name方法的具体用法?Python EventIcon.set_icon_name怎么用?Python EventIcon.set_icon_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sugar3.graphics.icon.EventIcon的用法示例。


在下文中一共展示了EventIcon.set_icon_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Picker

# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import set_icon_name [as 别名]
class Picker(Gtk.Grid):

    def __init__(self, icon, label):
        Gtk.Grid.__init__(self)

        self._button = EventIcon(pixel_size=style.LARGE_ICON_SIZE,
                                 icon_name=icon)
        self.attach(self._button, 0, 0, 1, 1)
        self._button.hide()

        self._label = Gtk.Label(label.replace(' ', '\n'))
        self._label.props.justify = Gtk.Justification.CENTER
        self.attach(self._label, 0, 1, 1, 1)
        self._label.hide()

    def show_all(self):
        self._button.show()
        self._label.show()
        self.show()

    def hide_all(self):
        self._button.hide()
        self._label.hide()
        self.hide()

    def connect(self, callback, arg):
        self._button.connect('activate', callback, arg)

    def set_color(self, color):
        self._button.xo_color = color

    def set_icon(self, icon):
        self._button.set_icon_name(icon)
开发者ID:AbrahmAB,项目名称:sugar,代码行数:35,代码来源:agepicker.py

示例2: Picker

# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import set_icon_name [as 别名]
class Picker(Gtk.Grid):

    def __init__(self, icon, label):
        Gtk.Grid.__init__(self)

        self._button = EventIcon(pixel_size=style.LARGE_ICON_SIZE,
                                 icon_name=icon)
        self.attach(self._button, 0, 0, 1, 1)
        self._button.hide()

        self._label = Gtk.Label(label)
        self.attach(self._label, 0, 1, 1, 1)
        self._label.hide()

    def show_all(self):
        self._button.show()
        self._label.show()
        self.show()

    def hide_all(self):
        self._button.hide()
        self._label.hide()
        self.hide()

    def connect(self, callback, arg):
        self._button.connect('button-press-event', callback, arg)

    def set_color(self, color):
        self._button.xo_color = color

    def set_icon(self, icon):
        self._button.set_icon_name(icon)
开发者ID:AxEofBone7,项目名称:sugar,代码行数:34,代码来源:agepicker.py

示例3: AgePicker

# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import set_icon_name [as 别名]
class AgePicker(Gtk.Grid):

    age_changed_signal = GObject.Signal('age-changed',
                                        arg_types=([int]))

    def __init__(self, color, gender, age):
        Gtk.Grid.__init__(self)
        self._color = color
        self._gender = gender
        self._age = age

        if self._gender is '':
            # Used for graphic only; does not set user's gender preference.
            self._gender = 'female'

        self._icon = EventIcon(icon_name='%s-%d' % (self._gender, self._age),
                               pixel_size=style.LARGE_ICON_SIZE)
        self._icon.connect('button-press-event', self.__pressed_cb)
        self.attach(self._icon, 0, 0, 1, 1)
        self._icon.show()

        label = Gtk.Label()
        label.set_text(AGE_LABELS[self._age])
        self.attach(label, 0, 1, 1, 1)
        label.show()

        self.set_age()

    def set_color(self, color, age):
        self._color = color
        self.set_age(age)

    def set_age(self, age=None):
        if age in AGES:
            age_index = AGES.index(age)
        else:
            age_index = None

        if age_index == self._age:
            self._icon.props.xo_color = self._color
        else:
            self._icon.props.xo_color = _NOCOLOR
        self._icon.show()

    age = GObject.property(type=object, setter=set_age)

    def set_gender(self, gender):
        self._icon.set_icon_name('%s-%d' % (gender, self._age))
        self._icon.show()

    gender = GObject.property(type=object, setter=set_gender)

    def __pressed_cb(self, button, event):
        self.age_changed_signal.emit(self._age)
开发者ID:Akirato,项目名称:sugar,代码行数:56,代码来源:view.py


注:本文中的sugar3.graphics.icon.EventIcon.set_icon_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。