简体   繁体   中英

How to run a python program(containing tkinter) on startup

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?

Open /etc/profile and put this line at the bottom

sudo python /home/pi/projects/test.py

Source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM