orangewidget.workflow.drophandler

Drag/Drop handlers for handling drop events on the canvas.

This is used to create a widget node when a file is dragged onto the canvas.

To define a handler subclass a OWNodeFromMimeDataDropHandler or one of its subclasses (e.g SingleUrlDropHandler, SingleFileDropHandler, …) and register it with the target application’s entry point (the default is ‘orangecanvas.document.interactions.DropHandler’) in the project’s meta data, e.g.:

entry_points = {
    ...
    "orange.canvas.drophandler": [
        "The widget = fully.qualified.module:class_name",
        ...
    ],
    ...
class orangewidget.workflow.drophandler.OWNodeFromMimeDataDropHandler[source]

Bases: orangecanvas.document.interactions.NodeFromMimeDataDropHandler, abc.ABC

Canvas drop handler creating a OWBaseWidget nodes.

This implements a default qualifiedName() that is based on WIDGET class attribute.

WIDGET: Type[orangewidget.widget.OWBaseWidget] = None

Class attribute declaring which OWBaseWidget (sub)class this drop handler creates. Concrete subclasses must assign this attribute.

qualifiedName() str[source]

Reimplemented.

class orangewidget.workflow.drophandler.SingleUrlDropHandler[source]

Bases: orangewidget.workflow.drophandler.OWNodeFromMimeDataDropHandler

Canvas drop handler accepting a single url drop.

Subclasses must define canDropUrl() and parametersFromUrl()

Note

Use SingleFileDropHandler if you only care about local filesystem paths.

canDropMimeData(document: orangecanvas.document.schemeedit.SchemeEditWidget, data: PyQt5.QtCore.QMimeData) bool[source]

Reimplemented.

Delegate to canDropFile method if the data has a single local file system path.

parametersFromMimeData(document: orangecanvas.document.schemeedit.SchemeEditWidget, data: PyQt5.QtCore.QMimeData) Dict[str, Any][source]

Reimplemented.

Delegate to parametersFromUrl() method.

abstract canDropUrl(url: PyQt5.QtCore.QUrl) bool[source]

Can the handler create a node from the url.

Subclasses must redefine this method.

abstract parametersFromUrl(url: PyQt5.QtCore.QUrl) Dict[str, Any][source]

Return the node parameters from url.

Subclasses must redefine this method.

class orangewidget.workflow.drophandler.UrlsDropHandler[source]

Bases: orangewidget.workflow.drophandler.OWNodeFromMimeDataDropHandler

Canvas drop handler accepting url drops.

Subclasses must define canDropUrls() and parametersFromUrls()

Note

Use FilesDropHandler if you only care about local filesystem paths.

canDropMimeData(document: orangecanvas.document.schemeedit.SchemeEditWidget, data: PyQt5.QtCore.QMimeData) bool[source]

Reimplemented.

Delegate to canDropUrls() method.

parametersFromMimeData(document: orangecanvas.document.schemeedit.SchemeEditWidget, data: PyQt5.QtCore.QMimeData) Dict[str, Any][source]

Reimplemented.

Delegate to parametersFromUrls() method.

abstract canDropUrls(urls: Sequence[PyQt5.QtCore.QUrl]) bool[source]

Can the handler create a node from the urls list.

Subclasses must redefine this method.

abstract parametersFromUrls(urls: Sequence[PyQt5.QtCore.QUrl]) Dict[str, Any][source]

Return the node parameters from urls.

Subclasses must redefine this method.

class orangewidget.workflow.drophandler.SingleFileDropHandler[source]

Bases: orangewidget.workflow.drophandler.OWNodeFromMimeDataDropHandler

Canvas drop handler accepting single local file path.

Subclasses must define canDropFile() and parametersFromFile()

canDropMimeData(document: orangecanvas.document.schemeedit.SchemeEditWidget, data: PyQt5.QtCore.QMimeData) bool[source]

Reimplemented.

Delegate to canDropFile() method if the data has a single local file system path.

parametersFromMimeData(document: orangecanvas.document.schemeedit.SchemeEditWidget, data: PyQt5.QtCore.QMimeData) Dict[str, Any][source]

Reimplemented.

Delegate to parametersFromFile() method.

abstract canDropFile(path: str) bool[source]

Can the handler create a node from the file path.

Subclasses must redefine this method.

abstract parametersFromFile(path: str) Dict[str, Any][source]

Return the node parameters based on file path.

Subclasses must redefine this method.

class orangewidget.workflow.drophandler.FilesDropHandler[source]

Bases: orangewidget.workflow.drophandler.OWNodeFromMimeDataDropHandler

Canvas drop handler accepting local file paths.

Subclasses must define canDropFiles() and parametersFromFiles()

canDropMimeData(document: orangecanvas.document.schemeedit.SchemeEditWidget, data: PyQt5.QtCore.QMimeData) bool[source]

Reimplemented.

Delegate to canDropFiles() method if the data has only local filesystem paths.

parametersFromMimeData(document: orangecanvas.document.schemeedit.SchemeEditWidget, data: PyQt5.QtCore.QMimeData) Dict[str, Any][source]

Reimplemented.

Delegate to parametersFromFile() method.

abstract canDropFiles(paths: Sequence[str]) bool[source]

Can the handler create a node from the paths.

Subclasses must redefine this method.

abstract parametersFromFiles(paths: Sequence[str]) Dict[str, Any][source]

Return the node parameters based on paths.

Subclasses must redefine this method.