Actually,I have written a program in python using tkinter and GPIO .Making GPIO go high or low when i press the button widget on the screen created using tkinter.Now i want those switch to appear on my screen as soon as i power on my raspberry pi and it boots up.

1)I am using raspberry pi 2 model B

2)my program named tkinter.py is in '/home/pi/tkinter.py'

3)I have opened /etc/rc.local and placed 'sudo python /home/pi/tkinter.py &' but it didnt work

please provide me a solution which runs when raspberry pi boots up.Thank you

  • I don't know how to do what you want. The underlying problem is the program's standard input stream (stdin) and standard output stream (stdout) will not be what you expect. stdin will not be the keyboard and stdout will not be the screen. I believe they will be redirected (perhaps to /dev/null) by the init scripts.
    – joan
    Sep 15, 2015 at 11:37

2 Answers 2


As you've created a tkinter program, I'm assuming you're running it in X windows. So the question is more 2 questions:

  • How do you start X windows automatically on boot?
  • How do you start an app automatically when X windows starts?

To start X windows, you can enable "boot to desktop" from raspi-config.

To start an app automatically when X windows starts, add a line to /etc/xdg/lxsession/LXDE-pi/autostart. It should look something like:

@python /home/pi/tkinter.py
  • I have used the above line as u have mentioned ,but it is not working. .when i am using '@leafpad' and '@lxterminal' both of them got opened when the x windows boots but my program isn't running.I have also used '@/usr/bin/python /home/pi/tkinter.py'.please provide me a solution. thank u Oct 5, 2015 at 12:09

I found a helpful article here: Run a script on startup

But it sounds like you've tried the first option. Perhaps you need to make the script executable? Try the following :

chmod +x /home/pi/tkinter.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.