diff --git a/Orange/widgets/data/owselectcolumns.py b/Orange/widgets/data/owselectcolumns.py index 3835127b78a..c23161aaaae 100644 --- a/Orange/widgets/data/owselectcolumns.py +++ b/Orange/widgets/data/owselectcolumns.py @@ -14,6 +14,7 @@ from Orange.widgets.settings import ContextSetting, Setting from Orange.widgets.utils.listfilter import VariablesListItemView, slices, variables_filter from Orange.widgets.utils.widgetpreview import WidgetPreview +from Orange.widgets.utils.state_summary import format_summary_details from Orange.widgets.widget import Input, Output, AttributeList, Msg from Orange.data.table import Table from Orange.widgets.utils import vartype @@ -266,6 +267,9 @@ def dropcompleted(action): self.output_data = None self.original_completer_items = [] + self.info.set_input_summary(self.info.NoInput) + self.info.set_output_summary(self.info.NoOutput) + self.resize(600, 600) @property @@ -343,11 +347,13 @@ def set_data(self, data=None): self.class_attrs[:] = classes self.meta_attrs[:] = metas self.available_attrs[:] = available + self.info.set_input_summary(len(data), format_summary_details(data)) else: self.used_attrs[:] = [] self.class_attrs[:] = [] self.meta_attrs[:] = [] self.available_attrs[:] = [] + self.info.set_input_summary(self.info.NoInput) def update_domain_role_hints(self): """ Update the domain hints to be stored in the widgets settings. @@ -522,10 +528,13 @@ def commit(self): self.output_data = newdata self.Outputs.data.send(newdata) self.Outputs.features.send(AttributeList(attributes)) + self.info.set_output_summary(len(newdata), + format_summary_details(newdata)) else: self.output_data = None self.Outputs.data.send(None) self.Outputs.features.send(None) + self.info.set_output_summary(self.info.NoOutput) def reset(self): self.enable_used_attrs() diff --git a/Orange/widgets/data/tests/test_owselectcolumns.py b/Orange/widgets/data/tests/test_owselectcolumns.py index d9d6aed277c..8dff52c2b49 100644 --- a/Orange/widgets/data/tests/test_owselectcolumns.py +++ b/Orange/widgets/data/tests/test_owselectcolumns.py @@ -1,3 +1,4 @@ +# pylint: disable=unsubscriptable-object from unittest import TestCase from unittest.mock import Mock @@ -9,6 +10,7 @@ SelectAttributesDomainContextHandler from Orange.widgets.settings import ContextSetting from Orange.widgets.utils import vartype +from Orange.widgets.utils.state_summary import format_summary_details from Orange.widgets.tests.base import WidgetTest from Orange.widgets.data.owselectcolumns \ import OWSelectAttributes, VariablesListItemModel @@ -386,3 +388,23 @@ def test_move_rows(self): d1.domain.attributes, data.domain.attributes ) + + def test_summary(self): + """Check if status bar is updated when data is received""" + input_sum = self.widget.info.set_input_summary = Mock() + output_sum = self.widget.info.set_output_summary = Mock() + + data = Table("iris") + self.send_signal(self.widget.Inputs.data, data) + input_sum.assert_called_with(len(data), format_summary_details(data)) + output = self.get_output(self.widget.Outputs.data) + output_sum.assert_called_with(len(output), + format_summary_details(output)) + + input_sum.reset_mock() + output_sum.reset_mock() + self.send_signal(self.widget.Inputs.data, None) + input_sum.assert_called_once() + self.assertEqual(input_sum.call_args[0][0].brief, "") + output_sum.assert_called_once() + self.assertEqual(output_sum.call_args[0][0].brief, "")