|
|
@ -30,6 +30,7 @@ from electrum.invoices import PR_UNPAID, PR_PAID, PR_EXPIRED, PR_INFLIGHT, PR_UN |
|
|
|
|
|
|
|
if TYPE_CHECKING: |
|
|
|
from .main_window import ElectrumWindow |
|
|
|
from .installwizard import InstallWizard |
|
|
|
|
|
|
|
|
|
|
|
if platform.system() == 'Windows': |
|
|
@ -945,19 +946,23 @@ def export_meta_gui(electrum_window, title, exporter): |
|
|
|
.format(title, str(filename))) |
|
|
|
|
|
|
|
|
|
|
|
def get_parent_main_window(widget): |
|
|
|
def get_parent_main_window( |
|
|
|
widget, *, allow_wizard: bool = False, |
|
|
|
) -> Union[None, 'ElectrumWindow', 'InstallWizard']: |
|
|
|
"""Returns a reference to the ElectrumWindow this widget belongs to.""" |
|
|
|
from .main_window import ElectrumWindow |
|
|
|
from .transaction_dialog import TxDialog |
|
|
|
from .installwizard import InstallWizard |
|
|
|
for _ in range(100): |
|
|
|
if widget is None: |
|
|
|
return None |
|
|
|
if isinstance(widget, ElectrumWindow): |
|
|
|
return widget |
|
|
|
elif isinstance(widget, TxDialog): |
|
|
|
if isinstance(widget, TxDialog): |
|
|
|
return widget.main_window |
|
|
|
else: |
|
|
|
widget = widget.parentWidget() |
|
|
|
if isinstance(widget, InstallWizard) and allow_wizard: |
|
|
|
return widget |
|
|
|
widget = widget.parentWidget() |
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|