當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。