def on_enter(self): super().on_enter() score = highscore.get_score() if self.table: self._remove_old() self.table = [] self.font_top = {} self.font_top['font_size'] = self.fontsize self.font_top['bold'] = True self.font_top['font_name'] = _font_ self.font_label = {} self.font_label['font_size'] = self.fontsize self.font_label['bold'] = False self.font_label['font_name'] = _font_ Head_Pos = text.Label('', anchor_x='right', anchor_y='top', **self.font_top) Head_Name = text.Label('Name', anchor_x='left', anchor_y='top', **self.font_top) Head_Wave = text.Label('Wave', anchor_x='right', anchor_y='top', **self.font_top) self.table.append((Head_Pos, Head_Name, Head_Wave)) self.table.append((text.Label(''), text.Label(''), text.Label(''))) for i, entry in enumerate(score): pos = text.Label('%i. ' % (i + 1), anchor_x='right', anchor_y='top', **self.font_label) try: name = text.Label(entry[1].strip(), anchor_x='left', anchor_y='top', **self.font_label) except IndexError: print("highscore file broken") name = text.Label("Error", anchor_x='left', anchor_y='top', **self.font_label) wave = text.Label(entry[0], anchor_x='right', anchor_y='top', **self.font_label) self.table.append((pos, name, wave)) self._process_table()
def test_get_score(self): """Test whether get_score runs without error""" highscore.get_score()