How to Run GUI Programs on Startup on Raspberry Pi
Create a new .desktop file in autostart directory:
sudo nano /etc/xdg/autostart/test.desktop
For running a python script on startup, type and save this into the file:
[Desktop Entry]
Name=PiCounter
Exec=/usr/bin/python3 /home/pi/Desktop/test.py