使用 ncurses 修复页眉和页脚?
我第一次尝试 ncurses(通过 UniCurses for Python)。我正在尝试设计一个具有固定页眉和页脚的控制台应用程序,但文档并不清楚我将如何执行此操作。我会使用窗户吗?一个面板?还有别的事吗?我已经弄清楚如何为一串文本提供它自己的前景色和背景色,但不知道如何将其扩展到控制台窗口的整个长度。要了解我想要做什么,请查看这些 cmus 屏幕截图:
http://cmus.sourceforge。 net/#home
顶部的蓝色标题和底部的蓝色和白色页脚是我想要达到的目的。谢谢!
I'm trying out ncurses for the first time (via UniCurses for Python). I'm trying to design a console application with a fixed header and footer but the documentation isn't clear on how I would go about doing this. Would I use a window? A panel? Something else? I've figured out how to give a string of text it's own foreground and background colors, but don't know how to extend that for the entire length of the console window. For an idea of what I'm trying to do, look at these cmus screenshots:
http://cmus.sourceforge.net/#home
The blue header at the top and blue and white footer at the bottom is what i'm trying to get at. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,想通了。子窗口的救援:
可能有更好的方法来做到这一点,但它是一个解决方案。
Alright, figured it out. Sub-windows to the rescue:
There might be a better way to do this, but it's a solution.
使用Python Curses模块
初始化curses并给它一个颜色来使用
获取屏幕宽度和屏幕高度
创建具有终端颜色最大宽度的子窗口
标题标题背景和其中的文本
wtv你想要它说
显示一切
With Python Curses Module
initialize curses and give it a color to use
get screen width and screen height
create the subwindow header with the maximum width of terminal
color the header background and text within it
wtv you want it to say
show everything