Page 1 of 1

why does Pygame script wait for ESC key press on auto start

Posted: Sun Dec 11, 2016 6:09 pm
by windy54
Hi,

I am currenty using Pixel.

We have created a script to let the user select a set of photos to be displayed via a set of buttons to be used in a local museum.
The script is based on pygame library.

if we run the script from a terminal window from the home directory by using a command
python StevesFolder/script.py
the script runs and goes straight to our first window and we can select and navigate through the menus.

We are currently trying to run the script on start up by editing /etc/profile and adding the following command at the bottom

sudo python /home/pi/StevesFolder/script.py

On power up we get a black screen until the escape key is pressed, then our first window is displayed and everything works.

We do not want to have a keyboard connected with the final product so has anyone got any idea as to what is happening?

We have also tried other approaches such as a sytemd file to get the script to run on power up, none of which have worked.

thanks

Steve

Re: why does Pygame script wait for ESC key press on auto st

Posted: Mon Dec 12, 2016 10:27 am
by paddyg
I have run into problems in the past getting python scripts to start up and tried all the solutions suggested by googling including sytemd (which I have never really got to work) and putting the python command inside a bash script and running that. However I'm not sure I tried to run anything with pygame in it. If you replace it with a simple dummy test script in your start up does it work ok. The last autostart project I did I used cron (but it was on jessie lite so didn't have to worry about starting the xserver) see here It was based in part on work by Tathros, he did want the xserver so might be a relevant approach.

Re: why does Pygame script wait for ESC key press on auto st

Posted: Tue Dec 13, 2016 11:31 am
by BBUK
Hi windy54.

Your problem does not look exactly like one that I was experiencing but try my solution here: http://stackoverflow.com/questions/1703 ... it-display

Have fun

BBUK

Re: why does Pygame script wait for ESC key press on auto st

Posted: Tue Dec 13, 2016 3:53 pm
by gordon77
I use this and no problems with pygame..

Put
@sudo /usr/bin/python /home/pi/filename.py
In
~/.config/lxsession/LXDE-pi/autostart