单击桌面图标以在Raspbian中执行python脚本(Click desktop icon to execute python script in Raspbian)
我试图制作一个.bat或.exe文件来执行linux(Raspbian)中的python脚本。 我想在桌面上有一个点击(触摸屏)的图标,然后执行python脚本。
python脚本需要'sudo'授权...所以如果我想在终端中运行:
sudo python filelocation/name.py谢谢!
I am trying to make either a .bat or .exe file to execute a python script in linux (Raspbian). I would want to have an icon on the desktop which will be clicked (touch screen) and will then execute the python script.
The python script would need 'sudo' authorization... so if I wanted to run in terminal:
sudo python filelocation/name.pyThanks!
最满意答案
使用.desktop文件作为nodakai已经提到过。
要使用root权限执行python文件
使用像gksudo python program.py这样的东西。 这将在正常窗口中询问用户密码,不涉及终端。 如果不要求用户输入密码,请考虑sudoers文件中的条目,并使用通常的sudo python program.py 。 (如果使用此方法,请确保您的程序不允许用户执行他们想要的任何操作,但只能执行您希望用户能够以root用户身份执行的特定任务。)Use a .desktop file as nodakai already mentioned.
To have the python file executed with root permissions, either
use something like gksudo python program.py. This will ask the user for the password in a normal window, no terminal involved. if the user shall not be asked for a password, consider an entry in the sudoers file, and use the usual sudo python program.py. (If you use this, make sure your program doesn't allow the user to do whatever they want, but only does the specific tasks you want the user to be able to do as root.)更多推荐
发布评论