From 14ed1ae3919a549a2e30786d0addc3c022a1b850 Mon Sep 17 00:00:00 2001 From: Kurt Jacobson Date: Sat, 3 Oct 2020 22:21:56 -0400 Subject: [PATCH] ENH: Dialogs - Add method to hide last dialog --- qtpyvcp/widgets/dialogs/__init__.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/qtpyvcp/widgets/dialogs/__init__.py b/qtpyvcp/widgets/dialogs/__init__.py index c91755518..9d6af57c7 100644 --- a/qtpyvcp/widgets/dialogs/__init__.py +++ b/qtpyvcp/widgets/dialogs/__init__.py @@ -5,6 +5,8 @@ LOG = getLogger(__name__) +ACTIVE_DIALOGS = [] + def getDialog(name): """Get dialog instance from name. @@ -40,6 +42,20 @@ def showDialog(name): dialog.move(win_pos.x() - dialog.width() / 2, win_pos.y() - dialog.height() / 2) dialog.show() + ACTIVE_DIALOGS.append(dialog) + + +def hideActiveDialog(): + try: + dialog = ACTIVE_DIALOGS.pop(-1) + dialog.hide() + except: + pass + + +def hideDialog(name): + dialog = getDialog(name) + dialog.hide() def askQuestion(title='', message='', parent=None):