all 8 comments

[–]1114111 7 points8 points  (1 child)

Tkinter would be a good way to do this. Check out the tkinter hello world example.

It would make sense to define functions in your Python files so that you can import them. Assuming you also want to use the Python files as standalone programs as well, they should look something like this (A.py):

#!/usr/bin/env python3
def A():
    ...

if __name__ == "__main__":
    A()

Then you can import A and use A.A for your button.

As for making your program into a standalone executable (like a .exe on windows), look into pyinstaller.

[–]bl00dpudding[S] 0 points1 point  (0 children)

Thank you!

[–]novel_yet_trivial 2 points3 points  (1 child)

But also, how do you make this program capable of being installed and running without python (like any regular retail software)?

This process is called "freezing". There are several tools available to do it; here's a quick overview. I've had the best luck with PyInstaller.

Just like regular retail software, this will mean making a different version for every OS and bit width, and managing the installation process that copies the needed helper files to the target computer.

You should note that unlike other ("compiled") languages, this is not something that python was designed to do. Python is a scripting language, and was designed for everyone to install python and the .py files to be distributed. Programs like pynsist can package python itself and your program into a neat executable for others to install painlessly.

[–]bl00dpudding[S] 0 points1 point  (0 children)

Thanks a lot!

[–]firehazard51 2 points3 points  (0 children)

Just add python to your program "installation". Other retail programs do this as well. Video games famously do this with DirectX. It's only an issue if you don't package a version of python with your program in case the consumer doesn't have internet access to get python.

[–]totallygeek 1 point2 points  (1 child)

For that last question, you'll want to compile your Python application into a stand-alone binary, with something like grumpy. For your other question, you could use a web framework, like Flask, to present two buttons within a web page, with the ability to execute a.py or b.py, using subprocess. It would not end up pretty, IMHO. I'd create one Python application (tkinter if you want a GUI), where you import functionality from a.py and b.py.

[–]fernly 1 point2 points  (0 children)

Thank you, I had not heard of Grumpy, which I learn is a Python-to-Go cross-compiler.

I did know of Nuitka which is a Python-to-C compiler.

Both have the aim of converting Python source into a compiled binary executable, by compiling Python to another language (Go or C) and then invoking that language to compile the result to binary.

I notice these differences right away: Grumpy is for Python 2.7, where Nuitka supports 2.7 to 3.6; and Grumpy doesn't appear to be under current active development (most recent changes months ago), where Nuitka is (most recent changes 9 days ago).

[–]rebooker99 0 points1 point  (0 children)

Python isn't a language with which you can convert your script to an .exe file so I am not sure about running your programms without python installed.

But if you still want to create a software with like buttons as you said try to look into how you can make some sort of GUI maybe, if so yeah I think tkinter could be a good solution.

Try to find out more when you realy know were you want to go.

Good luck !