diff options
| author | Saniya Maheshwari <saniya.mah@gmail.com> | 2022-06-08 23:44:03 +0530 |
|---|---|---|
| committer | Saniya Maheshwari <saniya.mah@gmail.com> | 2022-06-09 14:30:57 +0530 |
| commit | b559ae31409694df54ae3022793c1180fa4e4802 (patch) | |
| tree | 7d4748ca293c0a1c0ed0d4c8a98dc69b0316982e /docs/userguide | |
| parent | 8aa6700215bbb1394fa8c5e6aef41c4a16ee4f04 (diff) | |
| download | python-setuptools-git-b559ae31409694df54ae3022793c1180fa4e4802.tar.gz | |
Added 'GUI Scripts' section
- Made separate section for `gui_scripts`
- Added an example `hello_world()` function that can be invoked using
a GUI script entry point
- Added `setup.cfg`, `setup.py` and `pyproject.toml` configuration
snippets
- Added that running `hello-world` in the terminal will open up a GUI
window.
Diffstat (limited to 'docs/userguide')
| -rw-r--r-- | docs/userguide/entry_point.rst | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/docs/userguide/entry_point.rst b/docs/userguide/entry_point.rst index e39ae5c8..3f5e5261 100644 --- a/docs/userguide/entry_point.rst +++ b/docs/userguide/entry_point.rst @@ -104,9 +104,61 @@ where ``name`` is the name for the script you want to create, the left hand side of ``:`` is the module that contains your function and the right hand side is the object you want to invoke (e.g. a function). +GUI Scripts +=========== + In addition to ``console_scripts``, Setuptools supports ``gui_scripts``, which will launch a GUI application without running in a terminal window. +For example, if we have a project with the same directory structure as before, +with an ``__init__.py`` file containing the following: + +.. code-block:: python + + import PySimpleGUI as sg + + def hello_world(): + sg.Window(title="Hello world", layout=[[]], margins=(100, 50)).read() + +Then, we can add a GUI script entry point: + +.. tab:: setup.cfg + + .. code-block:: ini + + [options.entry_points] + gui_scripts = + hello-world = timmins:hello_world + +.. tab:: setup.py + + .. code-block:: python + + from setuptools import setup + + setup( + # ..., + entry_points={ + 'gui_scripts': [ + 'hello-world=timmins:hello_world', + ] + } + ) + +.. tab:: pyproject.toml (**EXPERIMENTAL**) [#experimental]_ + + .. code-block:: toml + + [project.gui-scripts] + hello-world = "timmins:hello_world" + +Now, running: + +.. code-block:: bash + + $ hello-world + +will open a small application window with the title 'Hello world'. .. _dynamic discovery of services and plugins: |
