本文整理汇总了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
示例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
示例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())
示例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)
示例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
示例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()
示例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
示例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
示例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()
示例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