diff --git a/HISTORY.rst b/HISTORY.rst index 42dc3f4..b99ae77 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,10 @@ ======= History ======= +2024.10.10 -- Enhancement: Added state method for some widgets + * Added a state method to LabeledWidget, LabeledComboBox, LabeledEntry, UnitEntry + and UnitComboBox. This method sets or returns the state of the widget + 2024.7.21 -- Return the width of aligned labels * The align_labels procedure now returns the width of the labels. This is useful for laying out indented widgets. diff --git a/seamm_widgets/labeled_combobox.py b/seamm_widgets/labeled_combobox.py index a88491e..09272ec 100644 --- a/seamm_widgets/labeled_combobox.py +++ b/seamm_widgets/labeled_combobox.py @@ -114,3 +114,9 @@ def config(self, **kwargs): def configure(self, **kwargs): return self.config(**kwargs) + + def state(self, stateSpec=None): + """Set the state of the widget""" + result = super().state(stateSpec) + tmp = self.combobox.state(stateSpec) + return result + tmp diff --git a/seamm_widgets/labeled_entry.py b/seamm_widgets/labeled_entry.py index 0f8630c..47b14a7 100644 --- a/seamm_widgets/labeled_entry.py +++ b/seamm_widgets/labeled_entry.py @@ -107,3 +107,9 @@ def config(self, **kwargs): # having removed our options, pass rest to parent super().config(**kwargs) + + def state(self, stateSpec=None): + """Set the state of the widget""" + result = super().state(stateSpec) + tmp = self.entry.state(stateSpec) + return result + tmp diff --git a/seamm_widgets/labeled_widget.py b/seamm_widgets/labeled_widget.py index b5cf87f..9acef79 100644 --- a/seamm_widgets/labeled_widget.py +++ b/seamm_widgets/labeled_widget.py @@ -173,3 +173,8 @@ def config(self, **kwargs): # Since this is the base class, raise an error force # unrecognized options raise RuntimeError("Unknown option '{}'".format(k)) + + def state(self, stateSpec=None): + """Set the state of the widget""" + result = self.label.state(stateSpec) + return result diff --git a/seamm_widgets/unit_combobox.py b/seamm_widgets/unit_combobox.py index ee545b1..1c50384 100644 --- a/seamm_widgets/unit_combobox.py +++ b/seamm_widgets/unit_combobox.py @@ -173,3 +173,9 @@ def config(self, **kwargs): # having removed our options, pass rest to parent super().config(**kwargs) + + def state(self, stateSpec=None): + """Set the state of the widget""" + result = super().state(stateSpec) + tmp = self.units.state(stateSpec) + return result + tmp diff --git a/seamm_widgets/unit_entry.py b/seamm_widgets/unit_entry.py index 069b877..22b00e9 100644 --- a/seamm_widgets/unit_entry.py +++ b/seamm_widgets/unit_entry.py @@ -170,3 +170,9 @@ def config(self, **kwargs): # having removed our options, pass rest to parent super().config(**kwargs) + + def state(self, stateSpec=None): + """Set the state of the widget""" + result = super().state(stateSpec) + tmp = self.units.state(stateSpec) + return result + tmp