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()時,如何使Servers()類中包含的繼承函數display()接收選項tuple和sub_menu =「Server Menu」字符串?Python類繼承函數和從子項傳遞參數
ncurses對這類事情有很多幫助,不是嗎? –