Answers for "get terminal width python"

3

get terminal size python

import os

# you can do like this
columns, lines = os.get_terminal_size()

# or 
size = os.get_terminal_size()

columns = size.columns
lines = size.lines
Posted by: Guest on May-03-2021
1

python console width

import os
rows, columns = os.popen('stty size', 'r').read().split()
Posted by: Guest on September-01-2020
0

python set terminal size

If you install xdotool, you can change the size of the terminal window with something like this:

import subprocess
import shlex

id_cmd='xdotool getactivewindow'
resize_cmd='xdotool windowsize --usehints {id} 100 30'

proc=subprocess.Popen(shlex.split(id_cmd),stdout=subprocess.PIPE)
windowid,err=proc.communicate()
proc=subprocess.Popen(shlex.split(resize_cmd.format(id=windowid)))
proc.communicate()
Posted by: Guest on July-09-2021

Python Answers by Framework

Browse Popular Code Answers by Language