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


Python Gadget.from_widget方法代码示例

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


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

示例1: _paste_cb

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
 def _paste_cb(self, item, placeholder):
     gadget = util.get_parent(placeholder)
     if isinstance(placeholder, gtk.TreeView):
         from gazpacho.gadget import Gadget
         clipboard.paste(Gadget.from_widget(placeholder))
     else:
         clipboard.paste(placeholder, gadget.project)
开发者ID:dsaran,项目名称:packagehelper,代码行数:9,代码来源:popup.py

示例2: _start_editing

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
    def _start_editing(self, menuBar):
        gadget = Gadget.from_widget(menuBar)
        project = gadget.project

        # create the fake menubar
        fakeBar = MenuBar(gadget)

        # load it with our xml ui definition
        ui_def = project.uim.get_ui(gadget, 'initial-state')
        if ui_def:
            doc = minidom.parseString(ui_def[0])
            fakeBar.load(doc.documentElement)

        # replace the real one with this fake one
        fakeBar.show_all()
        self.replace_child(project.context, menuBar, fakeBar, menuBar.parent)

        # save some information to restore the state in _end_editing
        self._bars[menuBar].editing = True
        self._bars[menuBar].fakeBar = fakeBar
        i = project.selection.connect('selection-changed',
                                      self._on_selection__changed, menuBar)
        self._bars[menuBar].edit_activate_id = i

        fakeBar.get_toplevel().queue_draw()
开发者ID:dsaran,项目名称:packagehelper,代码行数:27,代码来源:bars.py

示例3: set

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
    def set(self, widget):
        from gazpacho.gadget import Gadget

        # remove old reference
        old_widget = self.get()
        if old_widget:
            old_gadget = Gadget.from_widget(old_widget)
            old_gadget.references.remove_referrer(self)

        # add new reference
        if widget:
            gadget = Gadget.from_widget(widget)
            gadget.references.add_referrer(self)

        #super(ObjectType, self).set(widget)
        self._set(widget)
开发者ID:dsaran,项目名称:packagehelper,代码行数:18,代码来源:properties.py

示例4: _end_editing

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
    def _end_editing(self, menuBar):
        gadget = Gadget.from_widget(menuBar)
        if not gadget:
            return
        project = gadget.project
        fakeBar = self._bars[menuBar].fakeBar
        parent = fakeBar.parent

        # put the real menuBar back in its place
        newBar = project.uim.get_widget(gadget)
        fakeBar.hide_all() # it's very important to hide this widget now
        newBar.show_all()
        self.replace_child(project.context, fakeBar, newBar, parent)

        # restore the state
        i = self._bars[menuBar].edit_activate_id
        project.selection.disconnect(i)
        self._bars[menuBar].editing = False
        self._bars[menuBar].fakeBar = None
        self._bars[menuBar].edit_activate_id = 0

        if newBar != menuBar:
            self._add_edit_button(newBar)
            project.remove_widget(menuBar)
            gadget.setup_widget(newBar)
            project.add_widget(newBar)

            info = self._bars[menuBar]
            del self._bars[menuBar]
            self._bars[newBar] = info
            menuBar.destroy()
开发者ID:dsaran,项目名称:packagehelper,代码行数:33,代码来源:bars.py

示例5: set

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
    def set(self, new_size):
        old_size = len(self.object.get_children())
        if new_size == old_size:
            return
        elif new_size > old_size:
            # The box has grown. Add placeholders
            while new_size > old_size:
                self.object.add(Placeholder())
                old_size += 1
        elif new_size > 0:
            # The box has shrunk. Remove placeholders first, starting
            # with the last one
            for child in self.object.get_children()[::-1]:
                if isinstance(child, Placeholder):
                    gtk.Container.remove(self.object, child)
                    old_size -= 1

                if old_size == new_size:
                    return

            # and then remove widgets
            child = self.object.get_children()[-1]
            while old_size > new_size and child:
                gadget = Gadget.from_widget(child)
                if gadget: # It may be None, e.g a placeholder
                    gadget.project.remove_widget(child)

                gtk.Container.remove(self.object, child)
                child = self.object.get_children()[-1]
                old_size -= 1
        self.notify()
开发者ID:dsaran,项目名称:packagehelper,代码行数:33,代码来源:box.py

示例6: _on_widget__drag_data_get

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
    def _on_widget__drag_data_get(self, event_widget, drag_context,
                                  selection_data, info, time):
        """Make the widget data available in the format that was
        requested.

        If the drag and drop occurs within the application the widget
        can be accessed directly otherwise it has to be passed as an
        XML string.
        """
        source_gadget = Gadget.from_widget(event_widget).dnd_gadget

        # If we can't get the widget we indicate this failure by
        # passing an empty string. Not sure if it's correct but it
        # works for us. Note that the source widget is sometimes
        # different from the dragged widget.
        data = ""
        if source_gadget:
            # The widget should be passed as XML
            if info == INFO_TYPE_XML:
                data = source_gadget.to_xml(skip_external_references=True)
            # The widget can be retrieved directly and we only pass the name
            elif info == INFO_TYPE_WIDGET:
                data = source_gadget.name

        selection_data.set(selection_data.target, 8, data)
开发者ID:dsaran,项目名称:packagehelper,代码行数:27,代码来源:dndhandlers.py

示例7: _update_edit_actions

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
    def _update_edit_actions(self, selection):
        """
        Update the actions in the edit group.

        @param selection: the selected widgets
        @type selection: list
        """
        if len(selection) == 1:
            widget = selection[0]
            gadget = Gadget.from_widget(widget)

            # Placeholders cannot be cut or copied but sometimes deleted
            if isinstance(widget, Placeholder):
                bar_manager.set_action_props(('Copy', 'Cut'),
                                             sensitive=False)
                bar_manager.set_action_prop('Delete',
                                            sensitive=widget.is_deletable())

            # Internal children cannot be cut, copied or deleted.
            elif gadget.internal_name:
                bar_manager.set_action_props(('Copy', 'Cut', 'Delete'),
                                             sensitive=False)

            else:
                bar_manager.set_action_props(('Copy', 'Cut', 'Delete'),
                                             sensitive=True)
        else:
            bar_manager.set_action_props(('Copy', 'Cut', 'Delete'),
                                         sensitive=False)

        # Unless the widget is toplevel it can only be pasted on a placeholder
        item = clipboard.get_selected_item()
        self._update_paste_action(selection, item)
开发者ID:dsaran,项目名称:packagehelper,代码行数:35,代码来源:uimstate.py

示例8: set

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
    def set(self, value):
        old_size = self.object.get_n_pages()
        new_size = value
        if new_size == old_size:
            return

        if new_size > old_size:
            project = self._project
            # The notebook has grown. Add pages
            while new_size > old_size:
                label = gtk.Label()
                project.set_new_widget_name(label)

                #print load_gadget_from_widget(label, project)
                no = self.object.append_page(
                    Placeholder(), label)
                label.set_text('Page %d' % (no + 1))
                #project.add_widget(label)
                old_size += 1
        else:
            # The notebook has shrunk. Remove pages

            # Thing to remember is that GtkNotebook starts the
            # page numbers from 0, not 1 (C-style). So we need to do
            # old_size-1, where we're referring to "nth" widget.
            while old_size > new_size:
                child_widget = self.object.get_nth_page(old_size - 1)
                child_gadget = Gadget.from_widget(child_widget)
                # If we got it, and it's not a placeholder, remove it
                # from the project
                if child_gadget:
                    self._project.remove_widget(child_widget)

                self.object.remove_page(old_size - 1)
                old_size -= 1
开发者ID:dsaran,项目名称:packagehelper,代码行数:37,代码来源:notebook.py

示例9: draw_annotations

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
def draw_annotations(expose_widget, expose_win):
    """ This is called to redraw any gazpacho annotations that intersect
    the given exposed window. We only draw nodes on windows that are
    actually owned by the widget. This keeps us from repeatedly
    drawing nodes for the same window in the same expose event. """

    from gazpacho.gadget import Gadget

    expose_gadget = Gadget.from_widget(expose_widget)
    if not expose_gadget:
        expose_gadget = get_parent(expose_widget)
    if not expose_gadget:
        return False

    project = expose_gadget.project

    if not expose_win.is_viewable():
        return False

    # Find the corresponding widget and gadget
    if expose_widget != expose_win.get_user_data():
        return False

    annotator = Annotator(expose_widget, expose_win)

    _draw_box_borders(project, expose_widget.get_toplevel(),
                      expose_win, annotator)
    _draw_nodes(project, expose_widget, expose_win, annotator)
开发者ID:dsaran,项目名称:packagehelper,代码行数:30,代码来源:annotator.py

示例10: _init_property_meta_data

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
    def _init_property_meta_data(self, dialog):
        """
        Set the metadata for some of the properties. This should not
        set default values of the properties since that is not always
        what we want.
        """
        # XXX not sure if we can assume that there actually is a vbox
        # and an action_area here?

        vbox = Gadget.from_widget(dialog.vbox)
        if vbox:
            vbox.get_prop('border-width').editable = False

        action_area = Gadget.from_widget(dialog.action_area)
        if action_area:
            action_area.get_prop('border-width').editable = False
            action_area.get_prop('spacing').editable = False
开发者ID:dsaran,项目名称:packagehelper,代码行数:19,代码来源:dialog.py

示例11: _on_widget__drag_begin

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
 def _on_widget__drag_begin(self, event_widget, drag_context):
     """
     Set a drag icon that matches the source widget.
     """
     source_gadget = Gadget.from_widget(event_widget).dnd_gadget
     if source_gadget:
         pixbuf = source_gadget.adaptor.icon.get_pixbuf()
         event_widget.drag_source_set_icon_pixbuf(pixbuf)
开发者ID:dsaran,项目名称:packagehelper,代码行数:10,代码来源:dndhandlers.py

示例12: _get_target_project

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
    def _get_target_project(self, widget):
        """
        Get the project to which the target belongs.

        @param widget: the target widget
        @type widget: gtk.Widget
        """
        gadget = Gadget.from_widget(widget)
        return gadget.project
开发者ID:dsaran,项目名称:packagehelper,代码行数:11,代码来源:dndhandlers.py

示例13: _populate_model_real

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
 def _populate_model_real(self, widgets, parent_iter, add_children):
     for w in widgets:
         iter = parent_iter
         gadget = Gadget.from_widget(w)
         if gadget:
             iter = self._model.append(parent_iter, (gadget,))
             if add_children:
                 children = gadget.get_children()
                 self._populate_model_real(children, iter, True)
开发者ID:dsaran,项目名称:packagehelper,代码行数:11,代码来源:widgetview.py

示例14: restore

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
 def restore(self, context, widget, data):
     ui_defs, placeholder = data    
     gadget = Gadget.from_widget(widget)
     
     # adding the widget to uim will replace the gtk-widget
     # connected to the gadget
     context.get_project().uim.add_gadget(gadget, ui_defs)
 
     if placeholder:
         Gadget.replace(placeholder, gadget.widget, gadget.get_parent())
开发者ID:dsaran,项目名称:packagehelper,代码行数:12,代码来源:bars.py

示例15: get_parent

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import from_widget [as 别名]
def get_parent(widget):
    from gazpacho.gadget import Gadget
    parent_widget = widget
    gadget = None
    while True:
        parent_widget = parent_widget.get_parent()
        if parent_widget is None:
            return None
        gadget = Gadget.from_widget(parent_widget)
        if gadget is not None:
            return gadget

    return None
开发者ID:dsaran,项目名称:packagehelper,代码行数:15,代码来源:util.py


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