0

I use Ubuntu.

Made a simple gui application in python using PyQt.

I can run this by using python interpreter as:

python application.py

I want to know whether is there any way to just run this application.py file by double-clicking on it as we do in windows(.exe files)!!!

Tarun Kumar
  • 1
  • 1
  • 2
  • 2
  • If you add `#!/usr/bin/env python` to the top of your script, you'll be able to run it directly (assuming you make the file executable). See e.g. http://stackoverflow.com/q/6908143/3001761 – jonrsharpe Feb 28 '15 at 09:37

3 Answers3

1

You can just drag a file onto your desktop from your file manager to copy it (or link it) to the desktop. That should create an icon for the file on your desktop in most Linux distros.

To allow the system to run your script you need to ensure that the script starts with a proper shebang line, eg

#!/usr/bin/env python

and that the file has execute permissions. Your file manager will have some menu command to modify file permissions. Or you can just do it in the shell with

chmod a+x application.py.

If you've created a link to your script on the desktop you'll need to modify the permissions of the original file, not the link, since links don't have permissions themselves.

Then you can single-click the icon to launch it.

PM 2Ring
  • 54,345
  • 6
  • 82
  • 182
0

Create a .desktop file like this and put it in /usr/share/applications/

[Desktop Entry]
Type=Application
Name=XChat Firefox
Exec=/usr/bin/your_script
Icon=/usr/share/icons/xchats_icon

found here: https://askubuntu.com/questions/60667/apply-icons-to-bash-scripts/60670#60670

Community
  • 1
  • 1
stukat
  • 66
  • 2
0

Check this link:

https://askubuntu.com/questions/761365/how-to-run-a-python-program-directly

You need to change how the file manager acts when you double click on executable files too.

Community
  • 1
  • 1
BuvinJ
  • 10,221
  • 5
  • 83
  • 96