Skip to content

Commit e359ca8

Browse files
authored
Merge pull request #4 from NSLS-II/graphics-scene
Re-engineering qmicroscope to allow a plugin API
2 parents 3af23e1 + 24bd9b5 commit e359ca8

18 files changed

+1439
-368
lines changed

main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ def __init__(self, parent=None):
3939

4040
# Create layout and add widgets
4141
layout = QVBoxLayout()
42-
layout.addWidget(self.container)
4342
hButtonBox = QHBoxLayout()
4443
hButtonBox.addStretch()
4544
hButtonBox.addWidget(self.startButton)
4645
hButtonBox.addWidget(self.settingsButton)
4746
hButtonBox.addStretch()
4847
layout.addLayout(hButtonBox)
48+
layout.addWidget(self.container)
49+
4950

5051
# Set main windows widget using our central layout
5152
widget = QWidget()

microscope/container.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
from qtpy.QtWidgets import ( QWidget, QGridLayout )
22
from qtpy.QtGui import QPaintEvent
33
from qtpy.QtCore import QSettings
4-
import microscope
54
from microscope.microscope import Microscope
65
from typing import List
76

87
""" A widget that contains one or more microscope widgets in a grid. """
98
class Container(QWidget):
10-
def __init__(self, parent:"QWidget|None"=None):
9+
def __init__(self, parent:"QWidget|None"=None, plugins=None):
1110
super(Container, self).__init__(parent)
11+
if not plugins:
12+
self.plugins = []
13+
else:
14+
self.plugins = plugins
1215
self.parent_widget = parent
1316
self._update: bool = True # Is an update required
1417
self._count: int = 1 # The number of widgets contained
@@ -17,11 +20,11 @@ def __init__(self, parent:"QWidget|None"=None):
1720

1821
self._widgets: "List[Microscope]" = []
1922

20-
if hasattr(self.parent_widget, 'set_main_microscope_url'):
21-
microscope_widget = Microscope(self)
22-
microscope_widget.clicked_url.connect(self.parent_widget.set_main_microscope_url)
23+
if hasattr(self.parent_widget, 'setup_main_microscope'):
24+
microscope_widget = Microscope(self, plugins=self.plugins)
25+
microscope_widget.clicked_url.connect(self.parent_widget.setup_main_microscope)
2326
else:
24-
microscope_widget = Microscope(self, viewport=False)
27+
microscope_widget = Microscope(self, viewport=False, plugins=self.plugins)
2528

2629
self._widgets.append(microscope_widget)
2730

@@ -97,9 +100,9 @@ def updateWidgets(self) -> None:
97100
if len(self._widgets) > self._count:
98101
self._widgets = self._widgets[:self._count]
99102
while(len(self._widgets) < self._count):
100-
microscope_widget = Microscope(self)
101-
if hasattr(self.parent_widget, 'set_main_microscope_url'):
102-
microscope_widget.clicked_url.connect(self.parent_widget.set_main_microscope_url)
103+
microscope_widget = Microscope(self, plugins=self.plugins)
104+
if hasattr(self.parent_widget, 'setup_main_microscope'):
105+
microscope_widget.clicked_url.connect(self.parent_widget.setup_main_microscope)
103106
self._widgets.append(microscope_widget)
104107

105108
def paintEvent(self, event: QPaintEvent) -> None:
@@ -148,8 +151,6 @@ def writeSettings(self, settings: QSettings) -> None:
148151
#self.updateMicroscope()
149152
# Write out all the settings for the widgets.
150153
for i in range(len(self._widgets)):
151-
settings.beginGroup(f'Camera{i}')
152-
self._widgets[i].writeSettings(settings)
153-
settings.endGroup()
154+
self._widgets[i].writeSettings(settings, settings_group=f'Camera{i}')
154155

155156
settings.endGroup()

microscope/downloader.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)