Skip to content

Commit

Permalink
no longer use argv in plugins since it's accessible from sys anyway
Browse files Browse the repository at this point in the history
  • Loading branch information
sezelt committed Jan 7, 2025
1 parent 1ef18ec commit 2d9b444
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
9 changes: 3 additions & 6 deletions PLUGINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ class ExamplePlugin:
uses_plugin_menu = False
display_name = "Example Plugin"

def __init__(self, parent, argv, *args, **kwargs):
def __init__(self, parent, *args, **kwargs):
self.parent = parent

if "--do-stuff" in argv:
pass

def close(self):
pass # perform any shutdown activities

Expand All @@ -33,9 +30,9 @@ class ExamplePlugin:

On loading the class is initialized using
```python
ExamplePlugin(parent=self, argv=argv)
ExamplePlugin(parent=self, [...])
```
where `self` is the `DataViewer` instance (the main window object) and argv is the list of command line arguments passed on launch.
where `self` is the `DataViewer` instance (the main window object)

The current implementation of the plugin interface is thus extremely simple: the plugin object gets a reference to the main window, and can in theory do whatever artitrarily stupid things it wants with it, and there are no guarantees on compatibility between different versions of the browser and plugins. Swift solves this using the API Broker, which interposes all actions taken by the plugin. While we may adopt such an interface in version 2.0, for now we simply have the following design guidelines that should ensure compatibility:

Expand Down
12 changes: 4 additions & 8 deletions src/py4D_browser/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def load_plugins(self, argv):
and should define a class with the `plugin_id` attribute
On loading the class is initialized using
ExamplePlugin(parent=self, argv=argv)
ExamplePlugin(parent=self)
with additional arguments potentially passed as kwargs
"""
Expand All @@ -43,9 +44,7 @@ def load_plugins(self, argv):
)
if plugin_menu:
self.processing_menu.addMenu(plugin_menu)
self.loaded_plugins.append(
member(parent=self, argv=argv, plugin_menu=plugin_menu)
)
self.loaded_plugins.append(member(parent=self, plugin_menu=plugin_menu))


def unload_plugins(self):
Expand All @@ -67,11 +66,8 @@ class ExamplePlugin:
uses_plugin_menu = False
display_name = "Example Plugin"

def __init__(self, parent, argv, *args, **kwargs):
def __init__(self, parent, *args, **kwargs):
self.parent = parent

if "--do-stuff" in argv:
pass

def close(self):
pass # perform any shutdown activities

0 comments on commit 2d9b444

Please sign in to comment.