Skip to content

Commit

Permalink
Merge pull request #212 from pytti-tools/fix_show_palette_hbox
Browse files Browse the repository at this point in the history
re-added make_hbox for show_palette
  • Loading branch information
dmarx authored Jun 23, 2022
2 parents 8a10acf + 4261d43 commit bdd0d96
Showing 1 changed file with 30 additions and 2 deletions.
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

0 comments on commit bdd0d96

Please sign in to comment.