本文整理汇总了Python中scripts.gui.action.Action类的典型用法代码示例。如果您正苦于以下问题:Python Action类的具体用法?Python Action怎么用?Python Action使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Action类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enable
def enable(self):
""" plugin method """
if self._enabled is True:
return
self._editor = scripts.editor.getEditor()
#self._camera = self._editor.getActiveMapView().getCamera()
self._action_show = Action(u"Camera Editor", checkable=True)
scripts.gui.action.activated.connect(self.toggle, sender=self._action_show)
self._editor._tools_menu.addAction(self._action_show)
self._createGui()
self._enabled = True
示例2: enable
def enable(self):
if self._enabled is True:
return
self.editor = scripts.editor.getEditor()
self.engine = self.editor.getEngine()
self._showAction = Action(u"Object selector", checkable=True)
scripts.gui.action.activated.connect(self.toggle, sender=self._showAction)
self.editor._tools_menu.addAction(self._showAction)
events.postMapShown.connect(self.update_namespace)
events.onObjectSelected.connect(self.setPreview)
events.onObjectsImported.connect(self.update_namespace)
self.buildGui()
示例3: enable
def enable(self):
""" Enable plugin """
if self._enabled is True:
return
# Fifedit plugin data
self._editor = scripts.editor.getEditor()
self._action_show = Action(u"LayerTool", checkable=True)
scripts.gui.action.activated.connect(self.toggle, sender=self._action_show)
self._editor._tools_menu.addAction(self._action_show)
self._createGui()
self.toggle()
events.postMapShown.connect(self.update)
events.preMapClosed.connect(self._mapClosed)
示例4: enable
def enable(self):
""" Enable plugin """
if self._enabled: return
# Fifedit plugin data
self._action_show = Action(u"LayerTool", checkable=True)
scripts.gui.action.activated.connect(self.toggle, sender=self._action_show)
self._editor._tools_menu.addAction(self._action_show)
self.create()
self.toggle()
events.postMapShown.connect(self.update)
events.preMapClosed.connect(self._mapClosed)
if self.settings['docked']:
self._editor.dockWidgetTo(self.container, self.settings['dockarea'])
示例5: enable
def enable(self):
""" enables the plugin and connects to the editor """
if self._enabled: return
self._enabled = True
# Fifedit plugin data
self._action_show = Action(self.getName(), checkable=True)
scripts.gui.action.activated.connect(self.toggle, sender=self._action_show)
self._editor._tools_menu.addAction(self._action_show)
self.load_map_history()
self.create()
onOpenMapFile.connect(self.update)
if self.settings['docked']:
self._editor.dockWidgetTo(self.container, self.settings['dockarea'])
示例6: enable
def enable(self):
""" plugin method """
if self._enabled is True:
return
self._editor = scripts.editor.getEditor()
self.engine = self._editor.getEngine()
self.imagemanager = self.engine.getImageManager()
self._showAction = Action(unicode(self.getName(),"utf-8"), checkable=True)
scripts.gui.action.activated.connect(self.toggle_gui, sender=self._showAction)
self._editor._tools_menu.addAction(self._showAction)
events.onInstancesSelected.connect(self.input)
self._reset()
self.create_gui()
示例7: enable
def enable(self):
""" enables the plugin and connects to the editor """
if self._enabled: return
self._enabled = True
# Fifedit plugin data
self._action_show = Action(self.getName(), checkable=True)
scripts.gui.action.activated.connect(self.toggle, sender=self._action_show)
self._editor._tools_menu.addAction(self._action_show)
postMapShown.connect(self.update)
onObjectSelected.connect(self.set_object)
onObjectsImported.connect(self.update_namespaces)
self.create()
self.toggle()
if self.settings['docked']:
self._editor.dockWidgetTo(self.container, self.settings['dockarea'])
示例8: enable
def enable(self):
""" plugin method """
if self._enabled: return
self._enabled = True
self._action_show = Action(unicode(self.getName(),"utf-8"), checkable=True)
scripts.gui.action.activated.connect(self.toggle_gui, sender=self._action_show)
self._editor._tools_menu.addAction(self._action_show)
onObjectSelected.connect(self.update)
onInstancesSelected.connect(self.update)
preMapClosed.connect(self.hide)
postMapShown.connect(self.update)
self.create_gui()
self.update_gui()
if self.settings['docked']:
self._editor.dockWidgetTo(self.container, self.settings['dockarea'])
示例9: enable
def enable(self):
""" plugin method """
if not self._renderer_available:
self._enabled = False
return
if self._enabled is True:
return
self._editor = scripts.editor.getEditor()
self.engine = self._editor.getEngine()
self._showAction = Action(unicode(self.getName(),"utf-8"), checkable=True)
scripts.gui.action.activated.connect(self.toggle_gui, sender=self._showAction)
self._editor._tools_menu.addAction(self._showAction)
events.postMapShown.connect(self.update_renderer)
events.onMapChanged.connect(self.update_renderer)
self._reset()
self.create_gui()
示例10: enable
def enable(self):
if self._enabled is True:
return
self.editor = scripts.editor.getEditor()
self.engine = self.editor.getEngine()
self._show_action = Action(u"History manager", checkable=True)
self._undo_action = Action(u"Undo", "gui/icons/undo.png")
self._redo_action = Action(u"Redo", "gui/icons/redo.png")
self._next_action = Action(u"Next branch", "gui/icons/next_branch.png")
self._prev_action = Action(u"Previous branch", "gui/icons/previous_branch.png")
self._show_action.helptext = u"Toggle HistoryManager"
self._undo_action.helptext = u"Undo action (CTRL+Z)"
self._redo_action.helptext = u"Redo action (CTRL+SHIFT+Z)"
self._next_action.helptext = u"Next branch (CTRL+ALT+Z"
self._prev_action.helptext = u"Previous branch (CTRL+ALT+SHIFT+Z)"
scripts.gui.action.activated.connect(self.toggle, sender=self._show_action)
scripts.gui.action.activated.connect(self._undo, sender=self._undo_action)
scripts.gui.action.activated.connect(self._redo, sender=self._redo_action)
scripts.gui.action.activated.connect(self._next, sender=self._next_action)
scripts.gui.action.activated.connect(self._prev, sender=self._prev_action)
self._undo_group = ActionGroup(name=u"UndoGroup")
self._undo_group.addAction(self._undo_action)
self._undo_group.addAction(self._redo_action)
self._undo_group.addAction(self._next_action)
self._undo_group.addAction(self._prev_action)
self.editor._tools_menu.addAction(self._show_action)
self.editor._edit_menu.insertAction(self._undo_group, 0)
self.editor._edit_menu.insertSeparator(position=1)
events.postMapShown.connect(self.update)
undomanager.changed.connect(self.update)
self.buildGui()
示例11: enable
def enable(self):
""" plugin method overwrite """
if self._enabled: return
self._editor = scripts.editor.getEditor()
self._engine = self._editor.getEngine()
self._action_show = Action(unicode(self.getName(),"utf-8"), checkable=True)
scripts.gui.action.activated.connect(self.toggle_gui, sender=self._action_show)
self._editor._tools_menu.addAction(self._action_show)
events.onCellSelected.connect(self.input)
events.preMapClosed.connect(self.hide)
events.postMapShown.connect(self.map_shown)
events.mousePressed.connect(self.mouse_pressed)
self._reset()
self.create()
self.container.x = 0
self.container.y = 0
self.show()
示例12: LightEdit
class LightEdit(plugin.Plugin):
""" The B{LightEdit} module is a plugin for FIFedit and allows to change the
global light value
FEATURES:
- enable FIFE lighting renderer
- generate random light values
- test lightsetups by manipulating the color channels
- reset to default
"""
def __init__(self):
self.active = False
self._renderer = None
self._camera = None
self._enabled = False
self._light = False
self.map_loaded = False
self._color = {}
self._color.update(DEFAULT_GLOBAL_LIGHT)
random.seed()
if "LightRenderer" in dir(fife):
self._renderer_available = True
else:
self._renderer_available = False
def _reset(self):
""" resets all dynamic vars """
pass
def enable(self):
""" plugin method """
if not self._renderer_available:
self._enabled = False
return
if self._enabled is True:
return
self._editor = scripts.editor.getEditor()
self.engine = self._editor.getEngine()
self._showAction = Action(unicode(self.getName(),"utf-8"), checkable=True)
scripts.gui.action.activated.connect(self.toggle_gui, sender=self._showAction)
self._editor._tools_menu.addAction(self._showAction)
events.postMapShown.connect(self.update_renderer)
events.onMapChanged.connect(self.update_renderer)
self._reset()
self.create_gui()
def disable(self):
""" plugin method """
if self._enabled is False:
return
self._reset()
self.container.hide()
self.removeAllChildren()
self._editor._tools_menu.removeAction(self._showAction)
events.postMapShown.disconnect(self.update_renderer)
events.onMapChanged.disconnect(self.update_renderer)
def isEnabled(self):
""" plugin method """
return self._enabled;
def getName(self):
""" plugin method """
return "Light editor"
def create_gui(self):
""" create gui container and setup callbacks """
self.container = pychan.loadXML('gui/lightedit.xml')
self.container.mapEvents({
"enable_global_light" : self.toggle_light,
"random_global_light" : self.random_color,
"reset_global_light" : self.reset_global_light,
"increase_R" : cbwa(self.increase_color, r=True),
"decrease_R" : cbwa(self.decrease_color, r=True),
"value_R/mouseWheelMovedUp" : cbwa(self.increase_color, step=0.2, r=True),
"value_R/mouseWheelMovedDown" : cbwa(self.decrease_color, step=0.2, r=True),
"increase_G" : cbwa(self.increase_color, g=True),
"decrease_G" : cbwa(self.decrease_color, g=True),
"value_G/mouseWheelMovedUp" : cbwa(self.increase_color, step=0.2, g=True),
"value_G/mouseWheelMovedDown" : cbwa(self.decrease_color, step=0.2, g=True),
"increase_B" : cbwa(self.increase_color, b=True),
"decrease_B" : cbwa(self.decrease_color, b=True),
"value_B/mouseWheelMovedUp" : cbwa(self.increase_color, step=0.2, b=True),
"value_B/mouseWheelMovedDown" : cbwa(self.decrease_color, step=0.2, b=True),
#.........这里部分代码省略.........
示例13: CameraEdit
class CameraEdit(plugin.Plugin):
def __init__(self):
self._enabled = False
# Camera instance
self._camera = None
# Editor instance
self._editor = None
# Toolbar button to display Camera Editor
self._action_show = None
# GUI
self._container = None
self._ok_button = None
self._cancel_button = None
def enable(self):
""" plugin method """
if self._enabled is True:
return
self._editor = scripts.editor.getEditor()
#self._camera = self._editor.getActiveMapView().getCamera()
self._action_show = Action(u"Camera Editor", checkable=True)
scripts.gui.action.activated.connect(self.toggle, sender=self._action_show)
self._editor._tools_menu.addAction(self._action_show)
self._createGui()
self._enabled = True
def disable(self):
""" plugin method """
if self._enabled is False:
return
self._container.setDocked(False)
self._container.hide()
self._editor._tools_menu.removeAction(self._action_show)
self._enabled = False
def isEnabled(self):
""" plugin method """
return self._enabled;
def getName(self):
""" plugin method """
return "Camera Editor"
def toggle(self):
""" Toggles the cameratool visible / invisible and sets
dock status
"""
if self._container.isVisible() or self._container.isDocked():
self._container.setDocked(False)
self._container.hide()
self._action_show.setChecked(False)
else:
self._container.show()
self.loadSettings()
self._action_show.setChecked(True)
self._adjustPosition()
def saveSettings(self):
engine = self._editor.getEngine()
id = self._container.collectData('idBox')
if id == '':
print 'Please enter a camera id.'
return
try:
map = engine.getModel().getMap(str(self._container.collectData('mapBox')))
except fife.Exception:
print 'Cannot find the specified map id.'
return
try:
layer = map.getLayer(str(self._container.collectData('layerBox')))
except fife.Exception:
print 'Cannot find the specified layer id.'
return
try:
vals = self._container.collectData('viewBox').split(',')
if len(vals) != 4:
raise ValueError
viewport = fife.Rect(*[int(c) for c in vals])
except ValueError:
print 'Please enter 4 comma (,) delimited values for viewport x,y,width,height.'
return
#.........这里部分代码省略.........
示例14: HistoryManager
class HistoryManager(plugin.Plugin):
def __init__(self):
self.editor = None
self.engine = None
self._enabled = False
self.undomanager = None
def enable(self):
if self._enabled is True:
return
self.editor = scripts.editor.getEditor()
self.engine = self.editor.getEngine()
self._show_action = Action(u"History manager", checkable=True)
self._undo_action = Action(u"Undo", "gui/icons/undo.png")
self._redo_action = Action(u"Redo", "gui/icons/redo.png")
self._next_action = Action(u"Next branch", "gui/icons/next_branch.png")
self._prev_action = Action(u"Previous branch", "gui/icons/previous_branch.png")
self._show_action.helptext = u"Toggle HistoryManager"
self._undo_action.helptext = u"Undo action (CTRL+Z)"
self._redo_action.helptext = u"Redo action (CTRL+SHIFT+Z)"
self._next_action.helptext = u"Next branch (CTRL+ALT+Z"
self._prev_action.helptext = u"Previous branch (CTRL+ALT+SHIFT+Z)"
scripts.gui.action.activated.connect(self.toggle, sender=self._show_action)
scripts.gui.action.activated.connect(self._undo, sender=self._undo_action)
scripts.gui.action.activated.connect(self._redo, sender=self._redo_action)
scripts.gui.action.activated.connect(self._next, sender=self._next_action)
scripts.gui.action.activated.connect(self._prev, sender=self._prev_action)
self._undo_group = ActionGroup(name=u"UndoGroup")
self._undo_group.addAction(self._undo_action)
self._undo_group.addAction(self._redo_action)
self._undo_group.addAction(self._next_action)
self._undo_group.addAction(self._prev_action)
self.editor._tools_menu.addAction(self._show_action)
self.editor._edit_menu.insertAction(self._undo_group, 0)
self.editor._edit_menu.insertSeparator(position=1)
events.postMapShown.connect(self.update)
undomanager.changed.connect(self.update)
self.buildGui()
def disable(self):
if self._enabled is False:
return
self.gui.hide()
self.removeAllChildren()
events.postMapShown.disconnect(self.update)
undomanager.changed.disconnect(self.update)
scripts.gui.action.activated.connect(self.toggle, sender=self._show_action)
scripts.gui.action.activated.disconnect(self._undo, sender=self._undo_action)
scripts.gui.action.activated.disconnect(self._redo, sender=self._redo_action)
scripts.gui.action.activated.disconnect(self._next, sender=self._next_action)
scripts.gui.action.activated.disconnect(self._prev, sender=self._prev_action)
self.editor._tools_menu.removeAction(self._show_action)
self.editor._tools_menu.removeAction(self._undo_group)
def isEnabled(self):
return self._enabled;
def getName(self):
return "History manager"
def buildGui(self):
self.gui = Panel(title=u"History")
self.scrollarea = widgets.ScrollArea(min_size=(200,300))
self.list = widgets.ListBox()
self.list.capture(self._itemSelected)
self.gui.addChild(self.scrollarea)
self.scrollarea.addChild(self.list)
self.gui.position_technique = "right:center"
def _linearUndo(self, target):
mapview = self.editor.getActiveMapView()
if mapview is None:
return
undomanager = mapview.getController().getUndoManager()
current_item = undomanager.current_item
# Redo?
item = current_item
count = 0
while item is not None:
if item == target:
undomanager.redo(count)
#.........这里部分代码省略.........
示例15: LayerTool
class LayerTool(plugin.Plugin):
""" The B{LayerTool} allows to select and show / hide layers of a loaded
map as well as creating new layers or edit layer properties
"""
# default should be pychan default, highlight can be choosen (format: r,g,b)
DEFAULT_BACKGROUND_COLOR = pychan.internal.DEFAULT_STYLE['default']['base_color']
HIGHLIGHT_BACKGROUND_COLOR = pychan.internal.DEFAULT_STYLE['default']['selection_color']
# the dynamicly created widgets have the name scheme prefix + layerid
LABEL_NAME_PREFIX = "select_"
def __init__(self):
super(LayerTool, self).__init__()
# Editor instance
self._editor = scripts.editor.getEditor()
# Plugin variables
self._enabled = False
# Current mapview
self._mapview = None
# Toolbar button to display LayerTool
self._action_show = None
# GUI
self._layer_wizard = None
self.container = None
self.wrapper = None
self.remove_layer_button = None
self.create_layer_button = None
self.edit_layer_button = None
self.default_settings = _PLUGIN_SETTINGS
self.eds = self._editor._settings
self.update_settings()
#--- Plugin functions ---#
def enable(self):
""" Enable plugin """
if self._enabled: return
# Fifedit plugin data
self._action_show = Action(u"LayerTool", checkable=True)
scripts.gui.action.activated.connect(self.toggle, sender=self._action_show)
self._editor._tools_menu.addAction(self._action_show)
self.create()
self.toggle()
events.postMapShown.connect(self.update)
events.preMapClosed.connect(self._mapClosed)
if self.settings['docked']:
self._editor.dockWidgetTo(self.container, self.settings['dockarea'])
def disable(self):
""" Disable plugin """
if not self._enabled: return
self.container.setDocked(False)
self.container.hide()
events.postMapShown.disconnect(self.update)
events.preMapClosed.disconnect(self._mapClosed)
self._editor._tools_menu.removeAction(self._action_show)
def isEnabled(self):
""" Returns True if plugin is enabled """
return self._enabled;
def getName(self):
""" Return plugin name """
return u"Layertool"
#--- End plugin functions ---#
def _mapClosed(self):
self.update(mapview=None)
def showLayerWizard(self):
""" Show layer wizard """
if not self._mapview: return
if self._layer_wizard: self._layer_wizard._widget.hide()
self._layer_wizard = LayerDialog(self._editor.getEngine(), self._mapview.getMap(), callback=self._layerCreated)
def showEditDialog(self):
""" Show layerdialog for active layer """
if not self._mapview: return
layer = self.getActiveLayer()
if not layer: return
if self._layer_wizard: self._layer_wizard._widget.hide()
self._layer_wizard = LayerDialog(self._editor.getEngine(), self._mapview.getMap(), layer=layer, callback=cbwa(self.update, self._mapview))
def clear(self):
""" Remove all subwrappers """
#.........这里部分代码省略.........