%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

bimpy is a a native extension for Python built with C++ and that provides bindings to dear imgui and distributed as a self-contained package bundled with glfw and gl3w

PyPI version

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
Core API Using `bimpy.App` class
```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) ``` ```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() ```
![Screenshot from 2020-12-05 08-38-39](https://user-images.githubusercontent.com/3229783/101244661-bfe01600-36d5-11eb-9d39-3d19c091abba.png) # Display images Display PIL image:
```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) ``` ![Screenshot from 2020-12-06 06-58-02](https://user-images.githubusercontent.com/3229783/101279465-743e7280-3790-11eb-9364-137c336b78a2.png)
Similarly, numpy arrays with 2 dimensions, 3 dimensions (2, 3 or 4 channels) of type **np.uint8** can be displayed. Display numpy, ndarray image:
```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) ``` ![Screenshot from 2020-12-06 07-05-08](https://user-images.githubusercontent.com/3229783/101279636-8ff64880-3791-11eb-8646-9957b0c42d1a.png)
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

bimpy is a a native extension for Python built with C++ and that provides bindings to dear imgui and distributed as a self-contained package bundled with glfw and gl3w

PyPI version

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
Core API Using `bimpy.App` class
```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) ``` ```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() ```
![Screenshot from 2020-12-05 08-38-39](https://user-images.githubusercontent.com/3229783/101244661-bfe01600-36d5-11eb-9d39-3d19c091abba.png) # Display images Display PIL image:
```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) ``` ![Screenshot from 2020-12-06 06-58-02](https://user-images.githubusercontent.com/3229783/101279465-743e7280-3790-11eb-9364-137c336b78a2.png)
Similarly, numpy arrays with 2 dimensions, 3 dimensions (2, 3 or 4 channels) of type **np.uint8** can be displayed. Display numpy, ndarray image:
```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) ``` ![Screenshot from 2020-12-06 07-05-08](https://user-images.githubusercontent.com/3229783/101279636-8ff64880-3791-11eb-8646-9957b0c42d1a.png)
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

bimpy is a a native extension for Python built with C++ and that provides bindings to dear imgui and distributed as a self-contained package bundled with glfw and gl3w

PyPI version

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
Core API Using `bimpy.App` class
```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) ``` ```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() ```
![Screenshot from 2020-12-05 08-38-39](https://user-images.githubusercontent.com/3229783/101244661-bfe01600-36d5-11eb-9d39-3d19c091abba.png) # Display images Display PIL image:
```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) ``` ![Screenshot from 2020-12-06 06-58-02](https://user-images.githubusercontent.com/3229783/101279465-743e7280-3790-11eb-9364-137c336b78a2.png)
Similarly, numpy arrays with 2 dimensions, 3 dimensions (2, 3 or 4 channels) of type **np.uint8** can be displayed. Display numpy, ndarray image:
```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) ``` ![Screenshot from 2020-12-06 07-05-08](https://user-images.githubusercontent.com/3229783/101279636-8ff64880-3791-11eb-8646-9957b0c42d1a.png)
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 * Thu Jun 08 2023 Python_Bot - 0.1.1-1 - Package Spec generated