Browse Source

qt wizard: WizardComponent: (fix) also inherit ABC

for `@abstractmethod` decorator to work
(except, turns out, it's not so simple because of pyqt's own magic for QWidget)
master
SomberNight 2 years ago
parent
commit
37173845c2
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 7
      electrum/gui/qt/util.py
  2. 4
      electrum/gui/qt/wizard/wizard.py

7
electrum/gui/qt/util.py

@ -1,3 +1,4 @@
from abc import ABC, ABCMeta
import os.path
import time
import sys
@ -1430,6 +1431,12 @@ def qt_event_listener(func):
return decorator
class _ABCQObjectMeta(type(QObject), ABCMeta): pass
class _ABCQWidgetMeta(type(QWidget), ABCMeta): pass
class AbstractQObject(QObject, ABC, metaclass=_ABCQObjectMeta): pass
class AbstractQWidget(QWidget, ABC, metaclass=_ABCQWidgetMeta): pass
if __name__ == "__main__":
app = QApplication([])
t = WaitingDialog(None, 'testing ...', lambda: [time.sleep(1)], lambda x: QMessageBox.information(None, 'done', "done"))

4
electrum/gui/qt/wizard/wizard.py

@ -10,7 +10,7 @@ from PyQt5.QtWidgets import (QDialog, QPushButton, QWidget, QLabel, QVBoxLayout,
from electrum.i18n import _
from electrum.logging import get_logger
from electrum.gui.qt.util import Buttons, icon_path, MessageBoxMixin, WWLabel, ResizableStackedWidget
from electrum.gui.qt.util import Buttons, icon_path, MessageBoxMixin, WWLabel, ResizableStackedWidget, AbstractQWidget
if TYPE_CHECKING:
from electrum.simple_config import SimpleConfig
@ -233,7 +233,7 @@ class QEAbstractWizard(QDialog, MessageBoxMixin):
return True
class WizardComponent(QWidget):
class WizardComponent(AbstractQWidget):
updated = pyqtSignal(object)
def __init__(self, parent: QWidget, wizard: QEAbstractWizard, *, title: str = None, layout: QLayout = None):

Loading…
Cancel
Save