MCPcopy Create free account
hub / github.com/DeepLabCut/DeepLabCut / _get_or_create_debug_dialog

Function _get_or_create_debug_dialog

deeplabcut/gui/dialogs/debug_dialog.py:204–234  ·  view source on GitHub ↗

Reuse a single dialog instance attached to ``parent``. Storing the dialog on the main window avoids accidental garbage collection and prevents opening a pile of duplicate windows.

(
    *,
    parent: QWidget,
    title: str,
    text_provider: Callable[[], str],
    text_hint: str,
    attr_name: str = "_dlc_debug_dialog",
)

Source from the content-addressed store, hash-verified

202
203
204def _get_or_create_debug_dialog(
205 *,
206 parent: QWidget,
207 title: str,
208 text_provider: Callable[[], str],
209 text_hint: str,
210 attr_name: str = "_dlc_debug_dialog",
211) -> DebugTextDialog:
212 """
213 Reuse a single dialog instance attached to ``parent``.
214
215 Storing the dialog on the main window avoids accidental garbage collection
216 and prevents opening a pile of duplicate windows.
217 """
218 dlg = getattr(parent, attr_name, None)
219 if isinstance(dlg, DebugTextDialog):
220 dlg.update_content(
221 title=title,
222 text_provider=text_provider,
223 hint=text_hint,
224 )
225 return dlg
226
227 dlg = DebugTextDialog(
228 title=title,
229 text_provider=text_provider,
230 parent=parent,
231 initial_hint=text_hint,
232 )
233 setattr(parent, attr_name, dlg)
234 return dlg
235
236
237def show_debug_report_dialog(

Callers 1

show_debug_report_dialogFunction · 0.85

Calls 2

update_contentMethod · 0.95
DebugTextDialogClass · 0.85

Tested by

no test coverage detected