Gempyre is a framework for quick and simple UI development
Project description
Gempyre-Python
The easy and productive UI library for Python.
If you know HTML, Gempyre is for you!
Gempyre
Gempyre is a C++ GUI library, see https://github.com/mmertama/Gempyre.git.
install from PyPi
There are many flavors in installing - but you need at least Python3.8 on Linux, Windows or MacOS.
e.g.
pip3 install Gempyre --user
or using Poetry
poetry add Gempyre
gi Installs Gempyre to the current user site-packages.
See also (https://docs.python.org/3/library/venv.html) or (https://python-poetry.org/), or (https://pipenv.pypa.io/en/latest/)
Build from sources
You can clone the repository and do install, or get releases from repository.
Gempyre-Python uses scikit build (some OS would need use python3 instead of python, you may need pip install scikit-build first):
python -m build && pip install .
Notes:
Raspberry OS
Todo: Needs optional RASPEBERRY flag to be passed to CMake.
Missing libraries
You may need python3-dev and python3-pip be installed. This may depend on your evironment, In linux e.g. apt-get install python3-dev, in MacOS look brew.
Dialogs requires pywebview installed that wont be hard dependency on 1.8.2 onwards. Upon need, please install manually.
Build with scikit-build
python3 -m venv venv
source venv/bin/activatex
pip3 install scikit-build
pip3 install .
python3 examples/balls/balls.py
Windows:
# Windows has a limit of path lengths to 260 chars - 8-+
#
# "260 characters is enough for everybody"
# - W.G III
Windows default filepath length is an issue. See Here and Here (reboot after change)
If that does not help (or not an option) you may try say in powershell.
mkdir C:\f
$env:TMPDIR = "C:\f"
$env:TEMP = "C:\f"
...before pip install.
Run
After install, you just run the script!
$ python3 test/telex_test.py
API
See examples how to use e.g. telex_test
The programming interface is very same as in Gempyre
- except I changed function and method name naming from CamelCase to more pythonic snake_case (Im not sure if that was a right choice).
Please look Gempyre for documentation.
There are some differences with functions, mainly due C++ overloading - I have left out some parameter combinations that are not important. See exceptions.txt.
Please note that Gempyre Core and Gempyre Graphics are part of Python API, but not GempyreUtils, it has C++ utilites and thus not applicable for Python programmers as everything and more is already there!
Python spesific issues:
As Gempyre is having its own event loop, using with asyncio needs Gempyre to be executed in its own thread.
Example
# non-async
def draw(canvas):
fc = Gempyre.FrameComposer()
fc.fill_style("magenta")
fc.fill_rect(Gempyre.Rect(1, 1, 30, 30))
canvas.draw_frame(fc)
# async
async def on_open(canvas)
await asyncio.sleep(3) # example wait
draw(canvas)
async def main():
map, names = resource.from_bytes({"ui.html": bytes(html, 'utf-8')})
ui = Gempyre.Ui(map, names["ui.html"])
loop = asyncio.get_running_loop() # Get the current event loop
# Schedule on_open to be called in the event loop thread
ui.on_open(lambda: loop.call_soon_threadsafe(asyncio.create_task, on_open(Gempyre.CanvasElement(ui, 'canvas'))))
# Run ui.run() in a separate thread
await asyncio.to_thread(ui.run)
if __name__ == "__main__":
asyncio.run(main())
Examples
See small test apps
Minimum single file app
#!/usr/bin/python3
import Gempyre
import os
import sys
from Gempyre import resource
html = '''
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
</head>
<body>
<script src="/gempyre.js"></script>
Hello!
</body>
</html>
'''
if __name__ == "__main__":
map, names = resource.from_bytes({"ui.html": bytes(html, 'utf-8')})
ui = Gempyre.Ui(map, names["ui.html"])
ui.run()
Minimum application with an external UI file
import Gempyre
import os
import sys
from Gempyre import resource
name = os.path.join(os.path.dirname(sys.argv[0]), "hello.html")
map, names = resource.from_file(name)
ui = Gempyre.Ui(map, names[name])
ui.run()
HTML
Assumed to be found in the same folder as the script
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script src="/gempyre.js"></script>
Hello!
</body>
</html>
Application with interaction
Python
def main():
name = os.path.join(os.path.dirname(sys.argv[0]), "example2.html")
map, names = resource.from_file(name)
ui = Gempyre.Ui(map, names[name])
output = Gempyre.Element(ui, "output")
open_button = Gempyre.Element(ui, "open")
open_button.subscribe("click", lambda _: output.set_html("Hello"))
ui.run()
if __name__ == "__main__":
main()
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<body>
<script src="/gempyre.js"></script>
<button id="open">Open</button>
<pre id="output"></pre>
</body>
</html>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gempyre-1.8.6.tar.gz.
File metadata
- Download URL: gempyre-1.8.6.tar.gz
- Upload date:
- Size: 52.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac99fb4298d62f1a16144918d9a6cc21f60efc61851f37daf694445a38e8aa9a
|
|
| MD5 |
cc1cef77d33d922a66964bb3226952f4
|
|
| BLAKE2b-256 |
5d09c89b1175b3c3d783a22821298ee3db7a0033762456c430d7e620b23d3cd0
|
File details
Details for the file gempyre-1.8.6-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: gempyre-1.8.6-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd2488420fceba368bf3a0e0d6d3523b6492fd8110f5c2939ae061996a065deb
|
|
| MD5 |
6b91117f9cea15cfa8818a0af9e41673
|
|
| BLAKE2b-256 |
97ca95b98ef7caba3316e7c86e88f342a646ceda11b4aa32d937049599a997b0
|
File details
Details for the file gempyre-1.8.6-cp38-cp38-macosx_15_0_arm64.whl.
File metadata
- Download URL: gempyre-1.8.6-cp38-cp38-macosx_15_0_arm64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.8, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00734ec2a6a7f1c92898cf1ec045c789b392d56835fd0e91e7dec7edc40779e4
|
|
| MD5 |
9103885d9d38aaadf157e4e67f05191f
|
|
| BLAKE2b-256 |
7fdc203e930bb89c92837f5912dd53e79637fd991a4c697aed25b639523aef62
|