'Run a pygame script created in pycharm using a clickable desktop icon [duplicate]

I'm a beginner using python and when I found out about pygame and how cool it was I immediately started learning it. I recently finished a simple game and I want to make a desktop icon that I can click to run the script rather than having to open pycharm and click the run button. If there is a way to just run the script by clicking a desktop icon that would be awesome. Any suggestions?



Solution 1:[1]

Welcome to Stack Overflow. There appear to be several packages that achieve this, but from this post, cx_Freeze seems to be easy to implement.

It creates an executable (.exe) from your Python code. Assuming you're using Windows, this should be the implementation:

from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(
    name="app_name",
    version="0.1",
    description="app_description",
    executables=[Executable("app_file.py", base=base)],
)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 y_arjun_y