spyder.api.editor#
This module contains the code editor API.
- class spyder.api.editor.EditorExtension[source]#
Bases:
objectBase class for editor extensions.
An extension is a “thing” that can be installed on an editor to add new behaviours or to modify its appearance.
A panel (model child class) is added to an editor by using PanelsManager,
spyder.plugins.editor.widgets.codeeditor.CodeEditor.panels.append().Subclasses may/should override the following methods:
spyder.api.EditorExtension.on_install()spyder.api.EditorExtension.on_uninstall()spyder.api.EditorExtension.on_state_changed()
..warning: The editor extension will be identified by its class name, this means that there cannot be two editor extensions of the same type on the same editor instance!
- clone_settings(original)[source]#
Clone the settings from another editor extension (same class).
This method is called when splitting an editor widget. # TODO at the current estate this is not working
- Parameters:
original – other editor extension (must be the same class).
Note
The base method does not do anything, you must implement this method for every new editor extension/panel (if you plan on using the split feature). You should also make sure any properties will be propagated to the clones.
- property editor#
Returns a reference to the parent code editor widget.
READ ONLY
- Return type:
spyder.plugins.editor.widgets.codeeditor.CodeEditor
- property enabled#
Tells if the editor extension is enabled.
spyder.api.EditorExtension.on_state_changed()will be called as soon as the editor extension state changed.- Type:
- on_install(editor)[source]#
Installs the extension on the editor.
- Parameters:
editor (spyder.plugins.editor.widgets.codeeditor.CodeEditor) – editor widget instance
Note
This method is called by editor when you install a EditorExtension. You should never call it yourself, even in a subclasss.
Warning
Don’t forget to call super when subclassing
- on_state_changed(state)[source]#
Called when the enable state has changed.
This method does not do anything, you may override it if you need to connect/disconnect to the editor’s signals (connect when state is true and disconnect when it is false).
- Parameters:
state (bool) – True = enabled, False = disabled
- class spyder.api.editor.Panel(dynamic=False)[source]#
Bases:
QWidget,EditorExtensionBase class for editor panels.
A panel is a editor extension and a QWidget.
Note
Use enabled to disable panel actions and setVisible to change the visibility of the panel.
- geometry()[source]#
Return geometry dimensions for floating Panels.
Note: If None is returned It’ll use editor contentsRect dimensions.
returns: x0, y0, height width.
- on_install(editor)[source]#
Extends
spyder.api.EditorExtension.on_install()method to set the editor instance as the parent widget.Warning
Don’t forget to call super if you override this method!
- Parameters:
editor (spyder.plugins.editor.widgets.codeeditor.CodeEditor) – editor instance
- paintEvent(event)[source]#
Fill the panel background using QPalette.
Notes
Please remember to extend this method in the child class to paint the panel’s desired information.
- property scrollable#
A scrollable panel will follow the editor’s scroll-bars.
Left and right panels follow the vertical scrollbar. Top and bottom panels follow the horizontal scrollbar.
- Type:
- setVisible(visible)[source]#
Shows/Hides the panel.
Automatically call PanelsManager.refresh_panels.
- Parameters:
visible – Visible state
- set_geometry(crect)[source]#
Set geometry for floating panels.
Normally you don’t need to override this method, you should override geometry instead.
- sizeHint()[source]#
Return the widget size hint, overriding the Qt method.
Notes
This size hint will define the QSize of the panel, i.e. it is where its width and height are defined.
If the size of your panel depends on displayed text, please use the LineNumberArea one as reference on how to implement this method.
If the size is not dependent on displayed text, please use the debugger panel as reference.
If your panel is in a floating position, please use the IndentationGuide one as reference.