![](https://i.ibb.co/wC9LxYw/Neutron-nobg.png)
Neutron allows developers to build native Python apps along with CSS and HTML for frontend design. Based on [pywebview](https://github.com/r0x0r/pywebview) for it's native GUI window and JavaScript-Python communication.
You can get started contributing via [CONTRIBUTING.md](https://github.com/IanTerzo/Neutron/blob/main/CONTRIBUTING.md) or **you can message me** on discord (**IanTheThird#9732**) if you want more insigths on the code and tips on what to contribute.
## Installation
```
pip install neutron-web
```
## 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
## Examples
### Full example
For a fully set up example project see [TEMPLATE](https://github.com/IanTerzo/Neutron/tree/main/TEMPLATE). The project is build how it's intended, meaning it has a CSS and HTML file for the design and a Python file for the logic. (It is comparable to how websites using JavaScript are built).
### Other examples
Althought not recommended for big projects, it's possible to create an app using only a Python file.
```py
import Neutron
win = Neutron.Window("Example")
HeaderObject = Neutron.elements.Header(win, id="title", content="Hello")
def setName():
HeaderObject.setAttribute("style", "color: red;")
HeaderObject.innerHTML = "Hello world!"
win.getElementById("submit").innerHTML = "clicked!"
Neutron.elements.Button(win, id="submit", content="Hi", onclick=Neutron.event(setName))
win.show()
```
Another example featuring in-python HTML:
```py
import Neutron
win = Neutron.Window("Example")
def setName():
name = win.getElementById("inputName").value
win.getElementById("title").innerHTML = "Hello: " + name
win.display(f"""
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
</head>
<body>
<h1 id="title">Hello: </h1>
<input id="inputName">
<button id="submitName" onclick="setName()">Submit</button>
</body>
</html>
""", pyfunctions=[setName]) # Link up any Python functions so that they can be used inside the HTML
win.show()
```
### Loader
To resolve slow loading times for bigger projects, Neutron features a loader system seen here:
```py
import Neutron
win = Neutron.Window("Example", size=(600,100))
# The loader covers while all the other elements and css loads
win.loader(content="<h1>Loading App...</h1>", color="#fff", after=lambda: win.toggle_fullscreen())
```
### Multiple windows
To create another window for example when a fuction is called you need to use the `childwindow` property.
```
def createNewWindow():
win = Neutrontest.Window("Example", size=(600, 100), childwindow=True)
win.display(file="secondwindow.html")
win.show()
```
Raw data
{
"_id": null,
"home_page": "",
"name": "neutron-web",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python,HTML,CSS,GUI,desktop apps",
"author": "IanTerzo (Ian Baldelli)",
"author_email": "ian.baldelli@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/61/5d/c8e016d5ddb904dcc7c4521552066ac92e26ac69743b0801f2ee837a01d4/neutron-web-0.3.1.tar.gz",
"platform": null,
"description": "\n![](https://i.ibb.co/wC9LxYw/Neutron-nobg.png)\n\n\n\nNeutron allows developers to build native Python apps along with CSS and HTML for frontend design. Based on [pywebview](https://github.com/r0x0r/pywebview) for it's native GUI window and JavaScript-Python communication.\n\n\n\nYou can get started contributing via [CONTRIBUTING.md](https://github.com/IanTerzo/Neutron/blob/main/CONTRIBUTING.md) or **you can message me** on discord (**IanTheThird#9732**) if you want more insigths on the code and tips on what to contribute. \n\n## Installation\n\n\n\n```\n\npip install neutron-web\n\n```\n\n\n\n## Building your project\n\n\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\n\n> **Note:** If you are on linux use \":\" instead of \";\"\n\n```\n\npyinstaller YOUR_PYTHON_FILE.py --noconsole --onefile --add-data=\"YOUR_HTML_FILE.html;.\" --add-data=\"YOUR_CSS_FILE.css;.\"\n\n```\n\n\n\nYou don't need to use `--add-data` if your project doesn't have a CSS or HTML file\n\n\n\n## Examples\n\n\n\n### Full example\n\n\n\nFor a fully set up example project see [TEMPLATE](https://github.com/IanTerzo/Neutron/tree/main/TEMPLATE). The project is build how it's intended, meaning it has a CSS and HTML file for the design and a Python file for the logic. (It is comparable to how websites using JavaScript are built).\n\n\n\n### Other examples\n\n\n\nAlthought not recommended for big projects, it's possible to create an app using only a Python file.\n\n```py\n\nimport Neutron\n\n\n\nwin = Neutron.Window(\"Example\")\n\n\n\nHeaderObject = Neutron.elements.Header(win, id=\"title\", content=\"Hello\")\n\n\n\n\n\ndef setName():\n\n HeaderObject.setAttribute(\"style\", \"color: red;\")\n\n HeaderObject.innerHTML = \"Hello world!\"\n\n win.getElementById(\"submit\").innerHTML = \"clicked!\"\n\n\n\n\n\nNeutron.elements.Button(win, id=\"submit\", content=\"Hi\", onclick=Neutron.event(setName))\n\n\n\nwin.show()\n\n```\n\n\n\nAnother example featuring in-python HTML:\n\n```py\n\nimport Neutron\n\n\n\nwin = Neutron.Window(\"Example\")\n\n\n\ndef setName():\n\n name = win.getElementById(\"inputName\").value\n\n win.getElementById(\"title\").innerHTML = \"Hello: \" + name\n\n\n\n\n\nwin.display(f\"\"\"\n\n\n\n<!DOCTYPE html>\n\n<html>\n\n <head lang=\"en\">\n\n <meta charset=\"UTF-8\">\n\n </head>\n\n <body>\n\n <h1 id=\"title\">Hello: </h1>\n\n <input id=\"inputName\">\n\n <button id=\"submitName\" onclick=\"setName()\">Submit</button>\n\n </body>\n\n</html>\n\n\"\"\", pyfunctions=[setName]) # Link up any Python functions so that they can be used inside the HTML\n\nwin.show()\n\n```\n\n### Loader \n\n\n\nTo resolve slow loading times for bigger projects, Neutron features a loader system seen here:\n\n```py\n\nimport Neutron\n\n\n\nwin = Neutron.Window(\"Example\", size=(600,100))\n\n\n\n# The loader covers while all the other elements and css loads\n\nwin.loader(content=\"<h1>Loading App...</h1>\", color=\"#fff\", after=lambda: win.toggle_fullscreen())\n\n\n\n```\n\n### Multiple windows\n\n\n\nTo create another window for example when a fuction is called you need to use the `childwindow` property. \n\n```\n\ndef createNewWindow():\n\n win = Neutrontest.Window(\"Example\", size=(600, 100), childwindow=True)\n\n win.display(file=\"secondwindow.html\")\n\n win.show()\n\n```\n\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Create modern cross-platform apps in Python using HTML and CSS",
"version": "0.3.1",
"split_keywords": [
"python",
"html",
"css",
"gui",
"desktop apps"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "ca8bf189c73311b401831f04e6f86c5d",
"sha256": "2376a257ab2d7c50fd5fafc58da00373607921e25bc082a592f317cf79e00ad9"
},
"downloads": -1,
"filename": "neutron_web-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ca8bf189c73311b401831f04e6f86c5d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10757,
"upload_time": "2022-12-21T16:02:08",
"upload_time_iso_8601": "2022-12-21T16:02:08.892469Z",
"url": "https://files.pythonhosted.org/packages/41/29/99a99cc363596c4c650341a0cda4b1422fe0a3dd893dff025ed213f717a2/neutron_web-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "bdce0506bb71f6540721c7600ade9e34",
"sha256": "038c3c065aa41b6769b3619883be3a7f5b56434eb8d4d44ed4283adcabbd4e42"
},
"downloads": -1,
"filename": "neutron-web-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "bdce0506bb71f6540721c7600ade9e34",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9556,
"upload_time": "2022-12-21T16:02:10",
"upload_time_iso_8601": "2022-12-21T16:02:10.560950Z",
"url": "https://files.pythonhosted.org/packages/61/5d/c8e016d5ddb904dcc7c4521552066ac92e26ac69743b0801f2ee837a01d4/neutron-web-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-21 16:02:10",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "neutron-web"
}