Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-added make_hbox for show_palette #212

Merged
merged 1 commit into from
Jun 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/pytti/update_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,34 @@
OUTPATH = f"{os.getcwd()}/images_out"


def make_hbox(im, fig):
# https://stackoverflow.com/questions/51315566/how-to-display-the-images-side-by-side-in-jupyter-notebook/51316108
import io
import ipywidgets as widgets
from ipywidgets import Layout

with io.BytesIO() as buf:
im.save(buf, format="png")
buf.seek(0)
wi1 = widgets.Image(
value=buf.read(),
format="png",
layout=Layout(border="0", margin="0", padding="0"),
)
with io.BytesIO() as buf:
fig.savefig(buf, format="png", bbox_inches="tight")
buf.seek(0)
wi2 = widgets.Image(
value=buf.read(),
format="png",
layout=Layout(border="0", margin="0", padding="0"),
)
return widgets.HBox(
[wi1, wi2],
layout=Layout(border="0", margin="0", padding="0", align_items="flex-start"),
)


# Update is called each step.
def update(
model,
Expand Down Expand Up @@ -140,9 +168,9 @@ def save_out(
# delete the file. if file not found, nothing happens.
if fpath.exists():
fpath.unlink()
#fpath.unlink(
# fpath.unlink(
# missing_ok=True
#)
# )

j = i + 1

Expand Down