windy54
Posts: 86
Joined: Sat Dec 29, 2012 3:37 pm

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

Sun Dec 11, 2016 6:09 pm

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

User avatar
paddyg
Posts: 2529
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

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

Mon Dec 12, 2016 10:27 am

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.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

BBUK
Posts: 142
Joined: Tue Dec 18, 2012 10:34 am

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

Tue Dec 13, 2016 11:31 am

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

gordon77
Posts: 4992
Joined: Sun Aug 05, 2012 3:12 pm

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

Tue Dec 13, 2016 3:53 pm

I use this and no problems with pygame..

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

Return to “Python”