如何用 Ruby 构建类似 top 的 UI
我想构建一个具有基于文本的 UI 的应用程序,类似于 Ruby 中的 Linux 命令“top”。 我可以使用哪些工具包和/或技术来构建 UI? 特别是,我想要控制台窗口的一个区域不断更新,并且能够按键来操作显示。
I want to build an application with a text based UI that is similar to the Linux command 'top', in Ruby. What toolkits and/or techniques can I use to build the UI? In particular I want an area of the console window that is constantly updating, and the ability to press keys to manipulate the display.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Ncurses 非常适合控制台应用程序,您可以找到多种语言的绑定(或者仅使用 shell 脚本)。 甚至还有一个被诅咒的 gtk (http://zemljanka.sourceforge.net/cursed/)我想这方面的工作已经停止了一段时间了。
你没有提到你的平台,但对于 OS/X 有一个很棒的小应用程序,名为 Geektool (http: //projects.tynsoe.org/en/geektool/),它允许您将脚本输出放在桌面上。 我使用一个小的 ruby 脚本来生成我的顶级进程列表:(
这可能会更好,但这是我编写的第一个 ruby 脚本,因为它有效,所以我从未重新访问它来改进它 - 并且不需要无论如何,它可能会帮助你提供一些想法)
Ncurses is great for console apps and you can find bindings for it for lots of languages (or just use shell scripting). There's even a cursed gtk (http://zemljanka.sourceforge.net/cursed/) though I think work on it stopped quite awhile back.
You didn't mention your platform, but for OS/X there's a great little app called Geektool (http://projects.tynsoe.org/en/geektool/) which allows you to put script output on your desktop. I use a small ruby script to generate my top processes list:
(This could probably be better, but it was the first ruby script I ever wrote and since it works I've never revisited it to improve it - and it doesn't take input. Anyway, it might help give you some ideas)
有关终端界面,请参阅 http://ncurses-ruby.berlios.de/
For a terminal interface, see http://ncurses-ruby.berlios.de/
有 stfl 但我不知道 ruby 绑定是否得到维护。 ncurses 可能是您最好的选择。
there's stfl but i don't know if the ruby bindings are maintained. ncurses is probably your best bet.