add new examples for jupyter and streamlit

This commit is contained in:
nicolalandro 2021-11-21 14:03:30 +01:00
parent c0f36f29fc
commit 9eda4a57fa
4 changed files with 217 additions and 2 deletions

View File

@ -13,7 +13,7 @@ Install with `pip install obj2html` and use with `obj2html('model.obj', 'index.h
![](imgs/colab_sample.png)
* run into jupyter notebook
* run into [jupyter notebook](https://jupyter.org/) ([jupyter_example.ipynb](examples/jupyter_example.ipynb)):
```
! pip install obj2html
! wget https://gitlab.com/nicolalandro/obj2html/-/raw/main/test/assets/model.obj
@ -24,6 +24,22 @@ obj2html('model.obj', 'index.html')
display(HTML('index.html'))
```
* run into [streamlit](https://streamlit.io/) app ([streamlit_example.py](examples/streamlit_example.py)):
```
# pip install obj2html streamlit
# have a model.obj (wget https://gitlab.com/nicolalandro/obj2html/-/raw/main/test/assets/model.obj)
import streamlit as st
import streamlit.components.v1 as components
from obj2html import obj2html
html_string = obj2html("model.obj", html_elements_only=True)
components.html(html_string)
with open("model.obj") as f:
st.download_button('Download model.obj', f, file_name="download_name.obj")
```
![](imgs/streamlit_example.png)
## Features
@ -33,7 +49,7 @@ display(HTML('index.html'))
- [x] pypi doc add image
- [x] edit html positions and other 3D params
- [x] add param for streamlit
- [ ] document param for streamlit
- [x] document param for streamlit
- [ ] dist wheel
- [ ] load three.js as static file
- [ ] .mat files support

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
import streamlit as st
import streamlit.components.v1 as components
from obj2html import obj2html
# run in the root folder, not inside exaples, to have the relative path working
obj_path = "test/assets/model.obj"
html_string = obj2html(obj_path, html_elements_only=True)
components.html(html_string)
with open(obj_path) as f:
st.download_button('Download model.obj', f, file_name="model.obj")

BIN
imgs/streamlit_example.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB