Skip to content

Commit

Permalink
fix: widget sensitivity not changing on subcategory change (#1020)
Browse files Browse the repository at this point in the history
* refactor: add _category_id attribute to Hardware tree panel

* refactor: remove self._do_set_sensitive() listener for succeed_get_{}_attributes message

* refactor: remove lines that load widgets from set_sensistive methods

* style: update stub files
  • Loading branch information
weibullguy committed Mar 4, 2022
1 parent ac19638 commit dc5bf6a
Show file tree
Hide file tree
Showing 22 changed files with 193 additions and 665 deletions.
47 changes: 12 additions & 35 deletions src/ramstk/views/gtk3/design_electric/components/capacitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,8 @@ def do_load_comboboxes(self, subcategory_id: int) -> None:
]
self.cmbConstruction.do_load_combo(_construction, signal="changed")

self._do_set_sensitive()

def _do_set_reliability_attributes(self, attributes: Dict[str, Any]) -> None:
"""Set the attributes when the reliability attributes are retrieved.
Expand All @@ -675,6 +677,8 @@ def _do_set_reliability_attributes(self, attributes: Dict[str, Any]) -> None:
signal="changed",
)

self._do_set_sensitive()

def _do_load_styles(self, combo: RAMSTKComboBox) -> None:
"""Load the style RAMSTKComboBox() when the specification changes.
Expand All @@ -694,19 +698,19 @@ def _do_load_styles(self, combo: RAMSTKComboBox) -> None:
_styles = []
self.cmbStyle.do_load_combo(entries=_styles, signal="changed")

def _do_set_sensitive(self, attributes: Dict[str, Any]) -> None:
def _do_set_sensitive(self) -> None:
"""Set widget sensitivity as needed for the selected capacitor type.
:return: None
:rtype: None
"""
if self._hazard_rate_method_id == 1:
self.__do_set_parts_count_sensitive(attributes)
self.__do_set_parts_count_sensitive()
else:
self.__do_set_part_stress_sensitive(attributes)
self.__do_set_part_stress_sensitive()

# pylint: disable=unused-argument
def __do_set_parts_count_sensitive(self, attributes: Dict[str, Any]) -> None:
def __do_set_parts_count_sensitive(self) -> None:
"""Set widget sensitivity as needed for MIL-HDBK-217F, Parts Count.
:return: None
Expand All @@ -722,51 +726,24 @@ def __do_set_parts_count_sensitive(self, attributes: Dict[str, Any]) -> None:
self.txtCapacitance.set_sensitive(False)
self.txtESR.set_sensitive(False)

def __do_set_part_stress_sensitive(self, attributes: Dict[str, Any]) -> None:
def __do_set_part_stress_sensitive(self) -> None:
"""Set widget sensitivity as needed for MIL-HDBK-217F, Part Stress.
:return: None
:rtype: None
"""
self.cmbSpecification.set_sensitive(True)
self.cmbSpecification.do_update(
attributes["specification_id"],
signal="changed",
)
self.cmbStyle.set_sensitive(True)
self.cmbStyle.do_update(
attributes["type_id"],
signal="changed",
)
self.txtCapacitance.set_sensitive(True)
self.txtCapacitance.do_update(
attributes["capacitance"],
signal="changed",
)
self.txtESR.set_sensitive(False)
self.cmbConstruction.set_sensitive(False)
self.cmbConfiguration.set_sensitive(False)

if self.subcategory_id == 12:
self.txtESR.set_sensitive(True)
self.txtESR.do_update(
attributes["resistance"],
signal="changed",
)
else:
self.txtESR.set_sensitive(False)

if self.subcategory_id == 13:
self.cmbConstruction.set_sensitive(True)
self.cmbConstruction.do_update(
attributes["construction_id"],
signal="changed",
)
else:
self.cmbConstruction.set_sensitive(False)

if self.subcategory_id == 19:
self.cmbConfiguration.set_sensitive(True)
self.cmbConfiguration.do_update(
attributes["configuration_id"],
signal="changed",
)
else:
self.cmbConfiguration.set_sensitive(False)
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ class CapacitorDesignElectricInputPanel(RAMSTKFixedPanel):
def do_load_comboboxes(self, subcategory_id: int) -> None: ...
def _do_set_reliability_attributes(self, attributes: Dict[str, Any]) -> None: ...
def _do_load_styles(self, combo: RAMSTKComboBox) -> None: ...
def _do_set_sensitive(self, attributes: Dict[str, Any]) -> None: ...
def __do_set_parts_count_sensitive(self, attributes: Dict[str, Any]) -> None: ...
def __do_set_part_stress_sensitive(self, attributes: Dict[str, Any]) -> None: ...
def _do_set_sensitive(self) -> None: ...
def __do_set_parts_count_sensitive(self) -> None: ...
def __do_set_part_stress_sensitive(self) -> None: ...
93 changes: 13 additions & 80 deletions src/ramstk/views/gtk3/design_electric/components/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ def do_load_comboboxes(self, subcategory_id: int) -> None:
_model = self.cmbInsert.get_model()
_model.clear()

self._do_set_sensitive()

def _do_load_insert(self, combo: RAMSTKComboBox) -> None:
"""Load the insert RAMSTKComboBox() when the specification changes.
Expand Down Expand Up @@ -498,7 +500,9 @@ def _do_set_reliability_attributes(self, attributes: Dict[str, Any]) -> None:
signal="changed",
)

def _do_set_sensitive(self, attributes: Dict[str, Any]) -> None:
self._do_set_sensitive()

def _do_set_sensitive(self) -> None:
"""Set widget sensitivity as needed for the selected connection.
:return: None
Expand All @@ -518,64 +522,28 @@ def _do_set_sensitive(self, attributes: Dict[str, Any]) -> None:

if self._hazard_rate_method_id == 1:
self.cmbType.set_sensitive(True)
self.cmbType.do_update(
attributes["type_id"],
signal="changed",
)
else:
self.__do_set_circular_sensitive(attributes)
self.__do_set_ic_socket_sensitive(attributes)
self.__do_set_pwa_edge_sensitive(attributes)
self.__do_set_pth_sensitive(attributes)
self.__do_set_circular_sensitive()
self.__do_set_ic_socket_sensitive()
self.__do_set_pwa_edge_sensitive()
self.__do_set_pth_sensitive()

def __do_set_circular_sensitive(self, attributes: Dict[str, Any]) -> None:
def __do_set_circular_sensitive(self) -> None:
"""Set the widgets for circular connectors sensitive or not.
:return: None
:rtype: None
"""
if self.subcategory_id == 1:
self.cmbType.set_sensitive(True)
# We don't block the callback signal otherwise the specification
# RAMSTKComboBox() will not be loaded and set.
self.cmbType.set_active(attributes["type_id"])

self.cmbSpecification.set_sensitive(True)
# We don't block the callback signal otherwise the insert
# RAMSTKComboBox() will not be loaded and set.
self.cmbSpecification.set_active(attributes["specification_id"])

self.cmbInsert.set_sensitive(True)
self.cmbInsert.do_update(
attributes["insert_id"],
signal="changed",
)

self.txtActivePins.set_sensitive(True)
self.txtActivePins.do_update(
str(attributes["n_active_pins"]),
signal="changed",
)

self.txtAmpsContact.set_sensitive(True)
self.txtAmpsContact.do_update(
str(self.fmt.format(attributes["current_operating"])),
signal="changed",
)

self.txtContactGauge.set_sensitive(True)
self.txtContactGauge.do_update(
str(attributes["contact_gauge"]),
signal="changed",
)

self.txtMating.set_sensitive(True)
self.txtMating.do_update(
str(attributes["n_cycles"]),
signal="changed",
)

def __do_set_ic_socket_sensitive(self, attributes: Dict[str, Any]) -> None:
def __do_set_ic_socket_sensitive(self) -> None:
"""Set the widgets for IC socket connectors sensitive or not.
:return: None
Expand All @@ -584,61 +552,26 @@ def __do_set_ic_socket_sensitive(self, attributes: Dict[str, Any]) -> None:
if self.subcategory_id == 3:
self.cmbQuality.set_sensitive(False)
self.txtActivePins.set_sensitive(True)
self.txtActivePins.do_update(
str(attributes["n_active_pins"]),
signal="changed",
)

def __do_set_pwa_edge_sensitive(self, attributes: Dict[str, Any]) -> None:
def __do_set_pwa_edge_sensitive(self) -> None:
"""Set the widgets for PCB/PWA edge connectors sensitive or not.
:return: None
:rtype: None
"""
if self.subcategory_id == 2:
self.txtAmpsContact.set_sensitive(True)
self.txtAmpsContact.do_update(
str(self.fmt.format(attributes["current_operating"])),
signal="changed",
)

self.txtContactGauge.set_sensitive(True)
self.txtContactGauge.do_update(
str(attributes["contact_gauge"]),
signal="changed",
)

self.txtMating.set_sensitive(True)
self.txtMating.do_update(
str(attributes["n_cycles"]),
signal="changed",
)

self.txtActivePins.set_sensitive(True)
self.txtActivePins.do_update(
str(attributes["n_active_pins"]),
signal="changed",
)

def __do_set_pth_sensitive(self, attributes: Dict[str, Any]) -> None:
def __do_set_pth_sensitive(self) -> None:
"""Set the widgets for PTH connections sensitive or not.
:return: None
:rtype: None
"""
if self.subcategory_id == 4:
self.txtNWave.set_sensitive(True)
self.txtNWave.do_update(
str(attributes["n_wave_soldered"]),
signal="changed",
)
self.txtNHand.set_sensitive(True)
self.txtNHand.do_update(
str(attributes["n_hand_soldered"]),
signal="changed",
)
self.txtNPlanes.set_sensitive(True)
self.txtNPlanes.do_update(
str(attributes["n_circuit_planes"]),
signal="changed",
)
10 changes: 5 additions & 5 deletions src/ramstk/views/gtk3/design_electric/components/connection.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class ConnectionDesignElectricInputPanel(RAMSTKFixedPanel):
def _do_load_insert(self, combo: RAMSTKComboBox) -> None: ...
def _do_load_specification(self, combo: RAMSTKComboBox) -> None: ...
def _do_set_reliability_attributes(self, attributes: Dict[str, Any]) -> None: ...
def _do_set_sensitive(self, attributes: Dict[str, Any]) -> None: ...
def __do_set_circular_sensitive(self, attributes: Dict[str, Any]) -> None: ...
def __do_set_ic_socket_sensitive(self, attributes: Dict[str, Any]) -> None: ...
def __do_set_pwa_edge_sensitive(self, attributes: Dict[str, Any]) -> None: ...
def __do_set_pth_sensitive(self, attributes: Dict[str, Any]) -> None: ...
def _do_set_sensitive(self) -> None: ...
def __do_set_circular_sensitive(self) -> None: ...
def __do_set_ic_socket_sensitive(self) -> None: ...
def __do_set_pwa_edge_sensitive(self) -> None: ...
def __do_set_pth_sensitive(self) -> None: ...
34 changes: 5 additions & 29 deletions src/ramstk/views/gtk3/design_electric/components/inductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ def do_load_comboboxes(self, subcategory_id: int) -> None:
[[_("Fixed")], [_("Variable")]], signal="changed"
)

self._do_set_sensitive()

def _do_load_panel(self, attributes: Dict[str, Any]) -> None:
"""Load the Inductor assessment input widgets.
Expand Down Expand Up @@ -294,7 +296,9 @@ def _do_set_reliability_attributes(self, attributes: Dict[str, Any]) -> None:
signal="changed",
)

def _do_set_sensitive(self, attributes: Dict[str, Any]) -> None:
self._do_set_sensitive()

def _do_set_sensitive(self) -> None:
"""Set widget sensitivity as needed for the selected inductor.
:return: None
Expand All @@ -309,45 +313,17 @@ def _do_set_sensitive(self, attributes: Dict[str, Any]) -> None:

if self._hazard_rate_method_id == 1:
self.cmbFamily.set_sensitive(True)
self.cmbFamily.do_update(
attributes["family_id"],
signal="changed",
)
else:
self.cmbSpecification.set_sensitive(True)
self.cmbSpecification.do_update(
attributes["specification_id"],
signal="changed",
)
self.cmbInsulation.set_sensitive(True)
self.cmbInsulation.do_update(
attributes["insulation_id"],
signal="changed",
)
self.txtArea.set_sensitive(True)
self.txtArea.do_update(
attributes["area"],
signal="changed",
)
self.txtWeight.set_sensitive(True)
self.txtWeight.do_update(
attributes["weight"],
signal="changed",
)

if self.subcategory_id == 1:
self.cmbFamily.set_sensitive(True)
self.cmbFamily.do_update(
attributes["family_id"],
signal="changed",
)

if self.subcategory_id == 2:
self.cmbConstruction.set_sensitive(True)
self.cmbConstruction.do_update(
attributes["construction_id"],
signal="changed",
)

def __do_load_family_combobox(self) -> None:
"""Load the family RAMSTKComboBox().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class InductorDesignElectricInputPanel(RAMSTKFixedPanel):
def do_load_comboboxes(self, subcategory_id: int) -> None: ...
def _do_load_panel(self, attributes: Dict[str, Any]) -> None: ...
def _do_set_reliability_attributes(self, attributes: Dict[str, Any]) -> None: ...
def _do_set_sensitive(self, attributes: Dict[str, Any]) -> None: ...
def _do_set_sensitive(self) -> None: ...
def __do_load_family_combobox(self) -> None: ...
def __do_load_insulation_combobox(self) -> None: ...
def __do_load_quality_combobox(self) -> None: ...
Expand Down
Loading

0 comments on commit dc5bf6a

Please sign in to comment.