@@ -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,18 +503,11 @@ def selectTally(self, tally_label=None):
502503
503504 # scores
504505 self .score_map = {}
505- self .score_map .clear ()
506506 self .scoresListWidget .clear ()
507507
508- sorted_scores = sorted (tally .scores )
509- # always put total first if present
510- if 'total' in sorted_scores :
511- idx = sorted_scores .index ('total' )
512- sorted_scores .insert (0 , sorted_scores .pop (idx ))
513-
514- for score in sorted_scores :
508+ for score in tally .scores :
515509 ql = QListWidgetItem ()
516- ql .setText (score . capitalize () )
510+ ql .setText (score )
517511 ql .setCheckState (QtCore .Qt .Unchecked )
518512 if not spatial_filters :
519513 ql .setFlags (QtCore .Qt .ItemIsUserCheckable )
@@ -628,39 +622,29 @@ def updateScores(self):
628622 applied_scores .append (score )
629623 self .model .appliedScores = tuple (applied_scores )
630624
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 )
625+ with QtCore .QSignalBlocker (self .scoresListWidget ):
626+ if not applied_scores :
627+ # if no scores are selected, enable all scores again
628+ for score , score_box in self .score_map .items ():
629+ score_box .setFlags (QtCore .Qt .ItemIsUserCheckable |
630+ QtCore .Qt .ItemIsEnabled |
631+ QtCore .Qt .ItemIsSelectable )
632+ else :
633+ # get units of applied scores
634+ selected_units = _SCORE_UNITS .get (
635+ applied_scores [0 ], _REACTION_UNITS )
636+ # disable scores with incompatible units
637+ for score , score_box in self .score_map .items ():
638+ sunits = _SCORE_UNITS .get (score , _REACTION_UNITS )
639+ if sunits != selected_units :
640+ score_box .setFlags (QtCore .Qt .ItemIsUserCheckable )
641+ score_box .setToolTip (
642+ "Score is incompatible with currently selected scores" )
643+ else :
644+ score_box .setFlags (score_box .flags () |
645+ QtCore .Qt .ItemIsUserCheckable )
646+ score_box .setFlags (score_box .flags () &
647+ ~ QtCore .Qt .ItemIsSelectable )
664648
665649 def updateNuclides (self ):
666650 applied_nuclides = []
0 commit comments