Python的终端菜单?终端着色?终端进度显示? [英] Python Terminal Menu? Terminal Coloring? Terminal progress display?

查看:442
本文介绍了Python的终端菜单?终端着色?终端进度显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用Python(2 *口味)广泛的一个项目,我想知道是否有一个终端菜单库或东西的效果呢?我期待通过使用箭头键选择highlightable,一些颜色,等等等等,我依稀记得有一种存在方式,使一个bash shell的终端菜单简化了一些选项来呼吸一下风味和生活进入我的剧本,但我不所有知道我怎么会从bash的用户输入传递给python脚本,或者有一个bash终端菜单中按与sysarggs的脚本调用?我想在Python端如果可能的事情。有什么建议?

I have a project that uses Python (2.* flavors) extensively and I am wondering if there is a terminal menu library or something to that effect? I am looking to breathe some flavor and life into my script by simplifying some of the options using arrow key highlightable options, some color, etc etc. I vaguely recall there being a way to make a bash shell terminal menu but I'm not at all sure how I would pass user input from bash to the python script, perhaps have a bash terminal menu push the script call with sysarggs? I'd like something on the python side if possible. Any suggestions?

也只有一个随机问题,在那种适合在这里,因为我们是在终端美学的话题,什么是处理一个柜台的最好方法?我的脚本查找图像文件,那么当它找到一个它清除与子进程调用终端来清除,然后打印重新发现IE 10的图像,发现一个,清晰,打印发现11图像总形象,有时我的脚本作品REAL快,我觉得这利弊性能。思考?

Also just a random question, kind of fits in here since we're on the topic of terminal aesthetics, what's the best way to handle a counter? My script looks for image files, then when it finds one it clears the terminal with a subprocess call to clear and then prints the total images found again IE 10 images, find one, clear, print "11 images found", sometimes my script works REAL fast and I feel this detriments performance. Thoughts?

非常感谢大家,我爱堆栈溢出;)

Thanks so much everyone, I love stack overflow ;)

编辑 - 感谢所有的快速反应!我有很多选择来仔细考虑。我给大家一个给予好评,因为所有你的反应是有帮助的。我检查了所有当我回家的图书馆和尽量挑一个你一个答案取决于什么最好散列出来,希望我能接你的所有,但因为所有的答案都是相关的!大部分AP preciated乡亲。我会在我一次下班回家报到,并有机会获得一些编码;)

Edit - Thanks for all the quick responses! I have alot of options to mull over. I gave everyone an upvote because all of your responses are helpful. I will check out all the libraries when I get home and try to pick one of you for an answer depending on what hashes out the best, wish I could pick you all though because all of your answers are relevant! Much appreciated folks. I'll report back in once I get home from work and get a chance to get some coding in ;)

编辑2 - 一个澄清计数器/进度显示上,寻找一种方式来防止这种情况的时候,我脚本发现数千张图片的时间很短ammount的detrimenting的表现,这是真正的斩蟒...

Edit 2 - A clarification on the counter/progress display, looking for a way to keep this from detrimenting performance when my script finds thousands of images in a very short ammount of time, this is real chopped up python...

for each item in list:
    if item ends with .jpg
        cnt=cnt+1
        do stuff with image file
        subprocess.call('clear')
        print str(cnt)+" total images processed."

再次感谢!

推荐答案

有一个名为库 Urwid 可提供菜单和更多一些。我从来没有使用过严重的目的,但它的工作pretty罚款,上面有我的preliminary经验。它适用于UN * X系统只虽然。 (该项目页说,它工作在Cygwin下,但我从来没有尝试过。)

There's a library called Urwid that offers menus and some more. I never used it for serious purposes, but the it work pretty fine with my preliminary experiences on it. It works on Un*x systems only though. (The project page says it works under Cygwin, but I never tried.)

这篇关于Python的终端菜单?终端着色?终端进度显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆