
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
OS menu shortcuts, correct taskbar behaviour, and environment activation for Python GUI apps
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:
.exe
on windows) that runs your application
conda
env or virtual environment, if any.desktop
file (Linux) to launch your
application from your desktop applications menuHere 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!]
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.
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.
FAQs
OS menu shortcuts, correct taskbar behaviour, and environment activation for Python GUI apps
We found that desktop-app demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Ā It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.