我找不到任何快速谷歌搜索,也没有在这里找到任何东西,为此省钱.但是,它没有做到这一点.那么究竟如何做您使用Python调整终端?
Kei*_*ith 16
要更改tty/pty设置,必须在stdin文件描述符上使用ioctl.
import termios
import struct
import fcntl
def set_winsize(fd, row, col, xpix=0, ypix=0):
winsize = struct.pack("HHHH", row, col, xpix, ypix)
fcntl.ioctl(fd, termios.TIOCSWINSZ, winsize)
Run Code Online (Sandbox Code Playgroud)
但是要更改实际窗口大小,您可以使用终端转义序列,但并非所有终端都支持或启用该功能.如果你正在使用urxvt,你可以这样做:
import sys
sys.stdout.write("\x1b[8;{rows};{cols}t".format(rows=32, cols=100))
Run Code Online (Sandbox Code Playgroud)
但这可能不适用于所有终端.
| 归档时间: |
|
| 查看次数: |
10001 次 |
| 最近记录: |