用于轻松创建看起来像Linux顶级程序的文本接口的库。

topshape的Python项目详细描述


https://img.shields.io/pypi/v/topshape.svghttps://img.shields.io/travis/mchlumsky/topshape.svgDocumentation StatusUpdatesPython 3https://codecov.io/gh/mchlumsky/topshape/branch/master/graph/badge.svg

用于轻松创建看起来像Linux顶级程序的文本接口的库。

它建立在urwid之上,但不需要了解urwid本身。

快速启动

下面是一个如何使用topshape的示例:

fromtopshapeimportTopShape# The columns are a list (or tuple) of dictionaries. Each# dictionary defines a column in the bodycolumns=({'label':'header1'},{'label':'header2'},{'label':'header3'})# The body function will be passed as a callback that must# return a 2-dimensional array everytime it's called.defbody():return[[str(i*j)foriinrange(3)]forjinrange(10)]# The header function will be passed as a callback that must# return a string everytime it's called.defheader():return'This is the header!'# The footer function will be passed as a callback that must# return a string everytime it's called.deffooter():return'This is the footer!'defhandle_q(app):app.exit()defhandle_f(app,answer):# do something with the answer# ...# key_map maps keys pressed to callbackskey_map={'q':handle_q,'f':(handle_f,'Enter some text here:'}app=TopShape.create_app(columns,body,header,footer,key_mapping=key_map)app.run()

输出:

https://raw.githubusercontent.com/mchlumsky/topshape/master/docs/example1.png

输出(等待用户输入):

https://raw.githubusercontent.com/mchlumsky/topshape/master/docs/example1-1.png

还有一个更完整的例子here,它是linux top程序的克隆。

屏幕截图:

https://raw.githubusercontent.com/mchlumsky/topshape/master/docs/example2.png

学分

这个包是用Cookiecutteraudreyr/cookiecutter-pypackage项目模板创建的。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
文件名的java正则表达式限制名称大小和文件扩展名   Mac上的java Android SDK:jspawnhelper意外退出   java SQL Server 2000到Oracle 12c重音字符   在Java中快速比较大数据集中的值和小数据集中的值   java在代码中的许多地方保留对对象的引用   Java规范中私有内部类的jvm访问标志与反射API不一致?   比较2个int数组中匹配的数字   java Apache Commons数学简化回归:get prediction stderr   安卓 Java SDK管理器因命令行输出中的“flashplayerplugin”而崩溃   JavaSQLite:关闭DB时必须关闭游标吗?   泛型Java设计抽象类声明示例说明   java应用程序在添加片段时崩溃   如何在java中使用注释为字段加载值