class BaseMenu(object):
def display(self):
header = "FooBar YO"
term = getTerminalSize()
#sys.stdout.write("\x1b[2J\x1b[H")
print header.center(term, '*')
#print sub_menu.center(term, '+')
print "Please choose which option:"
for i in options:
print(
str(options.index(i)+1) + ") "
)
class Servers(BaseMenu):
def __init__(self):
#super(Servers, self).__init__("server")
pass
def list_foo(self):
pass
def list_bar(self):
pass
options = (
list_foo,
list_bar
)
尝试从 Main Menu -> Servers 子菜单开始制作一系列文本菜单。当 Servers() 从 BaseClass 继承 display() 时,如何使继承的函数 display() 接收 Servers() 类中包含的选项 tuple 和 sub_menu = "Server Menu" 字符串?