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

Uploaded Source

Built Distributions

desktop_app-0.3.0-cp310-cp310-win_amd64.whl (23.9 kB view details)

Uploaded CPython 3.10 Windows x86-64

desktop_app-0.3.0-cp310-cp310-win32.whl (23.4 kB view details)

Uploaded CPython 3.10 Windows x86

desktop_app-0.3.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl (34.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.24+ x86-64 manylinux: glibc 2.5+ x86-64

desktop_app-0.3.0-cp310-cp310-macosx_10_15_x86_64.whl (19.6 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

desktop_app-0.3.0-cp39-cp39-win_amd64.whl (23.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

desktop_app-0.3.0-cp39-cp39-win32.whl (23.4 kB view details)

Uploaded CPython 3.9 Windows x86

desktop_app-0.3.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl (34.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64 manylinux: glibc 2.5+ x86-64

desktop_app-0.3.0-cp39-cp39-macosx_10_15_x86_64.whl (19.6 kB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

desktop_app-0.3.0-cp38-cp38-win_amd64.whl (23.9 kB view details)

Uploaded CPython 3.8 Windows x86-64

desktop_app-0.3.0-cp38-cp38-win32.whl (23.4 kB view details)

Uploaded CPython 3.8 Windows x86

desktop_app-0.3.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl (34.8 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.24+ x86-64 manylinux: glibc 2.5+ x86-64

desktop_app-0.3.0-cp38-cp38-macosx_10_15_x86_64.whl (19.6 kB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

desktop_app-0.3.0-cp37-cp37m-win_amd64.whl (23.9 kB view details)

Uploaded CPython 3.7m Windows x86-64

desktop_app-0.3.0-cp37-cp37m-win32.whl (23.4 kB view details)

Uploaded CPython 3.7m Windows x86

desktop_app-0.3.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl (35.9 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.24+ x86-64 manylinux: glibc 2.5+ x86-64

desktop_app-0.3.0-cp37-cp37m-macosx_10_15_x86_64.whl (19.6 kB view details)

Uploaded CPython 3.7m macOS 10.15+ x86-64

File details

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

File metadata

  • Download URL: desktop-app-0.3.0.tar.gz
  • Upload date:
  • Size: 57.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for desktop-app-0.3.0.tar.gz
Algorithm Hash digest
SHA256 616bb515a68c742cf681d7ff6881dac5c9f2ec944fe9d4748e7dac961d3145cd
MD5 a15b1f5814a32a47267332716175253b
BLAKE2b-256 a78135265f69a38a7def8800632660783f92c9088652c1ca3bc5ea36ae96ebe1

See more details on using hashes here.

File details

Details for the file desktop_app-0.3.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for desktop_app-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d16c7e4e11b41d8eed7fb82142b3adff121a103e7903a7f0d267ad628e1fb708
MD5 8170ecf399071312326e87a3e5b2c7b9
BLAKE2b-256 a98d403f5456650cfdecf480b9e342764fc2a5f6ab3de5dfdfe50db8c3f1640b

See more details on using hashes here.

File details

Details for the file desktop_app-0.3.0-cp310-cp310-win32.whl.

File metadata

  • Download URL: desktop_app-0.3.0-cp310-cp310-win32.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for desktop_app-0.3.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 9155004c1fe18f21b577957a3ae16a5055ec0b2b9e19ad11e2d818ca56a27f41
MD5 81f82783f0175573979577de7cd24350
BLAKE2b-256 578ef2eb7a0e40d52b04cd741118cff0e58882f77025c56a2006eee74f23d416

See more details on using hashes here.

File details

Details for the file desktop_app-0.3.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for desktop_app-0.3.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 6a918e8eeddcb358f998fd338efdf15670a83486a77c57a6b39a1f689ccaccbe
MD5 ddb8525918d3feb033bb2ede72e4c2a9
BLAKE2b-256 72e8e108f2a22950c74c5047d6f82523f98753df3dd37e98a03181cb73c5a3c8

See more details on using hashes here.

File details

Details for the file desktop_app-0.3.0-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for desktop_app-0.3.0-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ac9208cc51c4e53635e008d8d16bfad8ed188d074ebb3f9f07572f96fe981be6
MD5 5e0f5e2782641fc87544e07824722d70
BLAKE2b-256 86ec0cd0495376302cdcfbc8c477ba859b326738b526a052f87eff90d707e717

See more details on using hashes here.

File details

Details for the file desktop_app-0.3.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for desktop_app-0.3.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0e61330fb7dab4dfe8b3633df2a3d0f09316223f8a5ad8cbedadc7de8fa3f130
MD5 ec81a9566f2636ae4416fae9858ab75c
BLAKE2b-256 16b455f6f2d7ed38360b65cd0e2500b9c1b68d05fff8eb6fb8cbd6862739c7a8

See more details on using hashes here.

File details

Details for the file desktop_app-0.3.0-cp39-cp39-win32.whl.

File metadata

  • Download URL: desktop_app-0.3.0-cp39-cp39-win32.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for desktop_app-0.3.0-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 87273eff59b4227ba9d36b296dc043e012a4d7e54bcb238d2aa79330d8656244
MD5 19545d8ec5a8e2182b12f6fd54acb39c
BLAKE2b-256 e0a820bc600fef90eeb3fbb5234785e869a0e00ad7272c71c6d65633336961d3

See more details on using hashes here.

File details

Details for the file desktop_app-0.3.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for desktop_app-0.3.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 7c6e936813f08dbcc86d6d2f57fc8da782259d3e2f2f7febbecf6fbd68879292
MD5 990535557f52006d97bfde640d7d9b87
BLAKE2b-256 2e913b6290a28abf2b5f5f7e767ad4e6f0b0db4fde621d25d2d848e8b657e338

See more details on using hashes here.

File details

Details for the file desktop_app-0.3.0-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for desktop_app-0.3.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 8503d79b85594bc5440a93347f2ded23bceb0816173e0efa9cb24ac5ffce5511
MD5 5e0e1f8e36622b38b8df2c17da5e02b6
BLAKE2b-256 0fbb4cc7c6bc2f884226fd4866bf82c16a5769bdf8a69b56c68531f6f36f82ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for desktop_app-0.3.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0bec8f89e732ff7a14b149d8d99d3cfa0f5764bdd28e37652b15c47b9ba945d8
MD5 d3d32fa4ea6219feb2c3f309e586d3e1
BLAKE2b-256 67f9461e7b1841b4923a9763a3286bed588797d052ec23c536839c2facacf5c7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: desktop_app-0.3.0-cp38-cp38-win32.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for desktop_app-0.3.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 c8753cc0462871ba0816b4fc767d3c62c030955eeb1d085588e2035441a48c49
MD5 7dd87f226b98c61e8b662044e68040ba
BLAKE2b-256 3f8dafcc23d3455a328581593ad090360715e745fc4f490e51c39330ec3c4470

See more details on using hashes here.

File details

Details for the file desktop_app-0.3.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for desktop_app-0.3.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 d06f33688bf5c343302edd1d50ead094ec552634522268e5ee0e95338257066b
MD5 2ef87c60d64ee89648dbd3b7ca7f3d6f
BLAKE2b-256 cac00c2cebefbf269700e3b8a17d68cad5ebbf0c8f0dc01f13aabd94693ba3a1

See more details on using hashes here.

File details

Details for the file desktop_app-0.3.0-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for desktop_app-0.3.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 977b53a0211b4bce03ba40dd897fa8dc42deb28842bd9a996f80545594d16a02
MD5 0c11e76e320a12acf901c32c75db0c18
BLAKE2b-256 57866cf779df758bb144d36e51986bf94fd51df54c246f604ddc4fb9fb7f53cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for desktop_app-0.3.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 9d5cc10cbde071d1f52d79f03c9ff47690ef861bcac6e7d461eac76ba3b19dc4
MD5 7d425ad8f16e21bc14078c5c4065a4b9
BLAKE2b-256 5e7b25337b9a5bb6a8192f1f346e871b46e785f3c97ae6bba868881a1ed8ac64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: desktop_app-0.3.0-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for desktop_app-0.3.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 3c4eb55117d12ed028997669a0045816fbe14f6c47d32aba1ca4fd248cdde8ef
MD5 bad44e5f34ac4cb64a5770d962ad8095
BLAKE2b-256 36504ba76fde8201b5db1cb2c1c6249279b5faf5a7bcf99bedda2c93c35b3ff3

See more details on using hashes here.

File details

Details for the file desktop_app-0.3.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for desktop_app-0.3.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 3fecc830ceaa7f4fd4dda035a7dc6ba667c1936726ce186277a7ad8f7788ae75
MD5 4c586ed985c92ce8657229a248706aeb
BLAKE2b-256 c282077e32fa4ab3788516b9870db2428ae4ab550fbcb9299e888038ce668644

See more details on using hashes here.

File details

Details for the file desktop_app-0.3.0-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for desktop_app-0.3.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e5ea9b3b3be3272a2b45992c5dfb25ca4094bf186e31d4da78298169aaa58a16
MD5 204af82d4e3e9e7f23fda95ff5ea0c0c
BLAKE2b-256 85c508b8d6a6912befeb3c6426c9f33195a12e3f9f275550fa583fe3c294599b

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