lightfall 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lightfall/__init__.py +8 -0
- lightfall/__main__.py +10 -0
- lightfall/_version.py +24 -0
- lightfall/acquire/__init__.py +74 -0
- lightfall/acquire/buffer.py +363 -0
- lightfall/acquire/device_wrapper.py +416 -0
- lightfall/acquire/engine/__init__.py +155 -0
- lightfall/acquire/engine/base.py +587 -0
- lightfall/acquire/engine/bluesky.py +358 -0
- lightfall/acquire/engine/mock.py +165 -0
- lightfall/acquire/engine/plugins/__init__.py +9 -0
- lightfall/acquire/engine/plugins/bluesky_plugin.py +56 -0
- lightfall/acquire/engine/plugins/mock_plugin.py +55 -0
- lightfall/acquire/engine/protocol.py +145 -0
- lightfall/acquire/engine/registry.py +152 -0
- lightfall/acquire/engine/state.py +32 -0
- lightfall/acquire/engine/waiting_hook.py +225 -0
- lightfall/acquire/nats_bridge.py +62 -0
- lightfall/acquire/plan_ui.py +78 -0
- lightfall/acquire/plans/__init__.py +38 -0
- lightfall/acquire/plans/adaptive.py +288 -0
- lightfall/acquire/plans/example_plans.py +995 -0
- lightfall/acquire/plans/lightfall_plans.py +587 -0
- lightfall/acquire/plans/registry.py +543 -0
- lightfall/acquire/plans/standard_plans.py +186 -0
- lightfall/acquire/plans/user_plans.py +470 -0
- lightfall/acquire/runengine.py +36 -0
- lightfall/acquire/signals.py +452 -0
- lightfall/acquire/triggers/__init__.py +16 -0
- lightfall/acquire/triggers/base.py +25 -0
- lightfall/acquire/triggers/filter.py +37 -0
- lightfall/acquire/triggers/manager.py +73 -0
- lightfall/acquire/triggers/manual.py +36 -0
- lightfall/acquire/triggers/run_end.py +74 -0
- lightfall/acquire/triggers/run_start.py +52 -0
- lightfall/auth/__init__.py +38 -0
- lightfall/auth/policy.py +518 -0
- lightfall/auth/providers/__init__.py +30 -0
- lightfall/auth/providers/base.py +124 -0
- lightfall/auth/providers/keycloak.py +1017 -0
- lightfall/auth/providers/local.py +319 -0
- lightfall/auth/providers/pam.py +250 -0
- lightfall/auth/service_key.py +173 -0
- lightfall/auth/service_key_auth.py +79 -0
- lightfall/auth/session.py +656 -0
- lightfall/claude/__init__.py +52 -0
- lightfall/claude/_internal/__init__.py +1 -0
- lightfall/claude/_internal/serialization.py +195 -0
- lightfall/claude/_internal/threading.py +61 -0
- lightfall/claude/_internal/worker.py +757 -0
- lightfall/claude/_session_assembly.py +124 -0
- lightfall/claude/agent.py +596 -0
- lightfall/claude/lightfall_core_tools.py +410 -0
- lightfall/claude/markdown.py +103 -0
- lightfall/claude/permission_manager.py +588 -0
- lightfall/claude/tools/__init__.py +45 -0
- lightfall/claude/tools/controller.py +143 -0
- lightfall/claude/tools/interaction.py +177 -0
- lightfall/claude/tools/introspection.py +127 -0
- lightfall/claude/tools/logs.py +155 -0
- lightfall/claude/tools/screenshot.py +87 -0
- lightfall/claude/widget.py +851 -0
- lightfall/claude/widgets/__init__.py +5 -0
- lightfall/claude/widgets/permission_request.py +282 -0
- lightfall/claude/widgets/question_request.py +227 -0
- lightfall/claude/widgets/task_card.py +223 -0
- lightfall/config/__init__.py +23 -0
- lightfall/config/layers.py +317 -0
- lightfall/config/manager.py +244 -0
- lightfall/config/schema.py +154 -0
- lightfall/core/__init__.py +23 -0
- lightfall/core/application.py +727 -0
- lightfall/core/services.py +235 -0
- lightfall/devices/__init__.py +53 -0
- lightfall/devices/backends/__init__.py +17 -0
- lightfall/devices/backends/bcs.py +448 -0
- lightfall/devices/backends/happi.py +986 -0
- lightfall/devices/backends/mock.py +646 -0
- lightfall/devices/base.py +338 -0
- lightfall/devices/catalog.py +1039 -0
- lightfall/devices/connection_manager.py +676 -0
- lightfall/devices/model.py +290 -0
- lightfall/devices/monitoring.py +442 -0
- lightfall/devices/sim/__init__.py +26 -0
- lightfall/devices/sim/areadetector.py +436 -0
- lightfall/devices/sim/generators.py +223 -0
- lightfall/devices/sim/plugins.py +116 -0
- lightfall/epics/__init__.py +28 -0
- lightfall/epics/ca/__init__.py +10 -0
- lightfall/epics/ca/context.py +100 -0
- lightfall/epics/ca/pv.py +303 -0
- lightfall/epics/widgets/__init__.py +49 -0
- lightfall/epics/widgets/areadetector/__init__.py +16 -0
- lightfall/epics/widgets/areadetector/areadetector.py +281 -0
- lightfall/epics/widgets/areadetector/controls.py +478 -0
- lightfall/epics/widgets/areadetector/image_view.py +447 -0
- lightfall/epics/widgets/auto.py +319 -0
- lightfall/epics/widgets/base.py +404 -0
- lightfall/epics/widgets/checkbox.py +239 -0
- lightfall/epics/widgets/combobox.py +202 -0
- lightfall/epics/widgets/label.py +176 -0
- lightfall/epics/widgets/lineedit.py +253 -0
- lightfall/epics/widgets/motor.py +694 -0
- lightfall/epics/widgets/ophyd_base.py +469 -0
- lightfall/epics/widgets/ophyd_combobox.py +86 -0
- lightfall/epics/widgets/ophyd_label.py +54 -0
- lightfall/epics/widgets/ophyd_lineedit.py +170 -0
- lightfall/epics/widgets/ophyd_spinbox.py +79 -0
- lightfall/epics/widgets/slider.py +272 -0
- lightfall/epics/widgets/status_indicator.py +98 -0
- lightfall/epics/widgets/style.py +188 -0
- lightfall/exporter/__init__.py +1 -0
- lightfall/exporter/cli.py +67 -0
- lightfall/exporter/converters/__init__.py +26 -0
- lightfall/exporter/converters/base.py +39 -0
- lightfall/exporter/converters/noop.py +39 -0
- lightfall/exporter/converters/nxsas.py +73 -0
- lightfall/exporter/service.py +200 -0
- lightfall/exporter/tiled_utils.py +92 -0
- lightfall/ipc/__init__.py +6 -0
- lightfall/ipc/service.py +701 -0
- lightfall/ipc/trust.py +144 -0
- lightfall/logbook/__init__.py +46 -0
- lightfall/logbook/action_dialog.py +207 -0
- lightfall/logbook/action_logger.py +432 -0
- lightfall/logbook/block_mapper.py +562 -0
- lightfall/logbook/client.py +799 -0
- lightfall/logbook/converter.py +273 -0
- lightfall/logbook/editors/__init__.py +19 -0
- lightfall/logbook/editors/highlighter.py +305 -0
- lightfall/logbook/editors/markdown_editor.py +319 -0
- lightfall/logbook/editors/richtext_editor.py +1397 -0
- lightfall/logbook/entry_widget.py +1065 -0
- lightfall/logbook/event_listener.py +221 -0
- lightfall/logbook/fragment_widgets.py +925 -0
- lightfall/logbook/position_mapper.py +320 -0
- lightfall/logbook/protection.py +402 -0
- lightfall/logbook/style.py +394 -0
- lightfall/logbook/url.py +29 -0
- lightfall/logbook/visual_protection.py +330 -0
- lightfall/logbook/widget.py +680 -0
- lightfall/main.py +1091 -0
- lightfall/pipelines/__init__.py +4 -0
- lightfall/pipelines/client.py +148 -0
- lightfall/plugins/__init__.py +119 -0
- lightfall/plugins/agent_plugin.py +106 -0
- lightfall/plugins/agents/__init__.py +10 -0
- lightfall/plugins/agents/_mcp_helpers.py +52 -0
- lightfall/plugins/agents/alignment.py +94 -0
- lightfall/plugins/agents/autonomous_experiment/__init__.py +12 -0
- lightfall/plugins/agents/autonomous_experiment/nats_tools.py +210 -0
- lightfall/plugins/agents/autonomous_experiment/plugin.py +60 -0
- lightfall/plugins/agents/autonomous_experiment/prompts.py +164 -0
- lightfall/plugins/agents/current_esaf.py +435 -0
- lightfall/plugins/agents/device_tools.py +1043 -0
- lightfall/plugins/agents/engine_tools.py +720 -0
- lightfall/plugins/agents/ipython_tools.py +444 -0
- lightfall/plugins/agents/panel_builder.py +637 -0
- lightfall/plugins/agents/panel_design/references/cross_panel_patterns.md +95 -0
- lightfall/plugins/agents/panel_design/references/panel_design.md +680 -0
- lightfall/plugins/agents/panel_design.py +94 -0
- lightfall/plugins/agents/plan_design/references/plan_design.md +398 -0
- lightfall/plugins/agents/plan_design.py +90 -0
- lightfall/plugins/agents/plan_tools.py +878 -0
- lightfall/plugins/agents/scan_planning.py +101 -0
- lightfall/plugins/builtin_manifest.py +348 -0
- lightfall/plugins/controller_plugin.py +162 -0
- lightfall/plugins/engine_plugin.py +124 -0
- lightfall/plugins/errors.py +104 -0
- lightfall/plugins/info.py +112 -0
- lightfall/plugins/loader.py +878 -0
- lightfall/plugins/manifest.py +150 -0
- lightfall/plugins/panel_plugin.py +119 -0
- lightfall/plugins/plan_plugin.py +163 -0
- lightfall/plugins/registry.py +309 -0
- lightfall/plugins/settings_plugin.py +226 -0
- lightfall/plugins/statusbar_plugin.py +289 -0
- lightfall/plugins/theme_plugin.py +165 -0
- lightfall/plugins/types.py +136 -0
- lightfall/plugins/user_plugins.py +764 -0
- lightfall/project/__init__.py +37 -0
- lightfall/project/model.py +375 -0
- lightfall/project/service.py +427 -0
- lightfall/project/welcome.py +106 -0
- lightfall/resources/__init__.py +126 -0
- lightfall/resources/images/__init__.py +1 -0
- lightfall/resources/images/icon.ico +0 -0
- lightfall/resources/images/icon.png +0 -0
- lightfall/resources/images/logo.png +0 -0
- lightfall/services/__init__.py +33 -0
- lightfall/services/_alshub_client.py +73 -0
- lightfall/services/access_stamper.py +240 -0
- lightfall/services/als_beam_status.py +347 -0
- lightfall/services/ca_tunnel.py +325 -0
- lightfall/services/threaded_tiled_writer.py +174 -0
- lightfall/services/tiled_auth.py +21 -0
- lightfall/services/tiled_service.py +971 -0
- lightfall/services/tiled_writer_patch.py +301 -0
- lightfall/settings/__init__.py +1 -0
- lightfall/settings/image_helpers.py +30 -0
- lightfall/settings/user_settings_client.py +232 -0
- lightfall/ui/__init__.py +28 -0
- lightfall/ui/annotations.py +208 -0
- lightfall/ui/common/__init__.py +7 -0
- lightfall/ui/dialogs/__init__.py +26 -0
- lightfall/ui/dialogs/about_dialog.py +131 -0
- lightfall/ui/dialogs/add_trigger_dialog.py +152 -0
- lightfall/ui/dialogs/base.py +44 -0
- lightfall/ui/dialogs/bug_report_dialog.py +353 -0
- lightfall/ui/dialogs/create_plan_dialog.py +189 -0
- lightfall/ui/dialogs/device_edit_dialog.py +183 -0
- lightfall/ui/dialogs/export_dialog.py +565 -0
- lightfall/ui/dialogs/go_to_position_dialog.py +192 -0
- lightfall/ui/dialogs/login_dialog.py +756 -0
- lightfall/ui/dialogs/oauth_browser_dialog.py +305 -0
- lightfall/ui/dialogs/run_pipeline_dialog.py +131 -0
- lightfall/ui/dialogs/sample_metadata_dialog.py +316 -0
- lightfall/ui/docking/__init__.py +22 -0
- lightfall/ui/docking/icon_sidebar.py +806 -0
- lightfall/ui/docking/manager.py +682 -0
- lightfall/ui/docking/state.py +113 -0
- lightfall/ui/docking/theme.py +399 -0
- lightfall/ui/docking/widget.py +214 -0
- lightfall/ui/events.py +75 -0
- lightfall/ui/mainwindow.py +1006 -0
- lightfall/ui/models/__init__.py +49 -0
- lightfall/ui/models/device_selection.py +389 -0
- lightfall/ui/models/device_tree.py +1095 -0
- lightfall/ui/models/thread_model.py +667 -0
- lightfall/ui/models/tiled_model.py +384 -0
- lightfall/ui/panels/__init__.py +28 -0
- lightfall/ui/panels/base.py +525 -0
- lightfall/ui/panels/bluesky_panel.py +619 -0
- lightfall/ui/panels/claude/__init__.py +9 -0
- lightfall/ui/panels/claude/agent_registry.py +168 -0
- lightfall/ui/panels/claude_panel.py +887 -0
- lightfall/ui/panels/device_panel.py +370 -0
- lightfall/ui/panels/documents_panel.py +166 -0
- lightfall/ui/panels/ipython_panel.py +580 -0
- lightfall/ui/panels/logbook_entries_panel.py +84 -0
- lightfall/ui/panels/logbook_panel.py +627 -0
- lightfall/ui/panels/logging_panel.py +587 -0
- lightfall/ui/panels/pipeline_jobs_panel.py +160 -0
- lightfall/ui/panels/pipeline_triggers_panel.py +170 -0
- lightfall/ui/panels/plugins/__init__.py +34 -0
- lightfall/ui/panels/plugins/bluesky_plugin.py +27 -0
- lightfall/ui/panels/plugins/claude_plugin.py +29 -0
- lightfall/ui/panels/plugins/device_plugin.py +27 -0
- lightfall/ui/panels/plugins/documents_plugin.py +26 -0
- lightfall/ui/panels/plugins/ipython_plugin.py +27 -0
- lightfall/ui/panels/plugins/logbook_entries_plugin.py +23 -0
- lightfall/ui/panels/plugins/logbook_plugin.py +27 -0
- lightfall/ui/panels/plugins/logging_plugin.py +27 -0
- lightfall/ui/panels/plugins/pipeline_jobs_plugin.py +23 -0
- lightfall/ui/panels/plugins/pipeline_triggers_plugin.py +25 -0
- lightfall/ui/panels/plugins/queue_plugin.py +29 -0
- lightfall/ui/panels/plugins/synoptic_plugin.py +38 -0
- lightfall/ui/panels/plugins/threads_plugin.py +27 -0
- lightfall/ui/panels/plugins/tiled_browser_plugin.py +27 -0
- lightfall/ui/panels/plugins/visualization_plugin.py +27 -0
- lightfall/ui/panels/queue.py +754 -0
- lightfall/ui/panels/registry.py +483 -0
- lightfall/ui/panels/synoptic/__init__.py +27 -0
- lightfall/ui/panels/synoptic/editors.py +481 -0
- lightfall/ui/panels/synoptic/items.py +556 -0
- lightfall/ui/panels/synoptic/models.py +336 -0
- lightfall/ui/panels/synoptic/panel.py +889 -0
- lightfall/ui/panels/synoptic/serialization.py +300 -0
- lightfall/ui/panels/synoptic/view.py +504 -0
- lightfall/ui/panels/threads_panel.py +621 -0
- lightfall/ui/panels/tiled_browser_panel.py +854 -0
- lightfall/ui/panels/visualization_panel.py +508 -0
- lightfall/ui/preferences/__init__.py +24 -0
- lightfall/ui/preferences/backend.py +148 -0
- lightfall/ui/preferences/builtin.py +220 -0
- lightfall/ui/preferences/claude_settings.py +762 -0
- lightfall/ui/preferences/device_settings.py +461 -0
- lightfall/ui/preferences/dialog.py +234 -0
- lightfall/ui/preferences/editor_settings.py +227 -0
- lightfall/ui/preferences/ipc_settings.py +226 -0
- lightfall/ui/preferences/logbook_settings.py +232 -0
- lightfall/ui/preferences/login_settings.py +183 -0
- lightfall/ui/preferences/manager.py +562 -0
- lightfall/ui/preferences/plugin_settings.py +392 -0
- lightfall/ui/preferences/proxy_settings.py +561 -0
- lightfall/ui/preferences/skill_settings.py +28 -0
- lightfall/ui/preferences/tiled_settings.py +469 -0
- lightfall/ui/preferences/tool_settings.py +393 -0
- lightfall/ui/preferences/user_portable_backend.py +131 -0
- lightfall/ui/preferences/user_profile_settings.py +316 -0
- lightfall/ui/preferences/visualization_settings.py +159 -0
- lightfall/ui/resources/__init__.py +1 -0
- lightfall/ui/resources/logo.png +0 -0
- lightfall/ui/statusbar/__init__.py +11 -0
- lightfall/ui/statusbar/manager.py +379 -0
- lightfall/ui/statusbar/plugins/__init__.py +28 -0
- lightfall/ui/statusbar/plugins/als_beam_status.py +218 -0
- lightfall/ui/statusbar/plugins/auth_status.py +116 -0
- lightfall/ui/statusbar/plugins/connection_status.py +100 -0
- lightfall/ui/statusbar/plugins/thread_status.py +556 -0
- lightfall/ui/statusbar/plugins/tiled_status.py +179 -0
- lightfall/ui/statusbar/plugins/user_status.py +84 -0
- lightfall/ui/theater/__init__.py +28 -0
- lightfall/ui/theater/manager.py +124 -0
- lightfall/ui/theater/overlay.py +279 -0
- lightfall/ui/theater/proxy.py +111 -0
- lightfall/ui/theme/__init__.py +18 -0
- lightfall/ui/theme/builtin.py +1015 -0
- lightfall/ui/theme/manager.py +875 -0
- lightfall/ui/theme/registry.py +195 -0
- lightfall/ui/toast.py +221 -0
- lightfall/ui/tutorial.py +1100 -0
- lightfall/ui/widgets/__init__.py +110 -0
- lightfall/ui/widgets/base_control.py +259 -0
- lightfall/ui/widgets/camera/__init__.py +36 -0
- lightfall/ui/widgets/camera/base.py +815 -0
- lightfall/ui/widgets/camera/dark_frames.py +213 -0
- lightfall/ui/widgets/camera/image_view.py +649 -0
- lightfall/ui/widgets/camera/panels/__init__.py +14 -0
- lightfall/ui/widgets/camera/panels/cooler.py +320 -0
- lightfall/ui/widgets/camera/panels/temperature.py +192 -0
- lightfall/ui/widgets/camera/plan_based.py +202 -0
- lightfall/ui/widgets/compact_motor.py +522 -0
- lightfall/ui/widgets/controller_matcher.py +278 -0
- lightfall/ui/widgets/controller_registry.py +144 -0
- lightfall/ui/widgets/device_control.py +411 -0
- lightfall/ui/widgets/device_selector.py +438 -0
- lightfall/ui/widgets/device_tree_tab.py +461 -0
- lightfall/ui/widgets/document_stream.py +1028 -0
- lightfall/ui/widgets/favorites_tab.py +191 -0
- lightfall/ui/widgets/motor_control.py +1120 -0
- lightfall/ui/widgets/observers/__init__.py +8 -0
- lightfall/ui/widgets/observers/camera.py +48 -0
- lightfall/ui/widgets/observers/image_view.py +130 -0
- lightfall/ui/widgets/plan_config.py +954 -0
- lightfall/ui/widgets/plan_edit_dialog.py +294 -0
- lightfall/ui/widgets/plan_selector.py +452 -0
- lightfall/ui/widgets/profile_avatar.py +128 -0
- lightfall/ui/widgets/queue_view.py +647 -0
- lightfall/ui/widgets/runengine_control.py +549 -0
- lightfall/ui/widgets/signal_control.py +793 -0
- lightfall/ui/widgets/skill_trigger_button.py +183 -0
- lightfall/ui/widgets/tiled_filter_widget.py +314 -0
- lightfall/ui/widgets/tiled_status.py +149 -0
- lightfall/ui/widgets/warning_banner.py +185 -0
- lightfall/utils/__init__.py +53 -0
- lightfall/utils/crash_diagnostics.py +454 -0
- lightfall/utils/data_migration.py +22 -0
- lightfall/utils/editor_launcher.py +594 -0
- lightfall/utils/error_collector.py +245 -0
- lightfall/utils/git_tracker.py +197 -0
- lightfall/utils/log_buffer.py +233 -0
- lightfall/utils/logging.py +229 -0
- lightfall/utils/module_resolver.py +70 -0
- lightfall/utils/sentry.py +722 -0
- lightfall/utils/threads.py +991 -0
- lightfall/utils/tiled_helpers.py +96 -0
- lightfall/visualization/__init__.py +50 -0
- lightfall/visualization/base.py +5 -0
- lightfall/visualization/base_visualization.py +74 -0
- lightfall/visualization/fitting/__init__.py +24 -0
- lightfall/visualization/fitting/base.py +267 -0
- lightfall/visualization/fitting/fitters.py +325 -0
- lightfall/visualization/fitting/panel.py +265 -0
- lightfall/visualization/memory.py +392 -0
- lightfall/visualization/motor_mixin.py +524 -0
- lightfall/visualization/pg.py +156 -0
- lightfall/visualization/registry.py +144 -0
- lightfall/visualization/spec.py +79 -0
- lightfall/visualization/theme.py +266 -0
- lightfall/visualization/widgets/__init__.py +28 -0
- lightfall/visualization/widgets/adaptive/__init__.py +1 -0
- lightfall/visualization/widgets/adaptive/heatmap.py +655 -0
- lightfall/visualization/widgets/adaptive/plot.py +233 -0
- lightfall/visualization/widgets/heatmap.py +264 -0
- lightfall/visualization/widgets/image_stack.py +316 -0
- lightfall/visualization/widgets/image_view_toolbar.py +227 -0
- lightfall/visualization/widgets/lazy_image_view.py +590 -0
- lightfall/visualization/widgets/plot_1d.py +262 -0
- lightfall/visualization/widgets/scatter.py +247 -0
- lightfall/visualization/widgets/table.py +221 -0
- lightfall/visualization/widgets/time_axis.py +93 -0
- lightfall-0.1.1.dist-info/METADATA +223 -0
- lightfall-0.1.1.dist-info/RECORD +388 -0
- lightfall-0.1.1.dist-info/WHEEL +4 -0
- lightfall-0.1.1.dist-info/entry_points.txt +6 -0
- lightfall-0.1.1.dist-info/licenses/LEGAL.md +13 -0
- lightfall-0.1.1.dist-info/licenses/LICENSE.md +33 -0
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
# Lightfall Panel Design API Reference
|
|
2
|
+
|
|
3
|
+
This document provides the full API reference for designing BasePanel subclasses for the Lightfall application.
|
|
4
|
+
|
|
5
|
+
## see-also
|
|
6
|
+
|
|
7
|
+
- [`cross_panel_patterns.md`](cross_panel_patterns.md) — recipes for panels
|
|
8
|
+
that reach beyond their own widgets: dispatching prompts to the Claude
|
|
9
|
+
Assistant, opening other panels, and reacting to global events (device
|
|
10
|
+
connect, plan complete).
|
|
11
|
+
|
|
12
|
+
## Required Imports
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from typing import Any, ClassVar
|
|
18
|
+
|
|
19
|
+
from PySide6.QtCore import Signal, Qt
|
|
20
|
+
from PySide6.QtWidgets import (
|
|
21
|
+
QWidget, QVBoxLayout, QHBoxLayout,
|
|
22
|
+
QLabel, QPushButton, QLineEdit, QSpinBox, QDoubleSpinBox,
|
|
23
|
+
QComboBox, QCheckBox, QGroupBox, QTableWidget, QTableWidgetItem,
|
|
24
|
+
QSplitter, QScrollArea, QFrame, QSizePolicy,
|
|
25
|
+
)
|
|
26
|
+
from lightfall.ui.panels.base import BasePanel, PanelMetadata
|
|
27
|
+
from lightfall.ui.panels.registry import PanelRegistry
|
|
28
|
+
from lightfall.utils.logging import logger
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## user-plugin-architecture
|
|
32
|
+
|
|
33
|
+
Lightfall has two distinct ways to create panel plugins. Understanding which to use is critical.
|
|
34
|
+
|
|
35
|
+
### User Plugins (~/lightfall/plugins/)
|
|
36
|
+
|
|
37
|
+
**This is what YOU should use.** User plugins directly subclass `BasePanel`:
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from lightfall.ui.panels.base import BasePanel, PanelMetadata
|
|
41
|
+
from lightfall.ui.panels.registry import PanelRegistry
|
|
42
|
+
|
|
43
|
+
class MyPanel(BasePanel):
|
|
44
|
+
panel_metadata = PanelMetadata(id="lightfall.panels.user.my_panel", ...)
|
|
45
|
+
def _setup_ui(self) -> None: ...
|
|
46
|
+
|
|
47
|
+
# Self-register at module load time
|
|
48
|
+
PanelRegistry.get_instance().register(MyPanel, replace=True)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Key points:
|
|
52
|
+
- Direct `BasePanel` subclass
|
|
53
|
+
- Self-registers with `PanelRegistry.register()`
|
|
54
|
+
- Tracked by `UserPluginService` via `RegistrationTracker`
|
|
55
|
+
- Hot-reload supported
|
|
56
|
+
|
|
57
|
+
### Built-in Plugins (via manifest)
|
|
58
|
+
|
|
59
|
+
Built-in plugins use a **two-layer pattern** you should NOT copy:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
# File: lightfall/ui/panels/plugins/device_plugin.py
|
|
63
|
+
class DevicePanelPlugin(PanelPlugin): # <-- Plugin wrapper
|
|
64
|
+
def get_panel_class(self) -> type[BasePanel]:
|
|
65
|
+
from lightfall.ui.panels.device_panel import DevicePanel
|
|
66
|
+
return DevicePanel
|
|
67
|
+
|
|
68
|
+
# File: lightfall/ui/panels/device_panel.py
|
|
69
|
+
class DevicePanel(BasePanel): # <-- Actual panel
|
|
70
|
+
panel_metadata = PanelMetadata(...)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Why the two layers?
|
|
74
|
+
- **Lazy loading**: `PanelPlugin` is instantiated at startup, but the heavy `BasePanel` import is deferred until `get_panel_class()` is called
|
|
75
|
+
- **Plugin system integration**: `PanelPlugin` goes through `PluginLoader` → `PluginRegistry` → `PanelRegistry`
|
|
76
|
+
- **Qt independence**: The plugin system doesn't depend on Qt
|
|
77
|
+
|
|
78
|
+
### Do NOT Use PanelPlugin for User Plugins
|
|
79
|
+
|
|
80
|
+
❌ **Wrong** - Using PanelPlugin for user plugins:
|
|
81
|
+
```python
|
|
82
|
+
class MyPanelPlugin(PanelPlugin): # DON'T DO THIS
|
|
83
|
+
def get_panel_class(self):
|
|
84
|
+
return MyPanel
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
✅ **Correct** - Direct BasePanel with self-registration:
|
|
88
|
+
```python
|
|
89
|
+
class MyPanel(BasePanel): # DO THIS
|
|
90
|
+
panel_metadata = PanelMetadata(...)
|
|
91
|
+
|
|
92
|
+
PanelRegistry.get_instance().register(MyPanel, replace=True)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`PanelPlugin` is NOT tracked by `UserPluginService` and will NOT work correctly for user plugins.
|
|
96
|
+
|
|
97
|
+
## panel-metadata
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
@dataclass
|
|
101
|
+
class PanelMetadata:
|
|
102
|
+
id: str # Unique ID, e.g., "lightfall.panels.user.my_panel"
|
|
103
|
+
name: str # Display name in menus
|
|
104
|
+
description: str = "" # Tooltip/help text
|
|
105
|
+
icon: str = "" # Icon name (mdi.icon-name or path)
|
|
106
|
+
category: str = "General" # Menu grouping: "User", "Data", "Devices", etc.
|
|
107
|
+
required_permission: Permission | None = None # Access control (usually None)
|
|
108
|
+
singleton: bool = True # Only one instance allowed
|
|
109
|
+
closable: bool = True # User can close the panel
|
|
110
|
+
keywords: list[str] = field(default_factory=list) # Search keywords
|
|
111
|
+
|
|
112
|
+
# Docking preferences
|
|
113
|
+
default_area: str = "left" # "left" or "bottom" (gets sidebar button + title bar)
|
|
114
|
+
# "center" (always visible, no sidebar button)
|
|
115
|
+
sidebar_group: str = "top" # "top", "bottom" within sidebar
|
|
116
|
+
auto_hide: bool = True # Start in auto-hide sidebar
|
|
117
|
+
sidebar_order: int = 0 # Order within group (lower = higher)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## lifecycle-methods
|
|
121
|
+
|
|
122
|
+
### Required: `_setup_ui()`
|
|
123
|
+
|
|
124
|
+
Build your UI here. Called during `__init__` after layout is created.
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
def _setup_ui(self) -> None:
|
|
128
|
+
"""Build the panel's user interface."""
|
|
129
|
+
# self._layout is already a QVBoxLayout with no margins
|
|
130
|
+
self.label = QLabel("Hello!")
|
|
131
|
+
self._layout.addWidget(self.label)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Optional Hooks
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
def _on_activated(self) -> None:
|
|
138
|
+
"""Called when panel becomes active/focused."""
|
|
139
|
+
pass
|
|
140
|
+
|
|
141
|
+
def _on_deactivated(self) -> None:
|
|
142
|
+
"""Called when panel loses focus."""
|
|
143
|
+
pass
|
|
144
|
+
|
|
145
|
+
def _on_closing(self) -> None:
|
|
146
|
+
"""Called when panel is about to close."""
|
|
147
|
+
pass
|
|
148
|
+
|
|
149
|
+
def can_close(self, force: bool = False) -> bool:
|
|
150
|
+
"""Return False to prevent closing (e.g., unsaved work)."""
|
|
151
|
+
return True
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## signals
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
class BasePanel(QWidget):
|
|
158
|
+
activated = Signal() # Panel became active
|
|
159
|
+
deactivated = Signal() # Panel lost focus
|
|
160
|
+
state_changed = Signal(str, object) # key, value - state changed
|
|
161
|
+
closing = Signal() # Panel is closing
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## state-management
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
# Get/set panel state (survives restart if persisted)
|
|
168
|
+
value = self.get_state("key", default_value)
|
|
169
|
+
self.set_state("key", value)
|
|
170
|
+
|
|
171
|
+
# Get all state as dict
|
|
172
|
+
all_state = self.get_all_state()
|
|
173
|
+
|
|
174
|
+
# Restore from dict
|
|
175
|
+
self.restore_state(state_dict)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## mcp-introspection-api
|
|
179
|
+
|
|
180
|
+
Override these to expose panel-specific data and actions to Claude:
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
def _get_specific_introspection_data(self) -> dict[str, Any]:
|
|
184
|
+
"""Return panel-specific data for MCP tools."""
|
|
185
|
+
return {
|
|
186
|
+
"current_value": self._value,
|
|
187
|
+
"item_count": len(self._items),
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
def _get_available_actions(self) -> list[dict[str, Any]]:
|
|
191
|
+
"""Return actions Claude can invoke."""
|
|
192
|
+
actions = super()._get_available_actions()
|
|
193
|
+
actions.extend([
|
|
194
|
+
{
|
|
195
|
+
"name": "refresh",
|
|
196
|
+
"description": "Refresh the data",
|
|
197
|
+
"method": "action_refresh",
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"name": "set_filter",
|
|
201
|
+
"description": "Set the filter text",
|
|
202
|
+
"method": "action_set_filter",
|
|
203
|
+
"parameters": {"filter_text": "string"},
|
|
204
|
+
},
|
|
205
|
+
])
|
|
206
|
+
return actions
|
|
207
|
+
|
|
208
|
+
def action_refresh(self, **kwargs) -> bool:
|
|
209
|
+
"""Custom action handler for 'refresh'."""
|
|
210
|
+
self._load_data()
|
|
211
|
+
return True
|
|
212
|
+
|
|
213
|
+
def action_set_filter(self, filter_text: str = "", **kwargs) -> bool:
|
|
214
|
+
"""Custom action handler for 'set_filter'."""
|
|
215
|
+
self._filter_input.setText(filter_text)
|
|
216
|
+
return True
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### The `parameters` dict
|
|
220
|
+
|
|
221
|
+
The optional `"parameters"` entry declares the keyword arguments Claude may
|
|
222
|
+
pass when invoking the action. It is **advisory metadata**: it is surfaced to
|
|
223
|
+
Claude through `lightfall_get_panel_info` so the model knows the shape of the call,
|
|
224
|
+
but the framework does **not** validate it. At invoke time,
|
|
225
|
+
`lightfall_invoke_panel_action` passes a free-form `kwargs` object straight through
|
|
226
|
+
`BasePanel.invoke_action(action, **kwargs)` into your `action_<name>(**kwargs)`
|
|
227
|
+
method (see `ui/panels/base.py` and `claude/lightfall_core_tools.py`).
|
|
228
|
+
|
|
229
|
+
- **Keys** are parameter names. They arrive as keyword arguments to the
|
|
230
|
+
`action_*` method, so they must be valid Python identifiers.
|
|
231
|
+
- **Values** are JSON-Schema type strings — `"string"`, `"integer"`,
|
|
232
|
+
`"number"`, or `"boolean"`. For a constrained choice, use a nested object:
|
|
233
|
+
`{"type": "string", "enum": ["absolute", "relative"]}`.
|
|
234
|
+
- **Treat every declared parameter as required.** There is no "optional" flag,
|
|
235
|
+
and Claude will try to supply everything listed. To make a parameter
|
|
236
|
+
optional, give the method a default and *omit* it from the dict — undeclared
|
|
237
|
+
kwargs are still accepted because the handler is called with `**kwargs`.
|
|
238
|
+
|
|
239
|
+
```python
|
|
240
|
+
def _get_available_actions(self) -> list[dict[str, Any]]:
|
|
241
|
+
actions = super()._get_available_actions()
|
|
242
|
+
actions.append({
|
|
243
|
+
"name": "run_scan",
|
|
244
|
+
"description": "Start a scan over the named motor",
|
|
245
|
+
"method": "action_run_scan",
|
|
246
|
+
"parameters": {
|
|
247
|
+
"motor": "string",
|
|
248
|
+
"points": "integer",
|
|
249
|
+
"mode": {"type": "string", "enum": ["absolute", "relative"]},
|
|
250
|
+
},
|
|
251
|
+
})
|
|
252
|
+
return actions
|
|
253
|
+
|
|
254
|
+
def action_run_scan(
|
|
255
|
+
self, motor: str, points: int, mode: str = "absolute", **kwargs
|
|
256
|
+
) -> bool:
|
|
257
|
+
# `mode` is declared above, so Claude treats it as required. Drop it from
|
|
258
|
+
# `parameters` (keeping the default here) to make it truly optional.
|
|
259
|
+
...
|
|
260
|
+
return True
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## triggering-the-claude-assistant
|
|
264
|
+
|
|
265
|
+
Some panels want a button that drives an *AI-mediated* procedure — run a skill,
|
|
266
|
+
summarize the current state, draft a logbook note — rather than performing the
|
|
267
|
+
work themselves. The pattern is to dispatch a prompt to the singleton Claude
|
|
268
|
+
Assistant panel (`lightfall.panels.claude`), which then runs the relevant skill in
|
|
269
|
+
the chat the user can already see.
|
|
270
|
+
|
|
271
|
+
Use this when the action is open-ended or best handled by a skill (and when you
|
|
272
|
+
want the conversation visible to the operator). For deterministic, fully
|
|
273
|
+
specified operations, expose an MCP action (see `mcp-introspection-api`) or do
|
|
274
|
+
the work directly in the panel instead.
|
|
275
|
+
|
|
276
|
+
### Recommended: use `SkillTriggerButton`
|
|
277
|
+
|
|
278
|
+
`SkillTriggerButton` (`lightfall.ui.widgets.skill_trigger_button`) packages the
|
|
279
|
+
whole flow — get-or-open the Claude panel, guard on a busy agent, send the
|
|
280
|
+
prompt, report status — into one drop-in widget. It emits `dispatched(str)`
|
|
281
|
+
on success so you can chain follow-up behavior.
|
|
282
|
+
|
|
283
|
+
```python
|
|
284
|
+
from lightfall.ui.widgets.skill_trigger_button import SkillTriggerButton
|
|
285
|
+
|
|
286
|
+
btn = SkillTriggerButton(skill_name="Beam Alignment", prompt="Run the beam alignment skill.")
|
|
287
|
+
self._layout.addWidget(btn)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Manual pattern (for advanced cases)
|
|
291
|
+
|
|
292
|
+
When you need to collect Claude's reply (as `LogbookPanel` does) rather than
|
|
293
|
+
fire-and-forget, drive the bridge yourself. This mirrors
|
|
294
|
+
`LogbookPanel._get_claude_panel` / `_send_to_claude`:
|
|
295
|
+
|
|
296
|
+
```python
|
|
297
|
+
from lightfall.ui.panels.registry import PanelRegistry
|
|
298
|
+
|
|
299
|
+
registry = PanelRegistry.get_instance()
|
|
300
|
+
panel = registry.create("lightfall.panels.claude") # get-or-open the singleton
|
|
301
|
+
widget = getattr(panel, "_claude_widget", None)
|
|
302
|
+
if widget is None or not hasattr(widget, "agent"):
|
|
303
|
+
return
|
|
304
|
+
agent = widget.agent
|
|
305
|
+
if agent.is_busy(): # don't interrupt a running query
|
|
306
|
+
return
|
|
307
|
+
agent.message_received.connect(self._on_claude_message) # optional: collect reply
|
|
308
|
+
agent.query_completed.connect(self._on_claude_complete)
|
|
309
|
+
panel.action_send_message(prompt) # also shows in the chat UI
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Agent signals worth knowing:
|
|
313
|
+
|
|
314
|
+
- `is_busy() -> bool` — `True` while a query is queued or running. Always guard
|
|
315
|
+
on it before sending.
|
|
316
|
+
- `message_received(str)` — emitted per response chunk. Connect to accumulate
|
|
317
|
+
Claude's reply.
|
|
318
|
+
- `query_completed()` — emitted once when the query finishes. Disconnect your
|
|
319
|
+
handlers here (and clear any pending state).
|
|
320
|
+
|
|
321
|
+
> **Trigger-prompt phrasing.** When writing the prompt, include the target
|
|
322
|
+
> skill's name verbatim and at least one phrase from its "Use this skill
|
|
323
|
+
> when…" description in `SKILL.md`. This maximizes the match-rate over
|
|
324
|
+
> conversational rewordings.
|
|
325
|
+
|
|
326
|
+
> **Writing a skill that's easy to trigger from a panel.** If your skill is
|
|
327
|
+
> likely to be triggered from a panel button (not just a chat message), make
|
|
328
|
+
> it easy:
|
|
329
|
+
>
|
|
330
|
+
> - Write the "Use this skill when…" description so it contains a short,
|
|
331
|
+
> action-oriented phrase a panel can put verbatim in its trigger prompt.
|
|
332
|
+
> Bad: "Use when the operator needs help with X." Good: "Use when the user
|
|
333
|
+
> asks to run X, perform an X scan, or start an X procedure."
|
|
334
|
+
> - Avoid requiring information the panel can't supply. If the skill needs
|
|
335
|
+
> operator confirmation of a manual checklist, surface that as the skill's
|
|
336
|
+
> first interactive step (so the panel can fire-and-forget the prompt and
|
|
337
|
+
> let the skill handle the dialog).
|
|
338
|
+
|
|
339
|
+
## self-registration-pattern
|
|
340
|
+
|
|
341
|
+
User plugins MUST self-register at module load time:
|
|
342
|
+
|
|
343
|
+
```python
|
|
344
|
+
# At the END of your plugin file:
|
|
345
|
+
PanelRegistry.get_instance().register(MyPanel, replace=True)
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
The `replace=True` is REQUIRED for hot-reload support.
|
|
349
|
+
|
|
350
|
+
## complete-example
|
|
351
|
+
|
|
352
|
+
```python
|
|
353
|
+
"""My custom panel for Lightfall."""
|
|
354
|
+
from __future__ import annotations
|
|
355
|
+
|
|
356
|
+
from typing import Any
|
|
357
|
+
|
|
358
|
+
from PySide6.QtCore import Signal
|
|
359
|
+
from PySide6.QtWidgets import (
|
|
360
|
+
QLabel, QLineEdit, QPushButton, QVBoxLayout, QHBoxLayout, QWidget,
|
|
361
|
+
)
|
|
362
|
+
from lightfall.ui.panels.base import BasePanel, PanelMetadata
|
|
363
|
+
from lightfall.ui.panels.registry import PanelRegistry
|
|
364
|
+
from lightfall.utils.logging import logger
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
class MyCustomPanel(BasePanel):
|
|
368
|
+
"""A custom panel that shows a greeting."""
|
|
369
|
+
|
|
370
|
+
panel_metadata = PanelMetadata(
|
|
371
|
+
id="lightfall.panels.user.my_custom",
|
|
372
|
+
name="My Custom Panel",
|
|
373
|
+
description="A simple panel showing a personalized greeting",
|
|
374
|
+
icon="mdi.hand-wave",
|
|
375
|
+
category="User",
|
|
376
|
+
keywords=["greeting", "hello", "custom"],
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
# Custom signal
|
|
380
|
+
name_changed = Signal(str)
|
|
381
|
+
|
|
382
|
+
def _setup_ui(self) -> None:
|
|
383
|
+
"""Build the panel UI."""
|
|
384
|
+
# Name input row
|
|
385
|
+
input_row = QHBoxLayout()
|
|
386
|
+
input_row.addWidget(QLabel("Name:"))
|
|
387
|
+
self._name_input = QLineEdit()
|
|
388
|
+
self._name_input.setPlaceholderText("Enter your name")
|
|
389
|
+
self._name_input.textChanged.connect(self._update_greeting)
|
|
390
|
+
input_row.addWidget(self._name_input)
|
|
391
|
+
|
|
392
|
+
# Greet button
|
|
393
|
+
self._greet_btn = QPushButton("Greet")
|
|
394
|
+
self._greet_btn.clicked.connect(self._on_greet_clicked)
|
|
395
|
+
input_row.addWidget(self._greet_btn)
|
|
396
|
+
|
|
397
|
+
# Greeting label
|
|
398
|
+
self._greeting_label = QLabel("Hello!")
|
|
399
|
+
self._greeting_label.setStyleSheet("font-size: 18px; padding: 10px;")
|
|
400
|
+
|
|
401
|
+
# Add to layout
|
|
402
|
+
self._layout.addLayout(input_row)
|
|
403
|
+
self._layout.addWidget(self._greeting_label)
|
|
404
|
+
self._layout.addStretch()
|
|
405
|
+
|
|
406
|
+
# Restore state
|
|
407
|
+
saved_name = self.get_state("name", "")
|
|
408
|
+
if saved_name:
|
|
409
|
+
self._name_input.setText(saved_name)
|
|
410
|
+
|
|
411
|
+
def _update_greeting(self, name: str) -> None:
|
|
412
|
+
"""Update greeting when name changes."""
|
|
413
|
+
if name:
|
|
414
|
+
self._greeting_label.setText(f"Hello, {name}!")
|
|
415
|
+
else:
|
|
416
|
+
self._greeting_label.setText("Hello!")
|
|
417
|
+
self.set_state("name", name)
|
|
418
|
+
self.name_changed.emit(name)
|
|
419
|
+
|
|
420
|
+
def _on_greet_clicked(self) -> None:
|
|
421
|
+
"""Handle greet button click."""
|
|
422
|
+
name = self._name_input.text() or "World"
|
|
423
|
+
logger.info("Greeting: {}", name)
|
|
424
|
+
|
|
425
|
+
def _on_activated(self) -> None:
|
|
426
|
+
"""Focus the name input when panel is activated."""
|
|
427
|
+
self._name_input.setFocus()
|
|
428
|
+
|
|
429
|
+
# MCP introspection
|
|
430
|
+
|
|
431
|
+
def _get_specific_introspection_data(self) -> dict[str, Any]:
|
|
432
|
+
"""Return panel-specific data."""
|
|
433
|
+
return {
|
|
434
|
+
"current_name": self._name_input.text(),
|
|
435
|
+
"greeting_text": self._greeting_label.text(),
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
def _get_available_actions(self) -> list[dict[str, Any]]:
|
|
439
|
+
"""Return available actions."""
|
|
440
|
+
actions = super()._get_available_actions()
|
|
441
|
+
actions.extend([
|
|
442
|
+
{
|
|
443
|
+
"name": "set_name",
|
|
444
|
+
"description": "Set the name for greeting",
|
|
445
|
+
"method": "action_set_name",
|
|
446
|
+
"parameters": {"name": "string"},
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
"name": "greet",
|
|
450
|
+
"description": "Trigger the greet button",
|
|
451
|
+
"method": "action_greet",
|
|
452
|
+
},
|
|
453
|
+
])
|
|
454
|
+
return actions
|
|
455
|
+
|
|
456
|
+
def action_set_name(self, name: str = "", **kwargs) -> bool:
|
|
457
|
+
"""MCP action: Set the name."""
|
|
458
|
+
self._name_input.setText(name)
|
|
459
|
+
return True
|
|
460
|
+
|
|
461
|
+
def action_greet(self, **kwargs) -> bool:
|
|
462
|
+
"""MCP action: Click the greet button."""
|
|
463
|
+
self._on_greet_clicked()
|
|
464
|
+
return True
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
# Self-register with the panel registry (REQUIRED for user plugins)
|
|
468
|
+
PanelRegistry.get_instance().register(MyCustomPanel, replace=True)
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
## file-conventions
|
|
472
|
+
|
|
473
|
+
User plugins are stored in: `~/lightfall/plugins/`
|
|
474
|
+
|
|
475
|
+
Naming conventions:
|
|
476
|
+
- Filename: lowercase with underscores (e.g., `my_panel.py`)
|
|
477
|
+
- Panel ID: `lightfall.panels.user.<name>` (e.g., `lightfall.panels.user.my_panel`)
|
|
478
|
+
- Class name: PascalCase ending in Panel (e.g., `MyPanel`)
|
|
479
|
+
|
|
480
|
+
## qt-layout-tips
|
|
481
|
+
|
|
482
|
+
```python
|
|
483
|
+
# Vertical layout (stack widgets top to bottom)
|
|
484
|
+
layout = QVBoxLayout()
|
|
485
|
+
|
|
486
|
+
# Horizontal layout (stack widgets left to right)
|
|
487
|
+
layout = QHBoxLayout()
|
|
488
|
+
|
|
489
|
+
# Add stretch to push widgets together
|
|
490
|
+
layout.addStretch()
|
|
491
|
+
|
|
492
|
+
# Set margins (left, top, right, bottom)
|
|
493
|
+
layout.setContentsMargins(10, 10, 10, 10)
|
|
494
|
+
|
|
495
|
+
# Set spacing between widgets
|
|
496
|
+
layout.setSpacing(5)
|
|
497
|
+
|
|
498
|
+
# Group widgets in a titled box
|
|
499
|
+
group = QGroupBox("Settings")
|
|
500
|
+
group_layout = QVBoxLayout(group)
|
|
501
|
+
group_layout.addWidget(widget)
|
|
502
|
+
|
|
503
|
+
# Splitter for resizable sections
|
|
504
|
+
splitter = QSplitter(Qt.Orientation.Horizontal)
|
|
505
|
+
splitter.addWidget(left_panel)
|
|
506
|
+
splitter.addWidget(right_panel)
|
|
507
|
+
|
|
508
|
+
# Scrollable area
|
|
509
|
+
scroll = QScrollArea()
|
|
510
|
+
scroll.setWidgetResizable(True)
|
|
511
|
+
scroll.setWidget(content_widget)
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
## common-widgets
|
|
515
|
+
|
|
516
|
+
```python
|
|
517
|
+
# Label with text
|
|
518
|
+
label = QLabel("Text")
|
|
519
|
+
|
|
520
|
+
# Single-line text input
|
|
521
|
+
line_edit = QLineEdit()
|
|
522
|
+
line_edit.setPlaceholderText("Hint...")
|
|
523
|
+
line_edit.textChanged.connect(handler)
|
|
524
|
+
|
|
525
|
+
# Integer spinner
|
|
526
|
+
spin = QSpinBox()
|
|
527
|
+
spin.setRange(0, 100)
|
|
528
|
+
spin.setValue(10)
|
|
529
|
+
spin.valueChanged.connect(handler)
|
|
530
|
+
|
|
531
|
+
# Float spinner
|
|
532
|
+
double_spin = QDoubleSpinBox()
|
|
533
|
+
double_spin.setRange(0.0, 10.0)
|
|
534
|
+
double_spin.setDecimals(3)
|
|
535
|
+
double_spin.setValue(1.0)
|
|
536
|
+
|
|
537
|
+
# Dropdown
|
|
538
|
+
combo = QComboBox()
|
|
539
|
+
combo.addItems(["Option 1", "Option 2"])
|
|
540
|
+
combo.currentTextChanged.connect(handler)
|
|
541
|
+
|
|
542
|
+
# Checkbox
|
|
543
|
+
check = QCheckBox("Enable feature")
|
|
544
|
+
check.setChecked(True)
|
|
545
|
+
check.stateChanged.connect(handler)
|
|
546
|
+
|
|
547
|
+
# Button
|
|
548
|
+
btn = QPushButton("Click Me")
|
|
549
|
+
btn.clicked.connect(handler)
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
## compact-motor-widget
|
|
553
|
+
|
|
554
|
+
For simple motor controls in a panel, use `CompactMotorWidget` — a single-row
|
|
555
|
+
widget with status dot, readback, jog/abs toggle, setpoint entry, go, and stop.
|
|
556
|
+
It handles ophyd subscription, units, and motion state internally.
|
|
557
|
+
|
|
558
|
+
```python
|
|
559
|
+
from lightfall.ui.widgets.compact_motor import CompactMotorWidget
|
|
560
|
+
from lightfall.devices import DeviceCatalog
|
|
561
|
+
|
|
562
|
+
catalog = DeviceCatalog.get_instance()
|
|
563
|
+
info = catalog.get_device_by_name("sample_x")
|
|
564
|
+
widget = CompactMotorWidget(device_info=info, ophyd_obj=info.ophyd_device)
|
|
565
|
+
self._layout.addWidget(widget)
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
The `ophyd_obj` may be `None` initially; call `widget.set_motor(...)` once
|
|
569
|
+
the device finishes connecting (e.g. from `DeviceCatalog.device_connected`).
|
|
570
|
+
|
|
571
|
+
## lightfall-services
|
|
572
|
+
|
|
573
|
+
```python
|
|
574
|
+
# Toast notifications
|
|
575
|
+
from lightfall.ui.toast import ToastManager
|
|
576
|
+
toast = ToastManager.get_instance()
|
|
577
|
+
toast.success("Title", "Message")
|
|
578
|
+
toast.error("Title", "Message")
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
> **Prefer Qt palette role names** (`palette(text)`, `palette(highlight)`,
|
|
582
|
+
> `palette(mid)`, `palette(window)`) over hex codes in stylesheets — they
|
|
583
|
+
> auto-track theme switches and stay correct in both light and dark mode
|
|
584
|
+
> without an explicit re-style.
|
|
585
|
+
|
|
586
|
+
```python
|
|
587
|
+
# Theme awareness
|
|
588
|
+
from lightfall.ui.theme import ThemeManager
|
|
589
|
+
theme_mgr = ThemeManager.get_instance()
|
|
590
|
+
is_dark = theme_mgr.is_dark
|
|
591
|
+
|
|
592
|
+
# Preferences
|
|
593
|
+
from lightfall.ui.preferences.manager import PreferencesManager
|
|
594
|
+
prefs = PreferencesManager.get_instance()
|
|
595
|
+
value = prefs.get("key", default)
|
|
596
|
+
prefs.set("key", value)
|
|
597
|
+
|
|
598
|
+
# Device catalog
|
|
599
|
+
from lightfall.devices import DeviceCatalog
|
|
600
|
+
from lightfall.devices.model import DeviceCategory
|
|
601
|
+
|
|
602
|
+
catalog = DeviceCatalog.get_instance()
|
|
603
|
+
# list_devices returns DeviceInfo objects
|
|
604
|
+
motor_infos = catalog.list_devices(category=DeviceCategory.MOTOR)
|
|
605
|
+
# Access ophyd device via .ophyd_device property
|
|
606
|
+
motors = [info.ophyd_device for info in motor_infos if info.ophyd_device]
|
|
607
|
+
# Or get ophyd device directly by name
|
|
608
|
+
motor = catalog.get_ophyd_device("sample_x")
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
## device-catalog-api
|
|
612
|
+
|
|
613
|
+
The DeviceCatalog provides device discovery and access. It manages DeviceInfo
|
|
614
|
+
objects which wrap ophyd devices with metadata and state tracking.
|
|
615
|
+
|
|
616
|
+
### Two-Layer Architecture
|
|
617
|
+
|
|
618
|
+
- **DeviceInfo**: Metadata wrapper with name, category, state, etc.
|
|
619
|
+
- **ophyd device**: The actual hardware interface (accessed via `.ophyd_device`)
|
|
620
|
+
|
|
621
|
+
### Listing and Searching Devices
|
|
622
|
+
|
|
623
|
+
```python
|
|
624
|
+
from lightfall.devices import DeviceCatalog
|
|
625
|
+
from lightfall.devices.model import DeviceCategory, DeviceInfo
|
|
626
|
+
|
|
627
|
+
catalog = DeviceCatalog.get_instance()
|
|
628
|
+
|
|
629
|
+
# List with filters (returns list[DeviceInfo])
|
|
630
|
+
devices = catalog.list_devices(category=DeviceCategory.MOTOR, beamline="BL1", active_only=True)
|
|
631
|
+
devices = catalog.search_devices("sample") # Search by name/description/tags
|
|
632
|
+
devices = catalog.get_all_devices() # Get all devices
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
### Getting a Single Device
|
|
636
|
+
|
|
637
|
+
```python
|
|
638
|
+
# By name (returns DeviceInfo | None)
|
|
639
|
+
device_info = catalog.get_device_by_name("sample_x")
|
|
640
|
+
|
|
641
|
+
# By EPICS prefix
|
|
642
|
+
device_info = catalog.get_device_by_prefix("IOC:m1")
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
### Accessing the Ophyd Device
|
|
646
|
+
|
|
647
|
+
```python
|
|
648
|
+
# Direct access (returns ophyd device or None)
|
|
649
|
+
ophyd_dev = catalog.get_ophyd_device("sample_x")
|
|
650
|
+
|
|
651
|
+
# Via DeviceInfo (may be None if not connected)
|
|
652
|
+
ophyd_dev = device_info.ophyd_device
|
|
653
|
+
|
|
654
|
+
# Control the device
|
|
655
|
+
if ophyd_dev:
|
|
656
|
+
position = ophyd_dev.position # Read position
|
|
657
|
+
ophyd_dev.set(10.0).wait() # Move and wait
|
|
658
|
+
ophyd_dev.stop() # Stop motion
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
### DeviceInfo Properties
|
|
662
|
+
|
|
663
|
+
```python
|
|
664
|
+
device_info.id # UUID - unique identifier
|
|
665
|
+
device_info.name # str - human-readable name
|
|
666
|
+
device_info.category # DeviceCategory enum
|
|
667
|
+
device_info.description # str - device description
|
|
668
|
+
device_info.prefix # str - EPICS PV prefix
|
|
669
|
+
device_info.beamline # str | None - beamline assignment
|
|
670
|
+
device_info.active # bool - is device active
|
|
671
|
+
device_info.state # DeviceState - current state (position, status, alarms)
|
|
672
|
+
device_info.ophyd_device # The actual ophyd device instance (may be None)
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
### DeviceCategory Enum
|
|
676
|
+
|
|
677
|
+
Available categories (independent vs dependent variable classification):
|
|
678
|
+
- `DeviceCategory.MOTOR` - Physical read/write (motors, positioners, slits) — independent variable
|
|
679
|
+
- `DeviceCategory.DETECTOR` - Measures something (detectors, cameras, sensors, diodes, signals) — dependent variable
|
|
680
|
+
- `DeviceCategory.CONTROLLER` - Non-physical read/write (temperature controllers, delay generators, power supplies) — independent variable, catch-all default
|