Skip to main content

Neutron is ment to be an intuative way of creating GUI applications using HTML, CSS and Python. It is built on top of PyQt6 and uses the QtWebEngine.

You can get started contributing via CONTRIBUTING.md.

Installation

pip install neutron-web

Example

For a template project see TEMPLATE or see the to-do app.

Usage

The Neutron api is designed to be very similar to the JavaScript DOM api. You can imagine the Window class as the document object in JavaScript (altough it is still missing a lot of features). Ideally you should be able to use Neutron as you would use the JavaScript DOM api, altough there are some differences.

Neutron features

Neutron.event(function : Callable)) -> str

Use this function when passing a python function to an event listener or javascript method that requires a callable as parameter. Return the new javascript "bridge" function as str.

Window(title: str, css: str, position: Tuple[int, int], size: Tuple[int, int]) -> Window

Create a window.

Window.run_javascript(javascript: str) -> str

Evaluate JavaScript code.

Window.display(file: str, html: str, pyfunctions: List[Callable], encoding: str) -> None

Used to parse your html code. You run it before showing the window. It takes a path to your htlm file or html code (if file is not provided), a list of python functions and an encoding. The encoding is the encoding of your html file. The python functions are the functions you want to able to directly call from your html file. See the to-do app example.

Window.show() -> None / Window.close() -> None

Show and close the window.

Building your project

To build a Neutron project you first need pyinstaller, install pyinstaller through pip: pip install pyinstaller. Then run the script below in your command prompt/terminal. You can also use other programs to build your project such as py2exe if you prefer.

Note: If you are on linux use ":" instead of ";"

pyinstaller YOUR_PYTHON_FILE.py --noconsole --onefile --add-data="YOUR_HTML_FILE.html;." --add-data="YOUR_CSS_FILE.css;."

You don't need to use --add-data if your project doesn't have a CSS or HTML file

Release files for neutron-web 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for neutron-web 0.5.1
File Interpreter ABI Platform
neutron_web-0.5.1-py3-none-any.whl Python 3 none any Details

Release files / neutron_web-0.5.1-py3-none-any.whl

Download URL neutron_web-0.5.1-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8ca0d6abda9028da47bd41e6b77e0551847c4ded40c575989d14435bd8ce996
BLAKE2b-256 checksum
How to use checksums
33844765905cf3e2ad407119a2e6477de60028e9cfe7f89fa92b57e4c978c4af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.5.1 This release

1 release file

0.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page