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


Python Gadget.replace方法代码示例

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


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

示例1: _execute_paste

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import replace [as 别名]
    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,代码行数:28,代码来源:clipboard.py

示例2: _create_box

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import replace [as 别名]
    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,代码行数:37,代码来源:box.py

示例3: restore

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import replace [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

示例4: _remove_gadget

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import replace [as 别名]
    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,代码行数:17,代码来源:dndhandlers.py

示例5: _delete_execute

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import replace [as 别名]
    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,代码行数:18,代码来源:command.py

示例6: _add_gadget

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import replace [as 别名]
    def _add_gadget(self, gadget, placeholder):
        """
        Remove the old placeholder and add a widget from the gadget.

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

        project.add_widget(gadget.widget)
        gadget.select()

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

示例7: _create_execute

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import replace [as 别名]
    def _create_execute(self):
        from gazpacho.gadget import Gadget
        from gazpacho.placeholder import Placeholder

        gadget = self._gadget

        # 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.
        gadget.deleted = False
        widget = gadget.widget

        if isinstance(widget, gtk.Window):

            # make window management easier by making created windows
            # transient for the editor window
            widget.set_transient_for(get_utility(IGazpachoApp).get_window())

            # Show windows earlier so we can restore the window-position
            # before the property editor is shown
            old_pos = widget.get_property('window-position')
            widget.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        else:
            if self._placeholder is None:
                for child in self._parent.widget.get_children():
                    if isinstance(child, Placeholder):
                        self._placeholder = child
                        break
            Gadget.replace(self._placeholder, widget, self._parent)

        self._gadget.project.add_widget(widget)
        self._gadget.select()

        widget.show_all()
        if isinstance(widget, gtk.Window):
            widget.set_position(old_pos)

            # we have to attach the accelerators groups so key shortcuts
            # keep working when this window has the focus. Only do
            # this the first time when creating a window, not when
            # redoing the creation since the accel group is already
            # set by then
            if self._initial_creation:
                widget.add_accel_group(bar_manager.get_accel_group())
                self._initial_creation = False
开发者ID:dsaran,项目名称:packagehelper,代码行数:47,代码来源:command.py

示例8: _execute_cut

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import replace [as 别名]
    def _execute_cut(self):
        from gazpacho.gadget import Gadget
        from gazpacho.placeholder import Placeholder

        gadget = self._gadget

        if not gadget.is_toplevel():
            parent = gadget.get_parent()

            if not self._placeholder:
                self._placeholder = Placeholder()

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

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

示例9: _replace

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import replace [as 别名]
    def _replace(self, target, source):
        """
        Replace the target widget with the source widget.

        @param target: the target gtk widget
        @type target: gtk.Gadget
        @param source: the source gtk widget
        @type source: gtk.Gadget
        """
        parent = util.get_parent(target)
        Gadget.replace(target, source, parent)

        # Remove old widget
        target.hide()
        self._project.remove_widget(target)

        # Add new widget
        self._project.add_widget(source)
        source.show_all()
开发者ID:dsaran,项目名称:packagehelper,代码行数:21,代码来源:box.py

示例10: delete

# 需要导入模块: from gazpacho.gadget import Gadget [as 别名]
# 或者: from gazpacho.gadget.Gadget import replace [as 别名]
 def delete(self, context, widget):
     gadget = Gadget.from_widget(widget)
 
     # replace the widget with a placeholder
     parent = gadget.get_parent()
     placeholder = None
     if parent:
         placeholder = Placeholder()
         placeholder.set_name(gadget.name)
         Gadget.replace(gadget.widget, placeholder , parent)
     
     uim = context.get_project().uim
     ui_defs = uim.get_ui(gadget)
     uim.remove_gadget(gadget)
 
     if placeholder:
         gadget.widget = placeholder
         placeholder.set_data('gazpacho::gadget', gadget)
 
     return ui_defs, placeholder
开发者ID:dsaran,项目名称:packagehelper,代码行数:22,代码来源:bars.py


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