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


Python gadget.Gadget类代码示例

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


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

示例1: _execute_paste

    def _execute_paste(self):
        # Note that updating the dependencies might replace the
        # widget's gtk-widget so we need to make sure we refer to the
        # correct one afterward.
        from gazpacho.gadget import Gadget
        self._gadget.deleted = False

        if self._gadget.is_toplevel():
            project = self._project
        else:
            parent = util.get_parent(self._placeholder)
            project = parent.project
            Gadget.replace(self._placeholder,
                           self._gadget.widget,
                           parent)

        project.add_widget(self._gadget.widget, new_name=True)
        self._gadget.select()

        self._gadget.widget.show_all()

        # We need to store the project of a toplevel widget to use
        # when undoing the cut.
        self._project = project

        return self._gadget
开发者ID:dsaran,项目名称:packagehelper,代码行数:26,代码来源:clipboard.py

示例2: restore

 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,代码行数:10,代码来源:bars.py

示例3: _create_box

    def _create_box(self, gtk_source, gtk_target, location):
        """
        Create a Box containing the widgets.

        @param gtk_source: the gtk  widget to add
        @type gtk_source: gtk.Gadget
        @param gtk_target: the gtk widget to replace
        @type gtk_target: gtk.Gadget
        @param location: Where to put the source in relation to the target
        @type location: (constant value)
        """
        from gazpacho.dndhandlers import DND_POS_TOP, DND_POS_BOTTOM, \
             DND_POS_LEFT

        # Create a Box with size 2
        if location in [DND_POS_TOP, DND_POS_BOTTOM]:
            box_type = 'GtkVBox'
        else:
            box_type = 'GtkHBox'
        adaptor = widget_registry.get_by_name(box_type)
        box_gadget = Gadget(adaptor, self._project)
        box_gadget.create_widget(interactive=False)
        box_gadget.get_prop('size').set(2)

        # Add the source and target widgets
        children = box_gadget.widget.get_children()
        if location in [DND_POS_TOP, DND_POS_LEFT]:
            source_placeholder, target_placeholder = children[0], children[1]
        else:
            source_placeholder, target_placeholder = children[1], children[0]

        Gadget.replace(source_placeholder, gtk_source, box_gadget)
        Gadget.replace(target_placeholder, gtk_target, box_gadget)

        return box_gadget.widget
开发者ID:dsaran,项目名称:packagehelper,代码行数:35,代码来源:box.py

示例4: add_tree_view_column

    def add_tree_view_column(self, tree_view, interactive=True):
        adaptor = widget_registry.get_by_type(gtk.TreeViewColumn)
        project = tree_view.project
        try:
            column = Gadget(adaptor, project)
            column.create_widget(interactive)
        except CreationCancelled:
            return

        cmd = CommandAddRemoveTreeViewColumn(tree_view, column, project, True)
        command_manager.execute(cmd, project)
        return column
开发者ID:dsaran,项目名称:packagehelper,代码行数:12,代码来源:treeview.py

示例5: _remove_gadget

    def _remove_gadget(self, gadget, placeholder):
        """
        Remove the widget from the gadget and replace it with a
        new placeholder.

        @param gadget: the gadget that should be removed
        @type gadget: L{gazpacho.gadget.Gadget}
        @param placeholder: the new placeholder
        @type placeholder: L{gazpacho.placeholder.Placeholder}
        """
        parent = gadget.get_parent()
        Gadget.replace(gadget.widget, placeholder, parent)

        gadget.widget.hide()
        gadget.project.remove_widget(gadget.widget)
开发者ID:dsaran,项目名称:packagehelper,代码行数:15,代码来源:dndhandlers.py

示例6: _paste_cb

 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,代码行数:7,代码来源:popup.py

示例7: set

    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,代码行数:16,代码来源:properties.py

示例8: draw_annotations

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,代码行数:28,代码来源:annotator.py

示例9: _delete_execute

    def _delete_execute(self):
        from gazpacho.gadget import Gadget
        from gazpacho.placeholder import Placeholder

        gadget = self._gadget

        if self._parent:
            if self._placeholder is None:
                self._placeholder = Placeholder()

            Gadget.replace(gadget.widget,
                           self._placeholder, self._parent)

        gadget.widget.hide()
        gadget.project.remove_widget(gadget.widget)
        gadget.deleted = True
开发者ID:dsaran,项目名称:packagehelper,代码行数:16,代码来源:command.py

示例10: _on_widget__drag_data_get

    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,代码行数:25,代码来源:dndhandlers.py

示例11: load

    def load(self, context, widget):
        """This loader is special because of these features:
        - It does not load the children of the menubar/toolbar
        - Load the uimanager and put its content (action groups) into the
        project
        """

#         # we need to save the properties of this widget because otherwise
#         # when we got it from the uimanager it's gonna be another widget with
#         # different properties
#         props = {}
#         for prop in gobject.list_properties(widget):
#             if 1 or prop.flags != gobject.PARAM_READWRITE:
#                 continue
#             if propertyclass.get_type_from_spec(prop) is gobject.TYPE_OBJECT:
#                 continue
#             # FIXME: This need to use the values from the catalog.
#             # But it doesn't work right now, the property in
#             # klass.properties is always set to False.
#             if prop.name == 'parent' or prop.name == 'child':
#                 continue
#             props[prop.name] = widget.get_property(prop.name)

        project = context.get_project()

        old_name = widget.name
        gadget = Gadget.load(widget, project)
        gadget._name = gadget.widget.name

        # change the widget for the one we get from the uimanager
        project.uim.load_widget(gadget, old_name)

        return gadget
开发者ID:dsaran,项目名称:packagehelper,代码行数:33,代码来源:bars.py

示例12: set

    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,代码行数:31,代码来源:box.py

示例13: set

    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,代码行数:35,代码来源:notebook.py

示例14: load

    def load(self, context, column):
        # column is a gtk.TreeViewColumn and we transform it into a
        # GazpachoTreeViewColumn
        gazpacho_column = GazpachoTreeViewColumn()
        gazpacho_column.copy(column)

        # copy the renderers also
        func = renderer_expert.get_type_based_on_renderer
        renderers = column.get_cell_renderers()
        cells = [(func(gobject.type_name(r)), r) for r in renderers]
        self.create_layout(gazpacho_column, cells)

        # now we replace the pure column with the gazpacho column
        # the old column is not useful anymore so we can set a custom widget
        # just to get its parent. see GTK+ bug #342471
        column.set_widget(gtk.Label())
        tree_view = get_column_parent(column)

        # when pasting a column from the clipboard, it is not attached to a
        # tree view yet
        if tree_view:
            tree_view.remove_column(column)
            tree_view.append_column(gazpacho_column)

        gazpacho_column.update_widget()

        project = context.get_project()
        return Gadget.load(gazpacho_column, project)
开发者ID:dsaran,项目名称:packagehelper,代码行数:28,代码来源:treeview.py

示例15: _end_editing

    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,代码行数:31,代码来源:bars.py


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