def body(self, master):
title = font.Font(self, size=TITLE_SIZE)
legend = {'anchor': W,
'justify': LEFT,
'font': font.Font(self, weight='bold')}
# Create all labels.
text = 'Cumulative score for\nprevious {}:'.format(self.level)
self.explanation = Label(master, text=text, font=title)
self.ruler_one = Label(master, text=(self.RULE * TEXT_WIDTH))
self.answers_right = Label(master, text='Answers right:', **legend)
self.display_right = Label(master, text=str(self.right))
self.answers_wrong = Label(master, text='Answers wrong:', **legend)
self.display_wrong = Label(master, text=str(self.wrong))
self.percent = Label(master, text='Percentage correct:', **legend)
percentage = str(int(100 * self.right / self.total + 0.5)) + '%'
self.display = Label(master, text=percentage)
self.ruler_two = Label(master, text=(self.RULE * TEXT_WIDTH))
# Display the results.
options = {'sticky': NSEW, 'padx': 5, 'pady': 5}
self.explanation.grid(row=0, column=0, columnspan=2, **options)
self.ruler_one.grid(row=1, column=0, columnspan=2, **options)
self.answers_right.grid(row=2, column=0, **options)
self.display_right.grid(row=2, column=1, **options)
self.answers_wrong.grid(row=3, column=0, **options)
self.display_wrong.grid(row=3, column=1, **options)
self.percent.grid(row=4, column=0, **options)
self.display.grid(row=4, column=1, **options)
self.ruler_two.grid(row=5, column=0, columnspan=2, **options)
评论列表
文章目录