當前位置: 首頁>>代碼示例>>Python>>正文


Python EventIcon.set_fill_color方法代碼示例

本文整理匯總了Python中sugar3.graphics.icon.EventIcon.set_fill_color方法的典型用法代碼示例。如果您正苦於以下問題:Python EventIcon.set_fill_color方法的具體用法?Python EventIcon.set_fill_color怎麽用?Python EventIcon.set_fill_color使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sugar3.graphics.icon.EventIcon的用法示例。


在下文中一共展示了EventIcon.set_fill_color方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from sugar3.graphics.icon import EventIcon [as 別名]
# 或者: from sugar3.graphics.icon.EventIcon import set_fill_color [as 別名]
    def __init__(self, poll_activity):
        Gtk.EventBox.__init__(self)
        self.modify_bg(Gtk.StateType.NORMAL,
                       style.COLOR_WHITE.get_gdk_color())

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(box)

        poll_activity.reset_poll()

        label = Gtk.Label()
        label.set_markup('<span size="xx-large" color="%s">%s</span>'
                         % (darker_color_str, _('Choose a Poll')))
        label.set_halign(Gtk.Align.START)
        label.props.margin_top = style.GRID_CELL_SIZE
        label.props.margin_bottom = style.GRID_CELL_SIZE / 2
        label.props.margin_left = style.GRID_CELL_SIZE
        box.pack_start(label, False, False, 0)

        poll_selector_box = Gtk.VBox()
        poll_selector_box.props.margin_left = style.GRID_CELL_SIZE
        poll_selector_box.props.margin_right = style.GRID_CELL_SIZE

        scroll = Gtk.ScrolledWindow()
        scroll.modify_bg(Gtk.StateType.NORMAL,
                         style.COLOR_WHITE.get_gdk_color())
        scroll.set_valign(Gtk.Align.START)
        scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scroll.set_size_request(
            -1, Gdk.Screen.height() - style.GRID_CELL_SIZE * 4)

        scroll.add_with_viewport(poll_selector_box)

        box.pack_start(scroll, True, True, 0)

        for poll in poll_activity._polls:
            sha = poll.sha

            poll_row = Gtk.HBox()
            poll_row.props.margin = 10
            poll_selector_box.pack_start(poll_row, False, False, 0)
            poll_selector_box.pack_start(Gtk.HSeparator(), False, False, 0)

            evbox = Gtk.EventBox()
            title = Gtk.Label()
            title.set_markup(
                '<span size="large">%s (%s)</span>' %
                (GObject.markup_escape_text(poll.title),
                 GObject.markup_escape_text(poll.author)))
            title.set_halign(Gtk.Align.START)
            title.set_max_width_chars(55)
            title.set_ellipsize(Pango.EllipsizeMode.END)

            evbox.add(title)
            poll_row.pack_start(evbox, True, True, 0)

            poll_icon = PollIcon(poll)
            poll_row.pack_start(poll_icon, False, False,
                                style.GRID_CELL_SIZE / 2)

            if poll.active:
                button = EventIcon(icon_name='activity-poll',
                                   pixel_size=style.STANDARD_ICON_SIZE)
                button.set_stroke_color('#888888')
            else:
                button = EventIcon(icon_name='toolbar-view',
                                   pixel_size=style.STANDARD_ICON_SIZE)
                button.set_fill_color('#888888')

            evbox.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
            evbox.connect('button-press-event',
                          poll_activity._select_poll_button_cb, sha)
            poll_icon.connect('button-press-event',
                              poll_activity._select_poll_button_cb, sha)
            button.connect('button-press-event',
                           poll_activity._select_poll_button_cb, sha)

            poll_row.pack_start(button, False, False, style.GRID_CELL_SIZE / 2)

            if poll.author == profile.get_nick_name():
                button = EventIcon(icon_name='basket',
                                   pixel_size=style.STANDARD_ICON_SIZE)
                button.set_stroke_color('#888888')
                button.connect('button-press-event',
                               poll_activity._delete_poll_button_cb, sha,
                               poll.title)
                poll_row.pack_start(button, False, False, 0)

        self.show_all()
開發者ID:godiard,項目名稱:poll-activity,代碼行數:91,代碼來源:Widgets.py


注:本文中的sugar3.graphics.icon.EventIcon.set_fill_color方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。