0

I want to achieve following:

run my GUI (made in Tkinter interface) application automatically as I boot the RPi (i.e. no desktop screen loading). But I want to be able kill the application so I can access the desktop though.

I have tried several methods which I found previously asked here, here and also here. I also played with adding my executable file in /home/pi/.config./autostart folder - no effect unfortunately.

I'm getting little desperate as this at first seemed as an easy task with lots of support online. However, after watching several tutorial, I have been stuck on this for days and cannot get it running properly.

What do I need to have it set in Boot Options (sudo raspi-config)?

Here is the code of the GUI app:

from Tkinter import *

root = Tk()
root.title('Scanner')

# create the top container
top_frame = Frame(root)
top_frame.pack( side = TOP )

scan_pcb=Label(top_frame,text='SCANNED CODE: ')
scan_pcb.grid(row=0,column=0)

pcb_entry=Entry(top_frame,background='white')
pcb_entry.grid(row=0,column=1)
pcb_entry.focus_set() 

# create the left container
left_frame = Frame(root)
left_frame.pack( side = LEFT )

A_label=Label(left_frame,text='A')
A_label.grid(row=0,column=0)
A_entry=Entry(left_frame,background='white')
A_entry.grid(row=0,column=1)

B_label=Label(left_frame,text='B')
B_label.grid(row=1,column=0)
B_entry=Entry(left_frame,background='white')
B_entry.grid(row=1,column=1)

C_label=Label(left_frame,text='C')
C_label.grid(row=2,column=0)
C_entry=Entry(left_frame,background='white')
C_entry.grid(row=2,column=1)

# create the right container
right_frame = Frame(root)
right_frame.pack( side = RIGHT )

D_label=Label(right_frame,text='D')
D_label.grid(row=0,column=2)
D_entry=Entry(right_frame,background='white')
D_entry.grid(row=0,column=3)

E_label=Label(right_frame,text='E')
E_label.grid(row=1,column=2)
E_entry=Entry(right_frame,background='white')
E_entry.grid(row=1,column=3)

E_label=Label(right_frame,text='F')
E_label.grid(row=2,column=2)
E_entry=Entry(right_frame,background='white')
E_entry.grid(row=2,column=3)

root.mainloop()

Here is the desktop shortcut text file:

[Desktop Entry]
Name=SCANNER
Comment=My application which does this
Icon=/home/pi/Desktop/scan.png
Exec=python /home/pi/Desktop/SCANNER.py
Type=Application
Encoding=UTF-8
Terminal=false
Categories=None;

Perhaps the methods mentioned in the links are outdated? Can anybody share relevant, precise and consise procedure for autorun boot, please?

Thank you very much.

Staflik
  • 3
  • 2

2 Answers2

1

Put the command line from your .desktop file into /home/pi/.config/lxsession/LXDE-pi/autostart or /etc/xdg/lxsession/LXDE/autostart, whichever you use on your system.

/home/pi/.config./autostart directory doesn't seem to exist or be used on Raspbian.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
1

From Raspberry Pi documentation:

Edit file /etc/rc.local sudo nano /etc/rc.local

Add your command bellow the comment, but leave the line exit 0 at the end of file.

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

python /home/pi/Desktop/SCANNER.py &

exit 0

Save. Make your script executable: sudo chmod 755 /home/pi/Desktop/SCANNER.py and restart Raspberry: sudo reboot now Your script should run after boot

Don't forget to add & after your command if your program will run in infinite loop.

Koxo
  • 151
  • 2