Skip to content

Commit

Permalink
Update custom_extension_template.py
Browse files Browse the repository at this point in the history
  • Loading branch information
seb5g committed Jun 20, 2024
1 parent 3773532 commit 8c0a159
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from qtpy import QtWidgets

from pymodaq.utils import gui_utils as gutils
from pymodaq.utils.config import Config, get_set_preset_path
from pymodaq.utils.config import Config, get_set_preset_path, ConfigError
from pymodaq.utils.logger import set_logger, get_module_name

# todo: replace here *pymodaq_plugins_template* by your plugin package name
Expand Down Expand Up @@ -116,15 +116,20 @@ def value_changed(self, param):
def main():
from pymodaq.utils.gui_utils.utils import mkQApp
from pymodaq.utils.gui_utils.loader_utils import load_dashboard_with_preset

from pymodaq.utils.messenger import messagebox

app = mkQApp(EXTENSION_NAME)
preset_file_name = plugin_config('presets', f'preset_for_{EXTENSION_NAME}')

load_dashboard_with_preset(preset_file_name, EXTENSION_NAME)

app.exec()

try:
preset_file_name = plugin_config('presets', f'preset_for_{EXTENSION_NAME}')
load_dashboard_with_preset(preset_file_name, EXTENSION_NAME)
app.exec()

except ConfigError as e:
messagebox(f'No entry with name f"preset_for_{EXTENSION_NAME}" has been configured'
f'in the plugin config file. The toml entry should be:\n'
f'[presets]'
f"preset_for_{EXTENSION_NAME} = {'a name for an existing preset'}"
)

if __name__ == '__main__':
main()

0 comments on commit 8c0a159

Please sign in to comment.