python set terminal size

Solutions on MaxInterview for python set terminal size by the best coders in the world

showing results for - "python set terminal size"
Line
11 Apr 2018
1import os
2
3# you can do like this
4columns, lines = os.get_terminal_size()
5
6# or 
7size = os.get_terminal_size()
8
9columns = size.columns
10lines = size.lines
Nicolò
11 Apr 2016
1If you install xdotool, you can change the size of the terminal window with something like this:
2
3import subprocess
4import shlex
5
6id_cmd='xdotool getactivewindow'
7resize_cmd='xdotool windowsize --usehints {id} 100 30'
8
9proc=subprocess.Popen(shlex.split(id_cmd),stdout=subprocess.PIPE)
10windowid,err=proc.communicate()
11proc=subprocess.Popen(shlex.split(resize_cmd.format(id=windowid)))
12proc.communicate()