windows – 如何在Python cmd行应用程序上创建静态标题/边框
发布时间:2020-12-13 21:27:19 所属栏目: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) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 使用Box Windows SDK v2库在C#桌面应用程序中对Box进行身份
- 在Windows上,绑定装载卷在docker-compose中的行为与docker
- windows – 当驱动器快满时,我可以安排发送电子邮件吗?
- windows-server-2008 – Windows 7 – 无法加入域.网络ID显
- windows – 如何强制重启而不是关机(XP)
- 在Windows上安装FFmpeg程序
- 权限 – 是否可以使用提升的权限打开基于控制面板的应用程序
- windows-server-2012 – 带有SSD本地驱动器的Windows Serve
- WSL2 启动速度好快,占用资源好少
- 文件上传——不为人知的木马上传大法
推荐文章
站长推荐
- windows-server-2003 – 是否可以在Windows Serv
- WPF窗口GotFocus / LostFocus
- win10家庭版升级专业版出现0x80070422错误
- windows-server-2008 – Windows Server 2008 R2
- windows-vista – 获取Vista Ultimate 64位的HDD
- 如何在Windows Server 2008 R2中关闭(禁用)Web代
- macos – 在Windows上使用Tycho构建的Eclipse RC
- Windows Azure – 以编程方式创建订阅
- 在远程Windows服务器上设置Git存储库?
- windows-phone-7 – 如何从代码中获取Windows Ph
热点阅读