开发者

How create an Executable file + Launcher in Ubuntu from a python script?

I have created a simple program in python. Now I want trasform this script in an executable program ( with hidden source code if possible ) and when I click 2 times on it, the program install itself on the ubuntu ( in the /usr/开发者_StackOverflow社区lib or /usr/bin I think ) and it will create a new launcher in the Application -> Game menu.

How can I do that ?


Closed-source? Meh. Well, you can compile python iirc, or simply use an obscusificator. But I recommend to open-source it ;-) The stuff you can double-click are .desktop files, for samples, see find /usr | grep desktop.


I can't help you with concealing the python source, however, the application launcher is a Desktop Entry file with a .desktop extension. Your installer would install that to the applications folder in one of the system XDG_DIRS such as /usr/share/ or /usr/local/share.

If you install your application's icon to a theme friendly location (such as /usr/local/share/icons/hicolor/<size>/apps/<your application name>.png) and install your executable to a location in PATH (often /usr/bin or /usr/local/bin) then you desktop entry file would not need absolute paths to the executable or icon.

As an example, let's take a python application called "myapp.py". Here is it's .desktop file:

[Desktop Entry]
Name=My Application
Type=Application
Exec=myapp.py
Icon=myapp

Then say the application is built with autotools (configure, make, make install) with the "default" build options in which prefix=/usr/local/share. The following files would be installed:

/usr/local/share/applications/myapp.desktop
/usr/local/share/icons/hicolor/16x16/apps/myapp.png
# same for sizes 22x22, 24x24, 32x32, 48x48, 64x64
# it's also a good idea to include a "scalable" svg icon
/usr/local/bin/myapp  
# ^ this is your python "executable"

After running update-desktop-database as root (or from your Makefile) then your application will have a launcher and a nice pretty icon.


use pyinstaller from pyinstaller.org

http://bytes.com/topic/python/insights/579554-simple-guide-using-pyinstaller

pyinstaller helloworld.py

creates 2 folders bin and dist

run your exec form dist folder like

./helloworld

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜