Skip to content

Conversation

@joshanne
Copy link
Contributor

@joshanne joshanne commented Nov 28, 2025

I've been using a modified version of this for some time now.

It borrows from the idea that a user could extend the interface to provide their own functionality.

The most basic of plugin modules looks like so:

import dronecan
from PyQt5.QtWidgets import QVBoxLayout, QWidget, QLabel, QDialog, QPlainTextEdit
from PyQt5.QtCore import Qt
from logging import getLogger

__all__ = 'PANEL_NAME', 'spawn', 'get_icon'

PANEL_NAME = 'Custom Panel'

logger = getLogger(__name__)

_singleton = None

class CustomPanel(QDialog):
    def __init__(self, parent, node):
        super(CustomPanel, self).__init__(parent)
        self.setWindowTitle('My Custom Panel')
        self.setAttribute(Qt.WA_DeleteOnClose)

        self._node = node

        layout = QVBoxLayout(self)
        layout.addWidget(QLabel('This is a label!', self))
        self.setLayout(layout)

    def closeEvent(self, event):
        global _singleton
        _singleton = None
        super(CustomPanel, self).closeEvent(event)

def spawn(parent, node):
    global _singleton
    if _singleton is None:
        _singleton = CustomPanel(parent, node)

    _singleton.show()
    _singleton.raise_()
    _singleton.activateWindow()

    return _singleton

def get_icon():
    return None

These modules can then be distributed as wheels and loaded by the user when required.

@joshanne joshanne force-pushed the pr/add-plugin-support branch from 8d7de29 to 7d7cade Compare December 11, 2025 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant