【发布时间】:2018-08-11 22:21:21
【问题描述】:
我目前正在尝试为我的程序运行一个小型控制台菜单。 我在 PyPi curses-menu 上找到了 curses-menu 模块并尝试了运气。
curses 菜单有一个 FunctionItem 调用 python 函数,但遗憾的是我在控制台上看不到输出。这是我的示例代码:
# Import the necessary packages
from cursesmenu import *
from cursesmenu.items import *
def hello(x):
print("Hello {}".format(x))
# Create the menu
menu = CursesMenu("Title", "Subtitle")
# Create some items
# A FunctionItem runs a Python function when selected
function_item = FunctionItem("Call a Python function", hello, [3])
# Once we're done creating them, we just add the items to the menu
menu.append_item(function_item)
# Finally, we call show to show the menu and allow the user to interact
menu.show()
hello 以 3 作为参数调用,它还创建输出,但我在控制台上看不到它,因为菜单仍然存在。
遗憾的是,我现在不知道该怎么办。如果有人能帮助我解决这个问题或告诉我一个更好的控制台菜单模块,我会很高兴。
【问题讨论】:
标签: python python-curses