windows – 如何在Python cmd行应用程序上创建静态标题/边框
发布时间:2020-08-04 20:08:10 所属栏目:Windows 来源:互联网
导读:我正在使用 Python cmd模块来创建CLI应用程序.一切都很棒!但是,我正在尝试将应用程序定制为某种类型的存在:文本颜色,标题,使用字母数字字符作为边框等. 有没有一种标准的方法来创建屏幕溢出的类型:我设置边框和颜色标题的屏幕顶部保持静态?从屏幕中间或其
|
我正在使用 Python cmd模块来创建CLI应用程序.一切都很棒!但是,我正在尝试将应用程序定制为某种类型的存在:文本颜色,标题,使用字母数字字符作为边框等. 有没有一种标准的方法来创建屏幕溢出的类型:我设置边框和颜色标题的屏幕顶部保持静态?从屏幕中间或其左侧,一直到屏幕底部,在提示符处输入的任何文本或命令将在到达标题/边框时停止显示.基本上,我所追求的是用户总是看到标题/边框,除非他们退出CLI应用程序.如果他们输入帮助,他们当然会看到标题/边框下方的命令.但是,当他们输入命令时,理想情况下,命令菜单将在屏幕标题/边框后面消失. 我能够实现这一目标的最佳方向是值得赞赏的. 检查 curses您应该能够使用颜色和静态边框来装饰CLI /终端. 我从HERE获得了扩展的例子: import curses
from multiprocessing import Process
p = None
def display(stdscr):
stdscr.clear()
stdscr.timeout(500)
maxy,maxx = stdscr.getmaxyx()
curses.newwin(2,maxx,3,1)
# invisible cursor
curses.curs_set(0)
if (curses.has_colors()):
# Start colors in curses
curses.start_color()
curses.use_default_colors()
curses.init_pair(1,curses.COLOR_RED,-1)
stdscr.refresh()
curses.init_pair(1,-1)
curses.init_pair(2,1,-1)
curses.init_pair(3,2,-1)
curses.init_pair(4,-1)
bottomBox = curses.newwin(8,maxx-2,maxy-8,1)
bottomBox.box()
bottomBox.addstr("BottomBox")
bottomBox.refresh()
bottomwindow = curses.newwin(6,maxx-4,maxy-7,2)
bottomwindow.addstr("This is my bottom view",curses.A_UNDERLINE)
bottomwindow.refresh()
stdscr.addstr("{:20s}".format("Hello world !"),curses.color_pair(4))
stdscr.refresh()
while True:
event = stdscr.getch()
if event == ord("q"):
break
def hang():
while True:
temp = 1 + 1
if __name__ == '__main__':
p = Process(target = hang)
curses.wrapper(display) (编辑:日照站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- libglog.dll CMake 在Windows上编译、应用glog
- 记忆管理 – WinRT是否有垃圾收集?
- windows – sqlite3-ruby gem:无法构建gem本机扩展名
- 是卸载/重新安装在Windows 7上更新PyCharm的最佳方法吗?
- windows – C try-catch块没有捕获硬件异常
- windows – sysopen权限被拒绝
- windows – 在matlab中监视内存
- 惊艳的cygwin——Windows下的Linux命令行环境的配置和使用
- xaml – Windows 8 App,更改BackButtonStyle的颜色
- windows – 如何使wget正确安静?
推荐文章
站长推荐
- win10下安装PyQt4
- NonSerialized 字段如果在dll 中读到数据写入Mon
- 从Windows文件夹到Linux分区
- Windows环境下安装MySQL5.7及MySQL WrokBench
- windows – Eclipse颜色主题和OS LF
- Windows AD域通过组策略设置域用户登录和注销脚本
- windows-store-apps – 查看Windows开发人员中心
- windows-phone-7 – 谁在Windows Phone 7中设置了
- libglog.dll CMake 在Windows上编译、应用glog
- .net – System.Diagnostics.EventLog – 连接到
热点阅读
