Name | pylon-desktop JSON |
Version |
0.2.2
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-10-04 13:55:10 |
maintainer | None |
docs_url | None |
author | aesthetics-of-record |
requires_python | <3.13,>=3.10 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Pylon 🏗️
Pylon is a framework that allows you to easily create desktop applications using Python and web technologies. 🐍🌐
## Key Features 🚀
- Web-based GUI generation
- System tray icon support 🖥️
- Multi-window management 🪟
- Bridge API between Python and JavaScript 🌉
- Single instance application support
## Installation 📦
### Direct Installation
```bash
pip install pylon-desktop
```
### Creating a React + Pylon Project
Boilerplate address: [https://github.com/python-pylon/pylon-react-boilerplate](https://github.com/python-pylon/pylon-react-boilerplate)
## Usage 🛠️
### Creating a Basic Application
```python
from pylon import PylonApp
app = PylonApp(single_instance=True, icon_path="assets/icon.ico")
window = app.create_window(
"https://www.example.com",
title="Pylon Browser",
)
app.run()
```
### Setting Up System Tray
```python
from pylon import TrayEvent
def on_double_click():
print("Tray icon was double-clicked.")
app.set_tray_actions({
TrayEvent.DoubleClick: on_double_click,
})
app.set_tray_menu_items([
{"label": "Show Window", "callback": app.show_main_window},
{"label": "Quit", "callback": app.quit},
])
app.setup_tray()
```
### Creating Python-JavaScript Bridge API
```python
from pylon import PylonAPI, Bridge
class CustomAPI(PylonAPI):
@Bridge(str, int, result=str)
def echo(self, message, number):
return f"Message received in Python: {message}, {number}"
@Bridge(result=str)
def getAppVersion(self):
return "1.0.0"
@Bridge(result=str)
def create_window(self):
window = app.create_window(
"alert.html",
js_apis=[CustomAPI()],
width=300,
height=200,
x=100,
y=100,
)
return window.id
window = app.create_window(
"index.html",
js_apis=[CustomAPI()],
# Other options...
)
```
```javascript
// CustomAPI method usage example
// Using the echo method
pylon.CustomAPI.echo('Hello', 42).then((result) => {
console.log(result); // "Message received in Python: Hello, 42" output
});
// Using the getAppVersion method
pylon.CustomAPI.getAppVersion().then((version) => {
console.log('App version:', version); // "App version: 1.0.0" output
});
// Using the create_window method
pylon.CustomAPI.create_window().then((windowId) => {
console.log('New window ID:', windowId); // "New window ID: [generated window ID]" output
});
// Example using async/await syntax
async function useCustomAPI() {
try {
const echoResult = await pylon.CustomAPI.echo('Test', 100);
console.log(echoResult);
const appVersion = await pylon.CustomAPI.getAppVersion();
console.log('Current app version:', appVersion);
const newWindowId = await pylon.CustomAPI.create_window();
console.log('Newly created window ID:', newWindowId);
} catch (error) {
console.error('Error occurred during API call:', error);
}
}
useCustomAPI();
```
## API Reference 📚
### PylonApp
- `create_window(url, title, frame, context_menu, js_apis, enable_dev_tools, width, height, x, y) -> BrowserWindow`: Creates a new window and returns a BrowserWindow object.
- `run()`: Runs the application.
- `set_tray_actions(actions)`: Sets tray icon actions.
- `set_tray_menu_items(items)`: Sets tray menu items.
- `setup_tray()`: Sets up the system tray.
- `get_windows()`: Returns a list of all browser windows.
- `show_main_window()`: Shows the first window.
- `get_window_by_id(window_id)`: Returns the window with the given ID.
- `hide_window_by_id(window_id)`: Hides the window with the given ID.
- `show_window_by_id(window_id)`: Shows the window with the given ID.
- `close_window_by_id(window_id)`: Closes the window with the given ID.
- `close_all_windows()`: Closes all windows.
- `quit()`: Quits the application.
- `toggle_fullscreen_by_id(window_id)`: Toggles fullscreen mode for the window with the given ID.
- `minimize_window_by_id(window_id)`: Minimizes the window with the given ID.
- `maximize_window_by_id(window_id)`: Maximizes the window with the given ID.
- `restore_window_by_id(window_id)`: Restores the window with the given ID to its normal state.
### BrowserWindow
- `__init__(app, title, url, frame, context_menu, js_apis, enable_dev_tools, width, height, x, y)`: Initializes a new browser window.
- `load_html_file(file_path)`: Loads a local HTML file into the web view.
- `_on_load_finished(ok)`: Handles the event when the web page load is finished.
- `open_dev_window()`: Opens the developer tools window.
- `get_window_properties()`: Returns the properties of the window.
- `closeEvent(event)`: Handles the event when the window is closed.
- `hide_window()`: Hides the window.
- `show_window()`: Shows the window.
- `close_window()`: Closes the window.
- `toggle_fullscreen()`: Toggles fullscreen mode for the window.
- `minimize_window()`: Minimizes the window.
- `maximize_window()`: Maximizes the window.
- `restore_window()`: Restores the window to its normal state.
### PylonAPI
Used to define bridge APIs for communication between Python and JavaScript.
- `@Bridge(*arg_types, result=return_type)`: Converts a Python method into a function callable from JavaScript.
- `arg_types`: Types of function arguments (multiple possible)
- `result`: Type of return value (optional)
## License 📄
This project is licensed under the terms of the Apache License 2.0. See the [LICENSE](./LICENSE) file for details.
## Contributing 🤝
(Add information about how to contribute here)
Raw data
{
"_id": null,
"home_page": null,
"name": "pylon-desktop",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.13,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "aesthetics-of-record",
"author_email": "111675679+aesthetics-of-record@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/f1/22/9645821cd29fec220ca5329fa84413e38a49e8ed4635342d01a59288edd4/pylon_desktop-0.2.2.tar.gz",
"platform": null,
"description": "# Pylon \ud83c\udfd7\ufe0f\n\nPylon is a framework that allows you to easily create desktop applications using Python and web technologies. \ud83d\udc0d\ud83c\udf10\n\n## Key Features \ud83d\ude80\n\n- Web-based GUI generation\n- System tray icon support \ud83d\udda5\ufe0f\n- Multi-window management \ud83e\ude9f\n- Bridge API between Python and JavaScript \ud83c\udf09\n- Single instance application support\n\n## Installation \ud83d\udce6\n\n### Direct Installation\n\n```bash\npip install pylon-desktop\n```\n\n### Creating a React + Pylon Project\n\nBoilerplate address: [https://github.com/python-pylon/pylon-react-boilerplate](https://github.com/python-pylon/pylon-react-boilerplate)\n\n## Usage \ud83d\udee0\ufe0f\n\n### Creating a Basic Application\n\n```python\nfrom pylon import PylonApp\n\napp = PylonApp(single_instance=True, icon_path=\"assets/icon.ico\")\n\nwindow = app.create_window(\n \"https://www.example.com\",\n title=\"Pylon Browser\",\n)\n\napp.run()\n```\n\n### Setting Up System Tray\n\n```python\nfrom pylon import TrayEvent\n\ndef on_double_click():\n print(\"Tray icon was double-clicked.\")\n\napp.set_tray_actions({\n TrayEvent.DoubleClick: on_double_click,\n})\napp.set_tray_menu_items([\n {\"label\": \"Show Window\", \"callback\": app.show_main_window},\n {\"label\": \"Quit\", \"callback\": app.quit},\n])\napp.setup_tray()\n```\n\n### Creating Python-JavaScript Bridge API\n\n```python\nfrom pylon import PylonAPI, Bridge\n\nclass CustomAPI(PylonAPI):\n @Bridge(str, int, result=str)\n def echo(self, message, number):\n return f\"Message received in Python: {message}, {number}\"\n\n @Bridge(result=str)\n def getAppVersion(self):\n return \"1.0.0\"\n\n @Bridge(result=str)\n def create_window(self):\n window = app.create_window(\n \"alert.html\",\n js_apis=[CustomAPI()],\n width=300,\n height=200,\n x=100,\n y=100,\n )\n return window.id\n\nwindow = app.create_window(\n \"index.html\",\n js_apis=[CustomAPI()],\n # Other options...\n)\n```\n\n```javascript\n// CustomAPI method usage example\n\n// Using the echo method\npylon.CustomAPI.echo('Hello', 42).then((result) => {\n console.log(result); // \"Message received in Python: Hello, 42\" output\n});\n\n// Using the getAppVersion method\npylon.CustomAPI.getAppVersion().then((version) => {\n console.log('App version:', version); // \"App version: 1.0.0\" output\n});\n\n// Using the create_window method\npylon.CustomAPI.create_window().then((windowId) => {\n console.log('New window ID:', windowId); // \"New window ID: [generated window ID]\" output\n});\n\n// Example using async/await syntax\nasync function useCustomAPI() {\n try {\n const echoResult = await pylon.CustomAPI.echo('Test', 100);\n console.log(echoResult);\n\n const appVersion = await pylon.CustomAPI.getAppVersion();\n console.log('Current app version:', appVersion);\n\n const newWindowId = await pylon.CustomAPI.create_window();\n console.log('Newly created window ID:', newWindowId);\n } catch (error) {\n console.error('Error occurred during API call:', error);\n }\n}\n\nuseCustomAPI();\n```\n\n## API Reference \ud83d\udcda\n\n### PylonApp\n\n- `create_window(url, title, frame, context_menu, js_apis, enable_dev_tools, width, height, x, y) -> BrowserWindow`: Creates a new window and returns a BrowserWindow object.\n- `run()`: Runs the application.\n- `set_tray_actions(actions)`: Sets tray icon actions.\n- `set_tray_menu_items(items)`: Sets tray menu items.\n- `setup_tray()`: Sets up the system tray.\n- `get_windows()`: Returns a list of all browser windows.\n- `show_main_window()`: Shows the first window.\n- `get_window_by_id(window_id)`: Returns the window with the given ID.\n- `hide_window_by_id(window_id)`: Hides the window with the given ID.\n- `show_window_by_id(window_id)`: Shows the window with the given ID.\n- `close_window_by_id(window_id)`: Closes the window with the given ID.\n- `close_all_windows()`: Closes all windows.\n- `quit()`: Quits the application.\n- `toggle_fullscreen_by_id(window_id)`: Toggles fullscreen mode for the window with the given ID.\n- `minimize_window_by_id(window_id)`: Minimizes the window with the given ID.\n- `maximize_window_by_id(window_id)`: Maximizes the window with the given ID.\n- `restore_window_by_id(window_id)`: Restores the window with the given ID to its normal state.\n\n### BrowserWindow\n\n- `__init__(app, title, url, frame, context_menu, js_apis, enable_dev_tools, width, height, x, y)`: Initializes a new browser window.\n- `load_html_file(file_path)`: Loads a local HTML file into the web view.\n- `_on_load_finished(ok)`: Handles the event when the web page load is finished.\n- `open_dev_window()`: Opens the developer tools window.\n- `get_window_properties()`: Returns the properties of the window.\n- `closeEvent(event)`: Handles the event when the window is closed.\n- `hide_window()`: Hides the window.\n- `show_window()`: Shows the window.\n- `close_window()`: Closes the window.\n- `toggle_fullscreen()`: Toggles fullscreen mode for the window.\n- `minimize_window()`: Minimizes the window.\n- `maximize_window()`: Maximizes the window.\n- `restore_window()`: Restores the window to its normal state.\n\n### PylonAPI\n\nUsed to define bridge APIs for communication between Python and JavaScript.\n\n- `@Bridge(*arg_types, result=return_type)`: Converts a Python method into a function callable from JavaScript.\n - `arg_types`: Types of function arguments (multiple possible)\n - `result`: Type of return value (optional)\n\n## License \ud83d\udcc4\n\nThis project is licensed under the terms of the Apache License 2.0. See the [LICENSE](./LICENSE) file for details.\n\n## Contributing \ud83e\udd1d\n\n(Add information about how to contribute here)\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "0.2.2",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c218cffc1da808df1bcab17686eeb4637d89f4b31e75dc2b3222416c1b8487bd",
"md5": "d09f877df35d0e30ad45a747a4bc2f61",
"sha256": "6c33d7217612ded672906892925f7626c535dced616f4312cc8de5ff82144ffb"
},
"downloads": -1,
"filename": "pylon_desktop-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d09f877df35d0e30ad45a747a4bc2f61",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.13,>=3.10",
"size": 12853,
"upload_time": "2024-10-04T13:55:07",
"upload_time_iso_8601": "2024-10-04T13:55:07.587530Z",
"url": "https://files.pythonhosted.org/packages/c2/18/cffc1da808df1bcab17686eeb4637d89f4b31e75dc2b3222416c1b8487bd/pylon_desktop-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f1229645821cd29fec220ca5329fa84413e38a49e8ed4635342d01a59288edd4",
"md5": "fb54f4d7f581c584366abc35ff8975ac",
"sha256": "47e8192a1e32ba49f6d92c66370a2ba311a5b512009e41e76800e0a13d8b35ec"
},
"downloads": -1,
"filename": "pylon_desktop-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "fb54f4d7f581c584366abc35ff8975ac",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.13,>=3.10",
"size": 12801,
"upload_time": "2024-10-04T13:55:10",
"upload_time_iso_8601": "2024-10-04T13:55:10.464489Z",
"url": "https://files.pythonhosted.org/packages/f1/22/9645821cd29fec220ca5329fa84413e38a49e8ed4635342d01a59288edd4/pylon_desktop-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-04 13:55:10",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pylon-desktop"
}