def update(self):
self.button.destroy()
question = self.hat.ask_question()
if question is None:
self.result()
return
self.label.destroy()
self.label = tk.Label(text=question['question'], bg='black', fg='white')
self.label.grid(row=1, column=1)
self.sublabel.destroy()
self.sublabel = tk.Label(text='\n'.join(question['answers']),
bg='black', fg='white')
self.sublabel.grid(row=2, column=1)
for button in self.buttons:
button.destroy()
for i in range(len(question['answers'])):
button = tk.Button(self.button_frame, text=ascii_uppercase[i], highlightbackground='black',
command=partial(self.choose_answer, answer=ascii_uppercase[i]))
button.grid(row=0, column=i)
self.buttons.append(button)
评论列表
文章目录