def button_press(self, button, data):
"""Generic callback method for buttons (not key-presses!).
@button - button object instance that called the method,
@data - (string) additional data provided by calling button
instance, used to define what action should be taken.
"""
if data in self.config.get_boardlist().keys():
# Board button was pressed.
# If the board was entered from any view other than MOTD
# (e.g. other board view), pop the widget from stack, so
# pressing ESC will return to MOTD.
if not self.motd_flag:
del self.loop.Widget
self.motd_flag = False
self.help_flag = False
self.board.name = data
# Transfer control to BoardView instance.
BoardView(self.loop, self.config, self.board, self)
elif data == "back":
# Clear the help flag, to avoid bugs.
self.help_flag = False
# Go back, restore saved widgets from previous screen.
del self.loop.Widget
# Check if we're on the main screen to avoid bugs.
if self.loop.stack_len == 1:
self.motd_flag = True
elif data == "quit":
# Bai
raise ur.ExitMainLoop()
评论列表
文章目录