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


Python EventIcon.hide方法代码示例

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


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

示例1: Picker

# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import hide [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 hide [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: ReflectionGrid

# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import hide [as 别名]

#.........这里部分代码省略.........
        GObject.idle_add(self._choose_activity)

    def _choose_activity(self):
        if not hasattr(self, '_activity_sw'):
            grid = Gtk.Grid()
            self._reflection.activity.load_overlay_area(grid)
            grid.show()

            bundle_icons = utils.get_bundle_icons()
            x = 0
            y = 0
            for bundle_id in bundle_icons.keys():
                icon_path = bundle_icons[bundle_id]
                if icon_path is None:
                    continue
                pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                    icon_path, style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)
                image = Gtk.Image.new_from_pixbuf(pixbuf)
                button = Gtk.ToolButton()
                button.set_icon_widget(image)
                image.show()
                button.connect('clicked', self._insert_activity, bundle_id)
                grid.attach(button, x, y, 1, 1)
                button.show()
                x += 1
                if x > 6:
                    y += 1
                    x = 0
        self._reflection.activity.show_overlay_area()
        self._reflection.activity.reset_cursor()

    def _insert_activity(self, widget, bundle_id):
        ''' Add activity from UI '''
        self._reflection.activity.hide_overlay_area()
        self.add_activity(bundle_id)
        if self._reflection.activity.sharing:
            self._reflection.activity.send_event(ACTIVITY_CMD,
                {"obj_id": self._reflection.data["obj_id"],
                 "bundle_id": bundle_id})

    def add_activity(self, bundle_id):
        ''' Add activity from sharer '''
        if not 'activities' in self._reflection.data:
            self._reflection.data['activities'] = []
        self._reflection.data['activities'].append(
            utils.bundle_id_to_icon(bundle_id))
        self._reflection.set_modification_time()
        self._activities_align.remove(self._activities_grid)
        self._make_activities_grid()

    def _make_activities_grid(self):
        column = 0
        self._activities_grid = Gtk.Grid()
        self._activities = []
        if 'activities' in self._reflection.data:
            for icon_path in self._reflection.data['activities']:
                if icon_path is None:
                    continue
                try:
                    pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                        icon_path, BUTTON_SIZE, BUTTON_SIZE)
                except Exception as e:
                    logging.error('Could not find icon %s: %s' %
                                  (icon_path, e))
                    continue
                self._activities.append(Gtk.Image.new_from_pixbuf(pixbuf))
开发者ID:AbrahmAB,项目名称:reflect,代码行数:70,代码来源:reflectwindow.py

示例4: ReflectionGrid

# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import hide [as 别名]

#.........这里部分代码省略.........
        self._reflection.activity.busy_cursor()
        GObject.idle_add(self._choose_activity)

    def _choose_activity(self):
        if not hasattr(self, "_activity_sw"):
            grid = Gtk.Grid()
            self._reflection.activity.load_overlay_area(grid)
            grid.show()

            bundle_icons = utils.get_bundle_icons()
            x = 0
            y = 0
            for bundle_id in bundle_icons.keys():
                icon_path = bundle_icons[bundle_id]
                if icon_path is None:
                    continue
                pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_path, style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)
                image = Gtk.Image.new_from_pixbuf(pixbuf)
                button = Gtk.ToolButton()
                button.set_icon_widget(image)
                image.show()
                button.connect("clicked", self._insert_activity, bundle_id)
                grid.attach(button, x, y, 1, 1)
                button.show()
                x += 1
                if x > 6:
                    y += 1
                    x = 0
        self._reflection.activity.show_overlay_area()
        self._reflection.activity.reset_cursor()

    def _insert_activity(self, widget, bundle_id):
        """ Add activity from UI """
        self._reflection.activity.hide_overlay_area()
        self.add_activity(bundle_id)
        if self._reflection.activity.sharing:
            self._reflection.activity.send_event(
                "%s|%s|%s" % (ACTIVITY_CMD, self._reflection.data["obj_id"], bundle_id)
            )

    def add_activity(self, bundle_id):
        """ Add activity from sharer """
        if not "activities" in self._reflection.data:
            self._reflection.data["activities"] = []
        self._reflection.data["activities"].append(utils.bundle_id_to_icon(bundle_id))
        self._reflection.set_modification_time()
        self._activities_align.remove(self._activities_grid)
        self._make_activities_grid()

    def _make_activities_grid(self):
        column = 0
        self._activities_grid = Gtk.Grid()
        self._activities = []
        if "activities" in self._reflection.data:
            for icon_path in self._reflection.data["activities"]:
                if icon_path is None:
                    continue
                try:
                    pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_path, BUTTON_SIZE, BUTTON_SIZE)
                except Exception as e:
                    logging.error("Could not find icon %s: %s" % (icon_path, e))
                    continue
                self._activities.append(Gtk.Image.new_from_pixbuf(pixbuf))
                self._activities_grid.attach(self._activities[-1], column, 0, 1, 1)
                self._activities[-1].show()
                column += 1
开发者ID:samdroid-apps,项目名称:reflect,代码行数:70,代码来源:reflectwindow.py


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