本文整理汇总了Python中view.View.create_menu方法的典型用法代码示例。如果您正苦于以下问题:Python View.create_menu方法的具体用法?Python View.create_menu怎么用?Python View.create_menu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类view.View
的用法示例。
在下文中一共展示了View.create_menu方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import create_menu [as 别名]
class Controller:
def __init__(self):
self.view = View()
self.serialize = Serialize()
def menu(self):
while True:
point = self.view.create_menu()
if point == 1:
self._calculate()
elif point == 2:
self.serialize.load()
elif point == 3:
data = self.view.change_serialization_file()
self.serialize.change_config(data[0], data[1])
elif point == 4:
break
def _calculate(self):
gender = self.view.read_gender()
weight = self.view.read_weight()
height = self.view.read_height()
age = self.view.read_age()
pa = self.view.read_pa()
model = Model(gender, weight, height, age, pa)
self.view.get_info(model.get_info())
data = (gender, weight, height, age, pa, model.calculate_calories())
input()
if self.view.is_dump():
self.serialize.dump(data)
示例2: __init__
# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import create_menu [as 别名]
class Controller:
def __init__(self):
self.view = View()
self.config = MyConfigParser()
self.sql_worker = SqlWorker(self.config.read_config())
def main(self):
try:
while True:
point = self.view.create_menu()
self.handler(operations[int((point-1) / 3)],
tables[(point-1) % 3])
input()
except TypeError:
self.view.show_exit()
def handler(self, operation, table_name):
if operation == "load":
if table_name == "pressure_data":
id = input("Enter id")
self.view.get_info(
self.sql_worker.load(table_name, id),
table_name
)
else:
self.view.get_info(
self.sql_worker.load(table_name),
table_name
)
elif operation == "add":
data = []
for i in table_data[table_name]:
point = input("Enter " + i + " : ")
data.append(point)
self.sql_worker.insert(table_name, data)
elif operation == "change":
data = []
id = input("Enter id")
for i in table_data[table_name]:
point = input("Enter " + i + " : ")
data.append(point)
self.sql_worker.update(table_name, id, data)
elif operation == "delete":
id = input("Enter id")
self.sql_worker.delete(table_name, id)
elif operation == "config":
for i in range(1, 4):
print("%d. %s" % (i, databases[i - 1]))
point = input()
self.config.change_config(databases[int(point) - 1])
self.sql_worker = SqlWorker(self.config.read_config())