diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-bimpy.spec | 395 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 397 insertions, 0 deletions
@@ -0,0 +1 @@ +/bimpy-0.1.1.tar.gz diff --git a/python-bimpy.spec b/python-bimpy.spec new file mode 100644 index 0000000..ae6d1e3 --- /dev/null +++ b/python-bimpy.spec @@ -0,0 +1,395 @@ +%global _empty_manifest_terminate_build 0 +Name: python-bimpy +Version: 0.1.1 +Release: 1 +Summary: bimpy - bundled imgui for python +License: MIT +URL: https://github.com/podgorskiy/bimpy +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/59/10/fa47d72afbea9205804b96f3f13f56f6da0297837c05305d44776c3ebdf8/bimpy-0.1.1.tar.gz + + +%description +<img src="doc_sources/logo.svg"> +<h4 align="center"> +<strong>bimpy</strong> is a a native extension for Python built with C++ and <a href="https://github.com/pybind/pybind11"></a> that provides bindings to <a href="https://github.com/ocornut/imgui">dear imgui</a> and distributed as a self-contained package bundled with <a href="https://github.com/glfw/glfw">glfw</a> and <a href="https://github.com/skaslev/gl3w">gl3w</a> +</h4> +<p align="center"> + <a href="https://badge.fury.io/py/bimpy"><img src="https://badge.fury.io/py/bimpy.svg" alt="PyPI version" height="18"></a> + <a href="https://pepy.tech/project/bimpy"><img src="https://pepy.tech/badge/bimpy"></a> + <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/pypi/l/bimpy"></a> + <a href="https://api.travis-ci.com/podgorskiy/bimpy.svg?branch=master"><img src="https://travis-ci.org/podgorskiy/bimpy.svg?branch=master"></a> +</p> +Features: +* Immediate mode UI with python. The API is kept as close to the original dear imgui as possible. +* **bimpy** already has all necessary functionality for window/OpenGL context creation and hides those details from the user. +* **bimpy** can display images from ndarrays, PIL Images, numpy arrays, etc., +* **bimpy** works on Windows, GNU Linux, and macOS. +* **bimpy** does not have dependencies and can be easily built from sources. Building relies only on distutils. +# Hello world with bimpy +Core API tries to map to the Dear ImGui as close as possible. There is additional API, such as `bimpy.App` class that simplifies **bimpy** usage +<table> +<tr><td> +Core API +</td> <td> +Using `bimpy.App` class </td> +</tr> +<tr> +<td> +```python +import bimpy as bp +ctx = bp.Context() +ctx.init(600, 600, "Hello") +s = bp.String() +f = bp.Float() +while not ctx.should_close(): + with ctx: + bp.text("Hello, world!") + if bp.button("OK"): + print(s.value) + bp.input_text('string', str, 256) + bp.slider_float("float", f, 0, 1) +``` +</td> +<td> +```python +import bimpy as bp +class App(bp.App): + def __init__(self): + super(App, self).__init__(title='Test') + self.s = bp.String() + self.f = bp.Float() + def on_update(self): + bp.text("Hello, world!") + if bp.button("OK"): + print(self.s.value) + bp.input_text('string', self.s, 256) + bp.slider_float("float", self.f, 0, 1) +app = App() +app.run() +``` +</td> +</tr> +</table> + +# Display images +Display PIL image: +<table> +<tr><td> +```python +import bimpy +from PIL import Image +ctx = bimpy.Context() +ctx.init(800, 800, "Image") +image = Image.open("test.png") +im = bimpy.Image(image) +while not ctx.should_close(): + with ctx: + bimpy.text("Display PIL Image") + bimpy.image(im) +``` +</td> <td> + +</td> +</tr> +</table> +Similarly, numpy arrays with 2 dimensions, 3 dimensions (2, 3 or 4 channels) of type **np.uint8** can be displayed. +Display numpy, ndarray image: +<table> +<tr><td> +```python +import bimpy +from PIL import Image +import numpy as np +ctx = bimpy.Context() +ctx.init(800, 800, "Image") +image = np.asarray(Image.open("3.png"), dtype=np.uint8) +im = bimpy.Image(image) +while not ctx.should_close(): + with ctx: + bimpy.text("Display Image of type:") + bimpy.same_line() + bimpy.text(str(type(image))) + bimpy.image(im) +``` +</td> <td> + +</td> +</tr> +</table> +More examples here: https://github.com/podgorskiy/bimpy/blob/master/examples/image.py + +%package -n python3-bimpy +Summary: bimpy - bundled imgui for python +Provides: python-bimpy +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +BuildRequires: python3-cffi +BuildRequires: gcc +BuildRequires: gdb +%description -n python3-bimpy +<img src="doc_sources/logo.svg"> +<h4 align="center"> +<strong>bimpy</strong> is a a native extension for Python built with C++ and <a href="https://github.com/pybind/pybind11"></a> that provides bindings to <a href="https://github.com/ocornut/imgui">dear imgui</a> and distributed as a self-contained package bundled with <a href="https://github.com/glfw/glfw">glfw</a> and <a href="https://github.com/skaslev/gl3w">gl3w</a> +</h4> +<p align="center"> + <a href="https://badge.fury.io/py/bimpy"><img src="https://badge.fury.io/py/bimpy.svg" alt="PyPI version" height="18"></a> + <a href="https://pepy.tech/project/bimpy"><img src="https://pepy.tech/badge/bimpy"></a> + <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/pypi/l/bimpy"></a> + <a href="https://api.travis-ci.com/podgorskiy/bimpy.svg?branch=master"><img src="https://travis-ci.org/podgorskiy/bimpy.svg?branch=master"></a> +</p> +Features: +* Immediate mode UI with python. The API is kept as close to the original dear imgui as possible. +* **bimpy** already has all necessary functionality for window/OpenGL context creation and hides those details from the user. +* **bimpy** can display images from ndarrays, PIL Images, numpy arrays, etc., +* **bimpy** works on Windows, GNU Linux, and macOS. +* **bimpy** does not have dependencies and can be easily built from sources. Building relies only on distutils. +# Hello world with bimpy +Core API tries to map to the Dear ImGui as close as possible. There is additional API, such as `bimpy.App` class that simplifies **bimpy** usage +<table> +<tr><td> +Core API +</td> <td> +Using `bimpy.App` class </td> +</tr> +<tr> +<td> +```python +import bimpy as bp +ctx = bp.Context() +ctx.init(600, 600, "Hello") +s = bp.String() +f = bp.Float() +while not ctx.should_close(): + with ctx: + bp.text("Hello, world!") + if bp.button("OK"): + print(s.value) + bp.input_text('string', str, 256) + bp.slider_float("float", f, 0, 1) +``` +</td> +<td> +```python +import bimpy as bp +class App(bp.App): + def __init__(self): + super(App, self).__init__(title='Test') + self.s = bp.String() + self.f = bp.Float() + def on_update(self): + bp.text("Hello, world!") + if bp.button("OK"): + print(self.s.value) + bp.input_text('string', self.s, 256) + bp.slider_float("float", self.f, 0, 1) +app = App() +app.run() +``` +</td> +</tr> +</table> + +# Display images +Display PIL image: +<table> +<tr><td> +```python +import bimpy +from PIL import Image +ctx = bimpy.Context() +ctx.init(800, 800, "Image") +image = Image.open("test.png") +im = bimpy.Image(image) +while not ctx.should_close(): + with ctx: + bimpy.text("Display PIL Image") + bimpy.image(im) +``` +</td> <td> + +</td> +</tr> +</table> +Similarly, numpy arrays with 2 dimensions, 3 dimensions (2, 3 or 4 channels) of type **np.uint8** can be displayed. +Display numpy, ndarray image: +<table> +<tr><td> +```python +import bimpy +from PIL import Image +import numpy as np +ctx = bimpy.Context() +ctx.init(800, 800, "Image") +image = np.asarray(Image.open("3.png"), dtype=np.uint8) +im = bimpy.Image(image) +while not ctx.should_close(): + with ctx: + bimpy.text("Display Image of type:") + bimpy.same_line() + bimpy.text(str(type(image))) + bimpy.image(im) +``` +</td> <td> + +</td> +</tr> +</table> +More examples here: https://github.com/podgorskiy/bimpy/blob/master/examples/image.py + +%package help +Summary: Development documents and examples for bimpy +Provides: python3-bimpy-doc +%description help +<img src="doc_sources/logo.svg"> +<h4 align="center"> +<strong>bimpy</strong> is a a native extension for Python built with C++ and <a href="https://github.com/pybind/pybind11"></a> that provides bindings to <a href="https://github.com/ocornut/imgui">dear imgui</a> and distributed as a self-contained package bundled with <a href="https://github.com/glfw/glfw">glfw</a> and <a href="https://github.com/skaslev/gl3w">gl3w</a> +</h4> +<p align="center"> + <a href="https://badge.fury.io/py/bimpy"><img src="https://badge.fury.io/py/bimpy.svg" alt="PyPI version" height="18"></a> + <a href="https://pepy.tech/project/bimpy"><img src="https://pepy.tech/badge/bimpy"></a> + <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/pypi/l/bimpy"></a> + <a href="https://api.travis-ci.com/podgorskiy/bimpy.svg?branch=master"><img src="https://travis-ci.org/podgorskiy/bimpy.svg?branch=master"></a> +</p> +Features: +* Immediate mode UI with python. The API is kept as close to the original dear imgui as possible. +* **bimpy** already has all necessary functionality for window/OpenGL context creation and hides those details from the user. +* **bimpy** can display images from ndarrays, PIL Images, numpy arrays, etc., +* **bimpy** works on Windows, GNU Linux, and macOS. +* **bimpy** does not have dependencies and can be easily built from sources. Building relies only on distutils. +# Hello world with bimpy +Core API tries to map to the Dear ImGui as close as possible. There is additional API, such as `bimpy.App` class that simplifies **bimpy** usage +<table> +<tr><td> +Core API +</td> <td> +Using `bimpy.App` class </td> +</tr> +<tr> +<td> +```python +import bimpy as bp +ctx = bp.Context() +ctx.init(600, 600, "Hello") +s = bp.String() +f = bp.Float() +while not ctx.should_close(): + with ctx: + bp.text("Hello, world!") + if bp.button("OK"): + print(s.value) + bp.input_text('string', str, 256) + bp.slider_float("float", f, 0, 1) +``` +</td> +<td> +```python +import bimpy as bp +class App(bp.App): + def __init__(self): + super(App, self).__init__(title='Test') + self.s = bp.String() + self.f = bp.Float() + def on_update(self): + bp.text("Hello, world!") + if bp.button("OK"): + print(self.s.value) + bp.input_text('string', self.s, 256) + bp.slider_float("float", self.f, 0, 1) +app = App() +app.run() +``` +</td> +</tr> +</table> + +# Display images +Display PIL image: +<table> +<tr><td> +```python +import bimpy +from PIL import Image +ctx = bimpy.Context() +ctx.init(800, 800, "Image") +image = Image.open("test.png") +im = bimpy.Image(image) +while not ctx.should_close(): + with ctx: + bimpy.text("Display PIL Image") + bimpy.image(im) +``` +</td> <td> + +</td> +</tr> +</table> +Similarly, numpy arrays with 2 dimensions, 3 dimensions (2, 3 or 4 channels) of type **np.uint8** can be displayed. +Display numpy, ndarray image: +<table> +<tr><td> +```python +import bimpy +from PIL import Image +import numpy as np +ctx = bimpy.Context() +ctx.init(800, 800, "Image") +image = np.asarray(Image.open("3.png"), dtype=np.uint8) +im = bimpy.Image(image) +while not ctx.should_close(): + with ctx: + bimpy.text("Display Image of type:") + bimpy.same_line() + bimpy.text(str(type(image))) + bimpy.image(im) +``` +</td> <td> + +</td> +</tr> +</table> +More examples here: https://github.com/podgorskiy/bimpy/blob/master/examples/image.py + +%prep +%autosetup -n bimpy-0.1.1 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-bimpy -f filelist.lst +%dir %{python3_sitearch}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 10 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.1-1 +- Package Spec generated @@ -0,0 +1 @@ +bbf69f202413b4b2f260d3fa0e1d0e7d bimpy-0.1.1.tar.gz |