RDS
Posts: 776
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Is it possible to define size and position of shell window

Mon Mar 20, 2017 11:22 am

My Python 3 program displays it's output in the usual 'shell' window. I operate the Pi headless using the excellent VNC feature.

Is it possible to include some code in my program to specify the size and position of the shell window, within the Desktop screen?

User avatar
Paeryn
Posts: 2986
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Is it possible to define size and position of shell wind

Mon Mar 20, 2017 1:25 pm

RDS wrote:My Python 3 program displays it's output in the usual 'shell' window. I operate the Pi headless using the excellent VNC feature.

Is it possible to include some code in my program to specify the size and position of the shell window, within the Desktop screen?
The usual terminal program lxterminal doesn't have options for choosing it's position, only the size of the terminal window (in characters), but you could always call xdotool to move and resize the current active window.

At the start of your Python program call xdotool to move the current window (replace the 50 100 with the coordinates you want the top-left corner to be) and resize it to the specified size (replace 80 25 with the size you want in characters) with :-

Code: Select all

import os

os.system("xdotool getactivewindow windowmove 50 100 windowsize --usehints 80 25")
xdotool might need to be installed with apt-get, I can't remember if it's installed or not by default.
She who travels light — forgot something.

RDS
Posts: 776
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Is it possible to define size and position of shell wind

Mon Mar 20, 2017 4:57 pm

@Paeryn
Thank you, I will look at that.

Return to “Python”