可爱的 Python:Curses 编程
2007-03-29 11:59:25 来源:WEB开发网try 代码块执行一些初始化,调用 main() 函数来执行实际工作,然后执行最后的清除。如果出错, except 代码块会将控制台恢复成缺省状态,然后报告遇到的异常。
main() 事件循环
现在,我们研究 main() 函数,看看 curses_txt2html 做些什么:
curses_txt2html.py main() 函数和事件循环 def
main
(stdscr):
# Frame the interface area at fixed VT100 size
global
screen
screen = stdscr.subwin(23, 79, 0, 0)
screen.box()
screen.hline(2, 1, curses.ACS_HLINE, 77)
screen.refresh()
# Define the topbar menus
file_menu = (
"File",
"file_func()")
proxy_menu = (
"Proxy Mode",
"proxy_func()")
doit_menu = (
"Do It!",
"doit_func()")
help_menu = (
"Help",
"help_func()")
exit_menu = (
"Exit",
"EXIT")
# Add the topbar menus to screen object
topbar_menu((file_menu, proxy_menu, doit_menu,
help_menu, exit_menu))
# Enter the topbar menu loop
while
topbar_key_handler():
draw_dict()
更多精彩
赞助商链接