@@ -160,18 +160,28 @@ def contextMenuEvent(
160160
161161
162162class GetObjectDialog (QW .QDialog ):
163- """Get object dialog box"""
163+ """Get object dialog box
164+
165+ Args:
166+ parent: Parent widget
167+ proxy: Remote proxy
168+ panel: Panel to retrieve objects from ('signal', 'image' or None for both)
169+ title: Dialog title
170+ """
164171
165172 def __init__ (
166173 self ,
167174 parent : QW .QWidget ,
168175 proxy : SimpleRemoteProxy ,
176+ panel : str | None = None ,
169177 title : str | None = None ,
170178 ) -> None :
171179 super ().__init__ (parent )
180+ assert panel in (None , "signal" , "image" )
172181 self .__proxy = proxy
173182 self .__current_object_uuid : str | None = None
174183 self .setWindowTitle (_ ("Select object" ) if title is None else title )
184+ self .setWindowIcon (svgtext_to_icon (svg_icons .DATALAB ))
175185 vlayout = QW .QVBoxLayout ()
176186 self .setLayout (vlayout )
177187
@@ -181,31 +191,37 @@ def __init__(
181191 logo_label .setPixmap (pixmap )
182192 logo_label .setAlignment (QC .Qt .AlignCenter )
183193
184- panelgroup = QW .QWidget ()
185- panellayout = QW .QHBoxLayout ()
186- panellayout .setContentsMargins (0 , 0 , 0 , 0 )
187- # panellayout.setAlignment(QC.Qt.AlignCenter)
188- panelgroup .setLayout (panellayout )
189-
190- panelcombo = QW .QComboBox ()
191- panelcombo .addItem (svgtext_to_icon (svg_icons .SIGNAL ), _ ("Signals" ))
192- panelcombo .addItem (svgtext_to_icon (svg_icons .IMAGE ), _ ("Images" ))
193- panelcombo .setCurrentIndex (0 if proxy .get_current_panel () == "signal" else 1 )
194- panelcombo .currentIndexChanged .connect (self .__change_panel )
195-
196- panellabel = QW .QLabel (_ ("Active panel:" ))
197- panellayout .addWidget (panellabel )
198- panellayout .addWidget (panelcombo )
199- panellayout .setStretch (1 , 1 )
194+ panelgroup = None
195+ if panel is None :
196+ panelgroup = QW .QWidget ()
197+ panellayout = QW .QHBoxLayout ()
198+ panellayout .setContentsMargins (0 , 0 , 0 , 0 )
199+ # panellayout.setAlignment(QC.Qt.AlignCenter)
200+ panelgroup .setLayout (panellayout )
201+
202+ panelcombo = QW .QComboBox ()
203+ panelcombo .addItem (svgtext_to_icon (svg_icons .SIGNAL ), _ ("Signals" ))
204+ panelcombo .addItem (svgtext_to_icon (svg_icons .IMAGE ), _ ("Images" ))
205+ if proxy .get_current_panel () == "image" :
206+ panelcombo .setCurrentIndex (1 )
207+ panelcombo .currentIndexChanged .connect (self .__change_panel )
208+
209+ panellabel = QW .QLabel (_ ("Active panel:" ))
210+ panellayout .addWidget (panellabel )
211+ panellayout .addWidget (panelcombo )
212+ panellayout .setStretch (1 , 1 )
213+ else :
214+ self .__proxy .set_current_panel (panel )
200215
201216 self .tree = SimpleObjectTree (parent )
202217 self .tree .init_from (proxy )
203218 self .tree .SIG_ITEM_DOUBLECLICKED .connect (lambda oid : self .accept ())
204- self .tree .itemSelectionChanged .connect (self .current_object_changed )
219+ self .tree .itemSelectionChanged .connect (self .__current_object_changed )
205220
206221 vlayout .addWidget (logo_label )
207222 vlayout .addSpacing (10 )
208- vlayout .addWidget (panelgroup )
223+ if panelgroup is not None :
224+ vlayout .addWidget (panelgroup )
209225 vlayout .addWidget (self .tree )
210226
211227 bbox = QW .QDialogButtonBox (QW .QDialogButtonBox .Ok | QW .QDialogButtonBox .Cancel )
@@ -215,21 +231,21 @@ def __init__(
215231 vlayout .addSpacing (10 )
216232 vlayout .addWidget (bbox )
217233 # Update OK button state:
218- self .current_object_changed ()
234+ self .__current_object_changed ()
219235
220236 def __change_panel (self , index : int ) -> None :
221237 """Change panel"""
222238 self .__proxy .set_current_panel ("signal" if index == 0 else "image" )
223239 self .tree .init_from (self .__proxy )
224- self .current_object_changed ()
225-
226- def get_current_object_uuid (self ) -> str :
227- """Return current object uuid"""
228- return self .__current_object_uuid
240+ self .__current_object_changed ()
229241
230- def current_object_changed (self ) -> None :
242+ def __current_object_changed (self ) -> None :
231243 """Item selection has changed"""
232244 self .__current_object_uuid = self .tree .get_current_item_id ()
233245 self .ok_btn .setEnabled (bool (self .__current_object_uuid ))
234246 self .ok_btn .setEnabled (bool (self .__current_object_uuid ))
235247 self .ok_btn .setEnabled (bool (self .__current_object_uuid ))
248+
249+ def get_current_object_uuid (self ) -> str :
250+ """Return current object uuid"""
251+ return self .__current_object_uuid
0 commit comments