'Resizing terminal window with python on linux

I have been unable to find a way to resize the terminal running linux with python 3.x I am on "Raspbian GNU/Linux 9 (stretch)"

I have only found ways to escape the terminal using character combinations, which does not work on some terminals.



Solution 1:[1]

You can try this line of code. It worked for me.

row = 20
col = 40
print('\x1b[8;{0};{1}t'.format(row, col), end='', flush=True)

Solution 2:[2]

You can try set_geometry() from wmctrl.py.

Otherwise you can rely on the wmctrl command directly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Md. HES
Solution 2 Diego Torres Milano