Skip to main content

OS menu shortcuts, correct taskbar behaviour, and environment activation for Python GUI apps

Project description

desktop-app

desktop-app simplifies making a Python GUI application install, launch, and behave in a standard way with respect to the application menus and the taskbar in Windows and Linux (Macos support planned).

If your application is a Python module runnable from the command line as python -m mymodule, then with minimal configuration desktop-app can:

  • Create a launcher script (or .exe on windows) that runs your application
    • after activating a conda env or virtual environment, if any
    • with a hidden console if on Windows
  • Install a start menu shortcut (Windows) or .desktop file (Linux) to launch your application from your desktop applications menu
  • Ensure your application appears in the taskbar with the correct name and icon, and can be pinned correctly.

Basic Usage

Here we'll follow the example in this repository for a module called oink, developed by Old MacDonald's Farm. Before Old MacDonald had heard of desktop-app, he had a package that looked like this:

.
├── oink
│   ├── __init__.py
│   └── __main__.py
└── setup.py

Where setup.py is:

from setuptools import setup

setup(
    name='oink',
    version='1.0',
    author='Old MacDonald',
    author_email="macdonald@eie.io",
    url='http://eie.io',
    packages=["oink"],
    setup_requires=['setuptools'],
)

__main__.py is:

import tkinter

root = tkinter.Tk()
root.geometry("300x300")
w = tkinter.Label(root, text="Oink!")
w.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
root.mainloop()

And __init__.py is empty.

After installing this package somewhere, MacDonald can run it from a terminal with python -m oink, and it shows a little window

[README still in progress!]

Reasons

Why a hidden console on Windows?

The usual recommendation to run Python GUI applications is with Pythonw.exe, which does not create a console window. However, when running under Pythonw.exe, a simple print() call will raise an exception, and certain low-level output redirection of subprocesses does not work due to the stdout and stderr filehandles not existing. Furthermore, some tools may create subprocesses that call cmd.exe, or Python.exe, briefly popping up console windows of their own since one doesn't already exist.

In order to be able to ignore these problems and code the same as you would with a console, in Windows the launcher script runs your application in a subprocess using Python.exe, but with the CREATE_NO_WINDOW flag so that the console exists, but is not visible.

Why activate environments?

Activating environments is not strictly necessary except when using conda on Windows, in which case some compiled extensions (notably, Qt libraries) cannot be imported unless the environment is active.

However, even on other platforms activating the environment simplifies running other programs that might be installed to the bin/Scripts directory of the virtual environment - calling code would otherwise have to manually find this directory and provide the full path to the programs it wants to run.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

desktop-app-0.1.3.tar.gz (54.0 kB view details)

Uploaded Source

Built Distributions

desktop_app-0.1.3-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

desktop_app-0.1.3-cp38-cp38-win_amd64.whl (21.9 kB view details)

Uploaded CPython 3.8 Windows x86-64

desktop_app-0.1.3-cp38-cp38-win32.whl (21.5 kB view details)

Uploaded CPython 3.8 Windows x86

desktop_app-0.1.3-cp37-cp37m-win_amd64.whl (21.9 kB view details)

Uploaded CPython 3.7m Windows x86-64

desktop_app-0.1.3-cp37-cp37m-win32.whl (21.4 kB view details)

Uploaded CPython 3.7m Windows x86

desktop_app-0.1.3-cp36-cp36m-win_amd64.whl (21.9 kB view details)

Uploaded CPython 3.6m Windows x86-64

desktop_app-0.1.3-cp36-cp36m-win32.whl (21.4 kB view details)

Uploaded CPython 3.6m Windows x86

File details

Details for the file desktop-app-0.1.3.tar.gz.

File metadata

  • Download URL: desktop-app-0.1.3.tar.gz
  • Upload date:
  • Size: 54.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for desktop-app-0.1.3.tar.gz
Algorithm Hash digest
SHA256 fbf62ac8a100a557c40f4549d4d56ebc85b517f97ef1193df06d1c71a56af4f3
MD5 3e6ae7e8dae0cb7f69aab30f1a11d620
BLAKE2b-256 75a1506b7a378562d45c245a1b60c181a2c50f9bb2c56f38503b9d91977dc174

See more details on using hashes here.

File details

Details for the file desktop_app-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: desktop_app-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for desktop_app-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5b94495e0750bdd6ffd651c7b8eccebf48488206516dde5ed852a1d400d86d65
MD5 82d8005ee70bd8cb838bb0d958a5d45a
BLAKE2b-256 a89c750fee1f1d6102fd672fb51445fe689dd39ddfe9a045128898b006323300

See more details on using hashes here.

File details

Details for the file desktop_app-0.1.3-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: desktop_app-0.1.3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for desktop_app-0.1.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a83c7b0eb96717b1ce9349527fa1bf3410c588fec33039416f35b3664568b6ff
MD5 8778d32bc9bab2e2ae7caadfb00c8a0a
BLAKE2b-256 59454712ba49e0063391b9fa44f9db90191ac97eeaf799f72e2c2461ca7bde7f

See more details on using hashes here.

File details

Details for the file desktop_app-0.1.3-cp38-cp38-win32.whl.

File metadata

  • Download URL: desktop_app-0.1.3-cp38-cp38-win32.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for desktop_app-0.1.3-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 0b06f917368c3cb8710402be74f6933c8c57cbc5b0c61a79ebdf98032e70f463
MD5 95de3946aa2c878813ab551b254bf391
BLAKE2b-256 81a99d34a2dda2f6e414551dfc2671f36664689168b40404cefee27f8827be36

See more details on using hashes here.

File details

Details for the file desktop_app-0.1.3-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: desktop_app-0.1.3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for desktop_app-0.1.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 534015dd41fbc824467595593b4b2ac1055c4a334d5f0153f11a5f6f487fef16
MD5 b35a92d2a7e10cbe0e5a96a46006352b
BLAKE2b-256 d8f10fd12d0b81344efac3f9626d63e9ec3a491d0b44758b69ae0594dbdfbd8f

See more details on using hashes here.

File details

Details for the file desktop_app-0.1.3-cp37-cp37m-win32.whl.

File metadata

  • Download URL: desktop_app-0.1.3-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for desktop_app-0.1.3-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 6303643c96ee667b1c0bea49bfd7c2eab0c33f88efc78d0b5b7738adc5fec241
MD5 7f345b118d3fe50b325f39bb302de7ba
BLAKE2b-256 2d7176f8bfe2c18b30598afc6151d848f29db4f8b0e4d8d6ffc96da8bce19451

See more details on using hashes here.

File details

Details for the file desktop_app-0.1.3-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: desktop_app-0.1.3-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for desktop_app-0.1.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 de69b144ee4209e322406626c693016c3b3ccdfd5efd67789e28c40eb0c8fba5
MD5 cdebb40f819d2b265c1212e4362e18ea
BLAKE2b-256 107961342f2fb2108ac3a5057acf06150b39eaf0df9cf4fe55ea0613abc29ae7

See more details on using hashes here.

File details

Details for the file desktop_app-0.1.3-cp36-cp36m-win32.whl.

File metadata

  • Download URL: desktop_app-0.1.3-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for desktop_app-0.1.3-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 0180c8a35714cf08000683d76f4d2243598d0607cf99dbdb85e074bd2106d057
MD5 ff4b5016153c724b3637e05ed8854b90
BLAKE2b-256 37f91be97a72a8ea951e3669f69ad5689fde4e005a5993820f11f5b787a982cb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page