How do I make a program written in python open with two clicks made an executable?

4

An example:

#!/usr/bin/python3
# coding: utf-8

# window.py

from gi.repository import Gtk

class App(Gtk.Window):
    def __init__(self):
        super(Gtk.Window, self).__init__(title='Hello World')
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_size_request(600, 400)
        self.set_keep_above(True)
        self.set_modal(True)
        self.set_icon_name('Hello World')
        self.set_deletable(True)
        self.set_opacity(1)
        self.set_skip_pager_hint(True)
        self.set_skip_taskbar_hint(False)
        self.set_auto_startup_notification(False)
        self.set_border_width(10)

main = App()
main.connect("delete-event", Gtk.main_quit)
main.show_all()
Gtk.main()

How do I open this script by giving two clicks as an executable?

    
asked by anonymous 19.01.2016 / 20:03

2 answers

4

For Windows, create a .bat file with content similar to this:

@echo off
python c:\teu_script.py %*
pause

You have to have python installed and the command python recognized.

Or you can create the executable from PyInstaller ( link )

In linux, you can add "shebang" at the beginning of your python script that will automatically be recognized as a python program:

#!/usr/bin/env python

You need to make the same script executable with the following command:

  

chmod + x your_script_python.py

    
19.01.2016 / 20:07
0

I use cx_freeze, this program creates the executable file, but when creating the file it is accompanied by other necessary files at the time of execution, in other words, a folder with a dll file + the executable is created. Unfortunately I could not merge all the files created into one.

I hope I have helped.

    
19.07.2017 / 11:20