nodedge.editor_window

Editor window module containing EditorWindow class.

class nodedge.editor_window.EditorWindow(parent: Optional[PySide2.QtWidgets.QWidget] = None)

Bases: PySide2.QtWidgets.QMainWindow

EditorWindow class

The editor window is the base of the multi document interface (MDI) MdiWindow.

The application can be opened with the EditorWindow as main window, even if it is not the main use case.

Instance Attributes

  • name_company - name of the company, used for permanent profile settings

  • name_product - name of this App, used for permanent profile settings

EditorWidgetClass

alias of nodedge.editor_widget.EditorWidget

property currentEditorWidget
Getter

Get current EditorWidget

Note

The EditorWindow has only one EditorWidget. This method is overridden by the MdiWindow which may have several EditorWidget.

Return type

Optional[editor_widget]

initUI() → None

Set up this QMainWindow.

Create EditorWidget, Actions and Menus

createStatusBar() → None

Create Status bar and connect to GraphicsView’s scenePosChanged event.

createActions() → None

Create basic File and Edit actions.

createMenus() → None

Create Menus for File and Edit.

createFileMenu()

Create File Menu.

createEditMenu()

Create Edit Menu.

createViewMenu() → None

Create view menu.

sizeHint() → PySide2.QtCore.QSize

Qt’s size hint handle. TODO: Investigate if we really need to overwrite this method.

Returns

None

updateTitle() → None

Update window title according to the name of the file currently opened.

onClipboardChanged() → None

Slot called when the clipboard has changed.

Returns

None

OnScenePosChanged(x: float, y: float)

Handle event when cursor position changed on the Scene. :param x: new cursor x position :type x: float :param y: new cursor y position :type y: float

newFile()

Open a clean new file in the window’s editor.

Confirmation is asked to the user if there are unsaved changes.

openFile(filename)

Open a file in the window’s editor from its filename.

Confirmation is asked to the user if there are unsaved changes.

Parameters

filename (str) – absolute path and filename of the file to open.

saveFile()

Save serialized JSON version of the currently opened file, in a JSON file based on the editor’s filename.

saveFileAs()

Save serialized JSON version of the currently opened file, allowing the user to choose the filename via a QFileDialog.

closeEvent(event: PySide2.QtGui.QCloseEvent) → None

Close the window.

Confirmation is asked to the user if there are unsaved changes.

quit() → None

Callback when the user decides to close the application.

Returns

None

undo() → None

Undo last operation.

redo() → None

Redo previously cancelled operation.

delete() → None

Delete selected items.

cut() → None

Cut to clipboard selected items.

copy() → None

Copy to clipboard selected items.

paste()

Paste from clipboard, creating items after deserialization.

static getFileDialogDirectory() → str

Returns starting directory for QFileDialog file open/save

Returns

starting directory for QFileDialog file open/save

Return type

str

static getFileDialogFilter()

Returns str standard file open/save filter for QFileDialog

Returns

standard file open/save filter for QFileDialog

Return type

str

maybeSave()

If current Scene is modified, ask a dialog to save the changes.

Returns

True if the action calling this method is allowed to continue. False if we should cancel operation.

Return type

bool

readSettings()

Read the permanent profile settings for this application.

writeSettings()

Write the permanent profile settings for this application.

beforeSaveFileAs(currentEditorWidget: nodedge.editor_widget.EditorWidget, filename: str) → None

Event triggered after choosing filename and before actual fileSave(). Current EditorWidget is passed because focus is lost after asking with QFileDialog and therefore getCurrentNodeEditorWidget will return None.

Parameters
onFitInView()
onGenerateCode()
createAction(name: str, callback: Callable, statusTip: Optional[str] = None, shortcut: Union[None, str, PySide2.QtGui.QKeySequence] = None) → PySide2.QtWidgets.QAction

Create an action for this window and add it to actions list.

Parameters
  • name (str) – action’s name

  • callback (Callable) – function to be called when the action is triggered

  • statusTip (Optional[str]) – Description of the action displayed at the bottom left of the EditorWindow.

  • shortcut (Optional[str]) – Keyboard shortcut to trigger the action.

Returns

staticMetaObject = <PySide2.QtCore.QMetaObject object>