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.2.tar.gz (53.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

desktop_app-0.1.2-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

desktop_app-0.1.2-cp38-cp38-win_amd64.whl (21.5 kB view details)

Uploaded CPython 3.8Windows x86-64

desktop_app-0.1.2-cp38-cp38-win32.whl (21.0 kB view details)

Uploaded CPython 3.8Windows x86

desktop_app-0.1.2-cp37-cp37m-win_amd64.whl (21.4 kB view details)

Uploaded CPython 3.7mWindows x86-64

desktop_app-0.1.2-cp37-cp37m-win32.whl (21.0 kB view details)

Uploaded CPython 3.7mWindows x86

desktop_app-0.1.2-cp36-cp36m-win_amd64.whl (21.5 kB view details)

Uploaded CPython 3.6mWindows x86-64

desktop_app-0.1.2-cp36-cp36m-win32.whl (21.0 kB view details)

Uploaded CPython 3.6mWindows x86

File details

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

File metadata

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

File hashes

Hashes for desktop-app-0.1.2.tar.gz
Algorithm Hash digest
SHA256 96cb68ed514befb26825a4eea0f69174bfbd50ae31bed688658f1a6462421ff0
MD5 07dda6a2054b80c730e47bfbe3169b93
BLAKE2b-256 1af7bc1e61bbc1cbce8ac040de3bdfd68c77718609ceeb1daed5b8fab467ebd8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: desktop_app-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.9 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for desktop_app-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 182d3186a9edb4ae7fcddbfe232a751e17df2b1417f48ca894684c01611981f1
MD5 216eeb4b1f5f73848006ce9b88affb7a
BLAKE2b-256 c7adf3a70cc7fa33651a4bfe46793ef159e4a1f10c6fd37ebb97d9445e017a75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: desktop_app-0.1.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 21.5 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for desktop_app-0.1.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6c88ead16b2834034a34e50ef35fde3ff6c693772892048f13274c79f8a42bf1
MD5 431821dafc6b298e5ff7bf56c0ee36c2
BLAKE2b-256 b649d897c693e483be790fdc9ec57076cda05fa0f286792c73bfca35374bad3e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: desktop_app-0.1.2-cp38-cp38-win32.whl
  • Upload date:
  • Size: 21.0 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for desktop_app-0.1.2-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 0502a6c6501ef7d67a715de58310d16b86b409bc852c3f22a4b7614a89466142
MD5 14fbea58bf8eb7c129d832ceb9bd5429
BLAKE2b-256 135f4d5378514fdfeb62f3408a2e05987f85068b846a423e639ffb731ac1c705

See more details on using hashes here.

File details

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

File metadata

  • Download URL: desktop_app-0.1.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 21.4 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for desktop_app-0.1.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 d9e19614ae5c560b1832cb171fc1acad2d35688e0bd2de7981e68dc7d91fe78e
MD5 65fc5086e1d4f5ca3f79b6a7db1318a9
BLAKE2b-256 72df403ad9bb87e05b78b3ec781f56ad3a1d4e04475fbdd0a05a53b119e4b6d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: desktop_app-0.1.2-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 21.0 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for desktop_app-0.1.2-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 a1e671d175c83216dbe5c8ec1fd25c41ce6c7264fada3579dfbe53bf0efcead0
MD5 9645e5e9496f1211d2eb9a42e7e3eb1a
BLAKE2b-256 4864eafff802372e3848d316bdc72b3b43ebda4146b7903c693e291df565ed73

See more details on using hashes here.

File details

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

File metadata

  • Download URL: desktop_app-0.1.2-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 21.5 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for desktop_app-0.1.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 958238f7606d087819bd31b21c16c047467a21b6a320b0eb2ff3c908e2143b17
MD5 4c2aacfc342a922216ff5340b0a670e4
BLAKE2b-256 00cbbce52ebc8732e8291b188e25f4442554573d8a10fbba2a1a7b9528daa4f5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: desktop_app-0.1.2-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 21.0 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for desktop_app-0.1.2-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 fdb19cf19b5fcb01fc3fc40d0ce6332e6a4bbfccd099ae7bb27e7deb06bd7732
MD5 9dc7947b133623a5ad015c1b07080077
BLAKE2b-256 835e667c8ca4f25320790e7d0137d3d86f67aaab357c481ae0009018191c647e

See more details on using hashes here.

Supported by

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