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