问题
I want to execute a simple python script that contain tkinter window on start up of raspberry pi. and the tkinter window will appear on the monitor. suppose my simple script is
import Tkinter
from Tkinter import *
root = Tk()
root.mainloop()
I have tried the following procedure and failed
mkdir ./bin
cd ./bin
sudo nano script_auto_run
then wrote the following code
#!/bin/bash
sudo python /home/pi/projects/test.py
to make it executable i ran
sudo chmod 755 script_auto_run
edited the rc.local file
sudo nano /etc/rc.local
and added the following line before exit0
/home/pi/bin/script_auto_run
what mistake am I doing?
回答1:
Open /etc/profile and put this line at the bottom
sudo python /home/pi/projects/test.py
Source
来源:https://stackoverflow.com/questions/29205616/how-to-run-a-python-programcontaining-tkinter-on-startup