Skip to content

Commit ff6fffe

Browse files
author
Kevin J Walters
committed
Rearranging the text setting for the summary Label on round results screen to set in constructor rather than later via property. This is neater but main motivation is to work around a Label y position bug.
1 parent 2612984 commit ff6fffe

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

CLUE_Rock_Paper_Scissors/advanced/rps_display.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,19 @@ def showPlayerVPlayerScreen(self, me_name, op_name, my_ch_idx, op_ch_idx,
707707

708708
pvp_group.append(s_group)
709709

710-
# max_glyphs is set to the maximum len of all the possible strings
711-
# the + 1 is workaround in case a buggy version of library is used
710+
if draw:
711+
sum_text = "Draw"
712+
elif win:
713+
sum_text = "You win"
714+
else:
715+
sum_text = "You lose"
716+
# Text starts invisible (BLACK) and color is later changed
712717
summary_dob = Label(self.font,
713-
text="",
714-
max_glyphs=8 + 1,
718+
text=sum_text,
715719
scale=3,
716720
color=BLACK)
721+
summary_dob.x = round((self.width
722+
- 3 * self.font_width * len(sum_text)) / 2)
717723
summary_dob.y = round(self.height - (3 * self.font_height / 2))
718724
pvp_group.append(summary_dob)
719725

@@ -742,15 +748,6 @@ def showPlayerVPlayerScreen(self, me_name, op_name, my_ch_idx, op_ch_idx,
742748

743749
if summary is not None:
744750
self.sample.play(summary)
745-
# max length of sum_text must be set in max_glyphs in summary_dob
746-
if draw:
747-
sum_text = "Draw"
748-
elif win:
749-
sum_text = "You win"
750-
else:
751-
sum_text = "You lose"
752-
summary_dob.text = sum_text
753-
summary_dob.x = round((self.width - 3 * self.font_width * len(sum_text)) // 2)
754751

755752
# Flash colours for win, fad up to blue for rest
756753
if not draw and win:

0 commit comments

Comments
 (0)