【发布时间】:2013-06-24 23:51:45
【问题描述】:
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" 字符串?
【问题讨论】:
-
ncurses 对这类事情有很大帮助,不是吗?
标签: python class inheritance