Skip to content

Commit aedc216

Browse files
committed
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
1 parent ec4db9a commit aedc216

File tree

6 files changed

+33
-0
lines changed

6 files changed

+33
-0
lines changed

HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
=======
22
History
33
=======
4+
2024.10.10 -- Enhancement: Added state method for some widgets
5+
* Added a state method to LabeledWidget, LabeledComboBox, LabeledEntry, UnitEntry
6+
and UnitComboBox. This method sets or returns the state of the widget
7+
48
2024.7.21 -- Return the width of aligned labels
59
* The align_labels procedure now returns the width of the labels. This is useful for
610
laying out indented widgets.

seamm_widgets/labeled_combobox.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,9 @@ def config(self, **kwargs):
114114

115115
def configure(self, **kwargs):
116116
return self.config(**kwargs)
117+
118+
def state(self, stateSpec=None):
119+
"""Set the state of the widget"""
120+
result = super().state(stateSpec)
121+
tmp = self.combobox.state(stateSpec)
122+
return result + tmp

seamm_widgets/labeled_entry.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,9 @@ def config(self, **kwargs):
107107

108108
# having removed our options, pass rest to parent
109109
super().config(**kwargs)
110+
111+
def state(self, stateSpec=None):
112+
"""Set the state of the widget"""
113+
result = super().state(stateSpec)
114+
tmp = self.entry.state(stateSpec)
115+
return result + tmp

seamm_widgets/labeled_widget.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,8 @@ def config(self, **kwargs):
173173
# Since this is the base class, raise an error force
174174
# unrecognized options
175175
raise RuntimeError("Unknown option '{}'".format(k))
176+
177+
def state(self, stateSpec=None):
178+
"""Set the state of the widget"""
179+
result = self.label.state(stateSpec)
180+
return result

seamm_widgets/unit_combobox.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,9 @@ def config(self, **kwargs):
173173

174174
# having removed our options, pass rest to parent
175175
super().config(**kwargs)
176+
177+
def state(self, stateSpec=None):
178+
"""Set the state of the widget"""
179+
result = super().state(stateSpec)
180+
tmp = self.units.state(stateSpec)
181+
return result + tmp

seamm_widgets/unit_entry.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,9 @@ def config(self, **kwargs):
170170

171171
# having removed our options, pass rest to parent
172172
super().config(**kwargs)
173+
174+
def state(self, stateSpec=None):
175+
"""Set the state of the widget"""
176+
result = super().state(stateSpec)
177+
tmp = self.units.state(stateSpec)
178+
return result + tmp

0 commit comments

Comments
 (0)