Skip to content Skip to sidebar Skip to footer

Tkinter Gui Does Not Run Properly When Auto Boot

this is my first time using Raspberry Pi 3 with Python Tkinter to make a GUI. I have written my script using Python. My code uses Raspberry Pi 3 GPIO 8 and GPIO 11 as inputs. I hav

Solution 1:

I have a tkinter GUI that boots on startup on my Raspberry Pi. I did it by adding it to autostart file.

First, make the script executable. Add

#!/usr/bin/python

as the first line of your python script.

Then use this command to make the file executable

chmod +x /home/pi/Desktop/test.py

Now you should be able to start your program without the "sudo python" prefix. Just typing /home/pi/Desktop/test.py in the terminal should boot your program.

Then open autostart file for editing with

nano /home/pi/.config/lxsession/LXDE-pi/autostart

and add

@/home/pi/Desktop/test.py

BTW: you are using "sudo" way to much. You should use sudo very rarely. If you edit user files with sudo you can screw up your file permissions, which leads to very strange bugs. You should need "sudo" when you are installing something, and that's about it.

Solution 2:

First of all a Hardware recommendation: sorry for quoting a german page but as shown here https://www.elektronik-kompendium.de/sites/raspberry-pi/1912111.htm your raspi 3 should have minimun a power supply from 5v and 2A but it would be perfect if it supports up to 3A. But thats just some side info.

For me this question PyQt: How to run GUI on Raspberry Pi desktop startup? helped me solving the GUI autostart problem.

Post a Comment for "Tkinter Gui Does Not Run Properly When Auto Boot"