Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Use vars to reduce function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ebadkamil committed Mar 15, 2021
1 parent 911b672 commit d230a18
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions nexus_constructor/treeview_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ def set_button_states(


def set_enabled_and_raise(action: QAction, value: bool):
"""Disable or enable the action and autoRaise the associated QToolButton.
Parameters
----------
action: QAction
The action to enable or disable
value: bool
True to enable action and raise associated QToolButton.
"""
action.setEnabled(value)
for widget in action.associatedWidgets():
if isinstance(widget, QToolButton):
Expand All @@ -159,12 +168,8 @@ def handle_number_of_items_selected_is_not_one(
:param create_link_action: The action for creating a link.
:param zoom_action: The action for zooming on a component.
"""
set_enabled_and_raise(delete_action, False)
set_enabled_and_raise(new_rotation_action, False)
set_enabled_and_raise(new_translation_action, False)
set_enabled_and_raise(create_link_action, False)
set_enabled_and_raise(zoom_action, False)
set_enabled_and_raise(edit_component_action, False)
for action in vars().values():
set_enabled_and_raise(action, False)


def expand_transformation_list(
Expand Down

0 comments on commit d230a18

Please sign in to comment.