11from qtpy .QtWidgets import ( QWidget , QGridLayout )
22from qtpy .QtGui import QPaintEvent
33from qtpy .QtCore import QSettings
4- import microscope
54from microscope .microscope import Microscope
65from typing import List
76
87""" A widget that contains one or more microscope widgets in a grid. """
98class 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 ()
0 commit comments