diff --git a/qwt/tests/utils.py b/qwt/tests/utils.py index 7f92a99..9f4d147 100644 --- a/qwt/tests/utils.py +++ b/qwt/tests/utils.py @@ -237,11 +237,16 @@ def __init__(self, widget_name, parent=None): super(TestCentralWidget, self).__init__(parent) self.widget_name = widget_name self.plots = None - self.widget_of_interest = self.parent() self.setLayout(QW.QVBoxLayout()) self.options = TestOptions(self) self.add_widget(self.options) + def get_widget_of_interest(self): + """Return widget of interest""" + if self.plots is not None and len(self.plots) == 1: + return self.plots[0] + return self.parent() + def add_widget(self, widget): """Add new sub-widget""" self.layout().addWidget(widget) @@ -257,8 +262,6 @@ def add_widget(self, widget): plot_name, "Enable new flat style option", plot.setFlatStyle ) widget.setChecked(plot.flatStyle()) - if len(self.plots) == 1: - self.widget_of_interest = self.plots[0] def take_screenshot(widget): @@ -297,7 +300,7 @@ def test_widget(widget_class, size=None, title=None, options=True): central_widget = TestCentralWidget(widget_name, parent=window) central_widget.add_widget(widget) window.setCentralWidget(central_widget) - widget_of_interest = central_widget.widget_of_interest + widget_of_interest = central_widget.get_widget_of_interest() else: widget_of_interest = window widget_of_interest.setObjectName(widget_name)