python cmd窗口 title_windows – 如何在Python cmd行应用程序上创建静态标题/边框

检查

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, 0, -1)

curses.init_pair(2, 1, -1)

curses.init_pair(3, 2, -1)

curses.init_pair(4, 3, -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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值