简体   繁体   中英

Raspberry Pi: How can I kill an auto-started Tkinter UI?

I coded a simple Tkinter UI in python on my Raspberry Pi. By executing this python script the UI starts in full screen by using this code line.

Tk.attributes("-fullscreen", False)

Then I included an autostart of this script: For that reason I added the following line of code in the file "sudo nano /etc/profile"

sudo python /home/pi/myscript.py

Unfortunately, I forgot to program an "Exit-Button". Is there any way to close/kill this task?

kill $(pgrep -f myscript.py)

The -f / --full option to pgrep tells it to consider the whole command string, instead of just the binary name ( python ). pkill may have a similar option to avoid using a subshell, not sure.

Some other people here have suggested using the -9 flag to kill -- I wouldn't do this unless the process doesn't respond to a normal kill first.

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