@@ -349,6 +349,7 @@ def __init__(self, model, font_metric, parent=None):
349349 self .tallyColorForm = ColorForm (self .model , self .main_window , 'tally' )
350350 self .scoresGroupBox = Expander (title = "Scores:" )
351351 self .scoresListWidget = QListWidget ()
352+ self .scoresListWidget .itemChanged .connect (self .updateScores )
352353 self .nuclidesListWidget = QListWidget ()
353354
354355 # Main layout
@@ -502,7 +503,6 @@ def selectTally(self, tally_label=None):
502503
503504 # scores
504505 self .score_map = {}
505- self .score_map .clear ()
506506 self .scoresListWidget .clear ()
507507
508508 sorted_scores = sorted (tally .scores )
@@ -628,39 +628,37 @@ def updateScores(self):
628628 applied_scores .append (score )
629629 self .model .appliedScores = tuple (applied_scores )
630630
631- if not applied_scores :
632- # if no scores are selected, enable all scores again
633- for score , score_box in self .score_map .items ():
634- sunits = _SCORE_UNITS .get (score , _REACTION_UNITS )
635- empty_item = QListWidgetItem ()
636- score_box .setFlags (empty_item .flags () |
637- QtCore .Qt .ItemIsUserCheckable )
638- score_box .setFlags (empty_item .flags () &
639- ~ QtCore .Qt .ItemIsSelectable )
640- elif 'total' in applied_scores :
641- self .model .appliedScores = ('total' ,)
642- # if total is selected, disable all other scores
643- for score , score_box in self .score_map .items ():
644- if score != 'total' :
645- score_box .setFlags (QtCore .Qt .ItemIsUserCheckable )
646- score_box .setToolTip (
647- "De-select 'total' to enable other scores" )
648- else :
649- # get units of applied scores
650- selected_units = _SCORE_UNITS .get (
651- applied_scores [0 ], _REACTION_UNITS )
652- # disable scores with incompatible units
653- for score , score_box in self .score_map .items ():
654- sunits = _SCORE_UNITS .get (score , _REACTION_UNITS )
655- if sunits != selected_units :
656- score_box .setFlags (QtCore .Qt .ItemIsUserCheckable )
657- score_box .setToolTip (
658- "Score is incompatible with currently selected scores" )
659- else :
660- score_box .setFlags (score_box .flags () |
661- QtCore .Qt .ItemIsUserCheckable )
662- score_box .setFlags (score_box .flags () &
663- ~ QtCore .Qt .ItemIsSelectable )
631+ with QtCore .QSignalBlocker (self .scoresListWidget ):
632+ if not applied_scores :
633+ # if no scores are selected, enable all scores again
634+ for score , score_box in self .score_map .items ():
635+ score_box .setFlags (QtCore .Qt .ItemIsUserCheckable |
636+ QtCore .Qt .ItemIsEnabled |
637+ QtCore .Qt .ItemIsSelectable )
638+ elif 'total' in applied_scores :
639+ self .model .appliedScores = ('total' ,)
640+ # if total is selected, disable all other scores
641+ for score , score_box in self .score_map .items ():
642+ if score != 'total' :
643+ score_box .setFlags (QtCore .Qt .ItemIsUserCheckable )
644+ score_box .setToolTip (
645+ "De-select 'total' to enable other scores" )
646+ else :
647+ # get units of applied scores
648+ selected_units = _SCORE_UNITS .get (
649+ applied_scores [0 ], _REACTION_UNITS )
650+ # disable scores with incompatible units
651+ for score , score_box in self .score_map .items ():
652+ sunits = _SCORE_UNITS .get (score , _REACTION_UNITS )
653+ if sunits != selected_units :
654+ score_box .setFlags (QtCore .Qt .ItemIsUserCheckable )
655+ score_box .setToolTip (
656+ "Score is incompatible with currently selected scores" )
657+ else :
658+ score_box .setFlags (score_box .flags () |
659+ QtCore .Qt .ItemIsUserCheckable )
660+ score_box .setFlags (score_box .flags () &
661+ ~ QtCore .Qt .ItemIsSelectable )
664662
665663 def updateNuclides (self ):
666664 applied_nuclides = []
0 commit comments