windows – 如何在Python cmd行应用程序上创建静态标题/边框
发布时间:2020-08-04 09:47:48 所属栏目: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) (编辑:莱芜站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows下不重启电脑使修改后的环境变量生效的方法
- 使用window.performance分析web前端性能
- 10053 您的主机中的软件中止了一个已建立的连接
- win7运行mapreduce报错Could not locate executable nullbi
- Windows 8 C# – 将网页源检索为字符串
- windows-phone-8 – Nokia Imaging SDK是否有硬件限制?
- windows-services – 监控单个窗口服务的性能
- 强制Xamarin在Windows上使用Mono
- jboss7.x – 无法登录到windows上的jboss 7.1管理控制台
- SFG_Window