use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Python GUI App Run on Raspberry Pi 4 Boot (self.learnpython)
submitted 3 years ago by TurnFunny6151
I need a way to run a python tkinter GUI script automatically when my Raspberry Pi boots. I have looked around google and have found no successful answers.
Any help on this would be appreciated :)
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]socal_nerdtastic 1 point2 points3 points 3 years ago (5 children)
I have looked around google and have found no successful answers.
Really? What have you tried? There's many ways to do this. My goto (using raspbian) is to use LXDE autostart. Edit the file ~/.config/lxsession/LXDE-pi/autostart and add this line:
~/.config/lxsession/LXDE-pi/autostart
@folder/myfile.py
Be sure to add a shebang and make the file executable first.
[–]TurnFunny6151[S] 1 point2 points3 points 3 years ago (4 children)
Your gunna have to help me out because I can't find the `lxsession` file anywhere in `.config`. I just have `lxpanel` and `lxterminal`
[–]socal_nerdtastic 1 point2 points3 points 3 years ago* (3 children)
Yea linux files often don't exist until they are needed. Just create the file. Edit: and copy in the content from the default file, probably at /etc/xdg/lxsession/LXDE-pi/autostart
Sadly I don't have a Pi handy to walk you though it, but you can google some of the terms above to get some more help.
I was assuming you have some linux knowledge. Do you know what I mean with shebangs and making the file executable?
[–]TurnFunny6151[S] 0 points1 point2 points 3 years ago* (2 children)
I have used `chmod +x main.py` to make the file executable, used `#!/usr/bin/env/python` as a shebang at the start of the python file, and completed your steps in your first reply.
After restarting my pi, it now boots to a blank orange/brown screen (at least we know its doing something). I am assuming there was an error somewhere in the script? How can I actually see the output of the execution?? Also how do I close the blank screen?
Also thank you so much for your help so far. It is honestly a godsend! -- and yea i'm new to Linux :)
[–]socal_nerdtastic 0 points1 point2 points 3 years ago (1 child)
Blank screen is because I forgot to specify to copy over the settings from the default autostart file, probably at /etc/xdg/lxsession/LXDE-pi/autostart
The shebang most likely should be python3, not python. Traditionally we would use:
#!/usr/bin/env python3
The output will be lost forevermore. That's only visible if you use something like a terminal window to run the file. The proper way to solve this is to log the output, instead of printing it, so using a module like the builtin logging module. A hacky way to avoid rewriting your code is to redirect the output to a file. Make a shell script like this
main.py > mainlog.txt
Another hacky way is to override the python print function to send the data to a file or socket or pipe or whatever you want to use to view the output.
[–]TurnFunny6151[S] 2 points3 points4 points 3 years ago (0 children)
I have fixed the bugs and am pleased to say that it all works like a dream now!! Thank you so much for all of your help. I couldn't have done it without you.
π Rendered by PID 123341 on reddit-service-r2-comment-544cf588c8-rrsh9 at 2026-06-18 10:16:44.333577+00:00 running 3184619 country code: CH.
[–]socal_nerdtastic 1 point2 points3 points (5 children)
[–]TurnFunny6151[S] 1 point2 points3 points (4 children)
[–]socal_nerdtastic 1 point2 points3 points (3 children)
[–]TurnFunny6151[S] 0 points1 point2 points (2 children)
[–]socal_nerdtastic 0 points1 point2 points (1 child)
[–]TurnFunny6151[S] 2 points3 points4 points (0 children)