![](https://i.ibb.co/wC9LxYw/Neutron-nobg.png)
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](https://github.com/IanTerzo/Neutron/blob/main/CONTRIBUTING.md).
## Installation
```
pip install neutron-web
```
## Example
For a template project see [TEMPLATE](https://github.com/IanTerzo/Neutron/tree/main/TEMPLATE) or see the [to-do app](https://github.com/IanTerzo/Neutron/tree/main/examples/todo-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), and the `HTMLElement` class, which is the base class for all HTML elements, as the javascript DOM Element object. The `HTMLElement` class supports most of the attributes the DOM Element object in JavaScript has but is still missing some methods. Ideally you should be able to use Neutron as you would use the JavaScript DOM api, altough there are some differences.
### Neutron features
```python
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.
```python
Window(title: str, css: str, position: Tuple[int, int], size: Tuple[int, int]) -> Window
```
Create a window.
```python
Window.run_javascript(javascript: str) -> str
```
Evaluate JavaScript code.
```python
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.
```python
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 throught 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
Raw data
{
"_id": null,
"home_page": null,
"name": "neutron-web",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python, HTML, CSS, GUI, desktop apps",
"author": "IanTerzo (Ian Baldelli)",
"author_email": "ian.baldelli@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/84/25/849f2645feb69c26bc7c3e109173f7950e910060cf162c51074e00efc780/neutron_web-0.5.tar.gz",
"platform": null,
"description": "\n![](https://i.ibb.co/wC9LxYw/Neutron-nobg.png)\n\nNeutron 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.\n\nYou can get started contributing via [CONTRIBUTING.md](https://github.com/IanTerzo/Neutron/blob/main/CONTRIBUTING.md).\n\n## Installation\n\n```\npip install neutron-web\n```\n\n## Example\nFor a template project see [TEMPLATE](https://github.com/IanTerzo/Neutron/tree/main/TEMPLATE) or see the [to-do app](https://github.com/IanTerzo/Neutron/tree/main/examples/todo-app).\n\n## Usage\nThe 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), and the `HTMLElement` class, which is the base class for all HTML elements, as the javascript DOM Element object. The `HTMLElement` class supports most of the attributes the DOM Element object in JavaScript has but is still missing some methods. Ideally you should be able to use Neutron as you would use the JavaScript DOM api, altough there are some differences.\n\n### Neutron features\n\n```python\nNeutron.event(function : Callable)) -> str\n```\nUse 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.\n\n```python\nWindow(title: str, css: str, position: Tuple[int, int], size: Tuple[int, int]) -> Window\n```\nCreate a window.\n\n```python\nWindow.run_javascript(javascript: str) -> str\n```\nEvaluate JavaScript code.\n\n```python\nWindow.display(file: str, html: str, pyfunctions: List[Callable], encoding: str) -> None\n```\nUsed 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.\n\n```python\nWindow.show() -> None / Window.close() -> None\n```\nShow and close the window.\n\n\n## Building your project\n\nTo build a Neutron project you first need pyinstaller, install pyinstaller throught 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.\n\n> **Note:** If you are on linux use \":\" instead of \";\"\n```\npyinstaller YOUR_PYTHON_FILE.py --noconsole --onefile --add-data=\"YOUR_HTML_FILE.html;.\" --add-data=\"YOUR_CSS_FILE.css;.\"\n```\n\nYou don't need to use `--add-data` if your project doesn't have a CSS or HTML file\n",
"bugtrack_url": null,
"license": null,
"summary": "Create modern cross-platform apps in Python using HTML and CSS",
"version": "0.5",
"project_urls": null,
"split_keywords": [
"python",
" html",
" css",
" gui",
" desktop apps"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7958e1da24849322cefd0991e1d533c7698a44125b5edd28842c928828ece685",
"md5": "e505f9aaac293687e88dfd56daf80814",
"sha256": "4936ae4bbb741cd3d52416f042d4a687caa49e4146c72f6fcaaca14eefebae01"
},
"downloads": -1,
"filename": "neutron_web-0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e505f9aaac293687e88dfd56daf80814",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9142,
"upload_time": "2025-01-05T01:22:32",
"upload_time_iso_8601": "2025-01-05T01:22:32.480538Z",
"url": "https://files.pythonhosted.org/packages/79/58/e1da24849322cefd0991e1d533c7698a44125b5edd28842c928828ece685/neutron_web-0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8425849f2645feb69c26bc7c3e109173f7950e910060cf162c51074e00efc780",
"md5": "408ca0744ed596fbc6041e0d444e797f",
"sha256": "bbb6aa69ecec3f93ddf437c7c3106ba19ffc35f6c24e047d16f90a24cf053808"
},
"downloads": -1,
"filename": "neutron_web-0.5.tar.gz",
"has_sig": false,
"md5_digest": "408ca0744ed596fbc6041e0d444e797f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8593,
"upload_time": "2025-01-05T01:22:35",
"upload_time_iso_8601": "2025-01-05T01:22:35.243514Z",
"url": "https://files.pythonhosted.org/packages/84/25/849f2645feb69c26bc7c3e109173f7950e910060cf162c51074e00efc780/neutron_web-0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-05 01:22:35",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "neutron-web"
}