Skip to content

# Gallery¶

In [1]:

    %matplotlib widget

In [2]:

    from ipywidgets import HBox, VBox, Output, Label

In [3]:

    url = "https://raw.githubusercontent.com/gbrault/jupytersketches/master/"

In [4]:

    gallery = Output()
    gallery

In [5]:

    from pysketcher import *

In [6]:

    import time

In [7]:

    from IPython.display import HTML, SVG, display, clear_output

In [8]:

    files = [("dryfriction","friction"),("pendulum","pendulum"),
             ("car","car"),("springmass","springmass"),
             ("springdashpotmass","springdashpotmass"),("jet_pump","jet_pump")]

In [9]:

    i = 0
    horiz = []
    vert = []
    outputs = [Output() for file in files]
    for output in outputs:
        if i == 3:
            vert.append(HBox(horiz))
            horiz = [output]
            i = 0
        else:
            i += 1
            horiz.append(output)
    if i >= 0 and i < 3:
        vert.append(HBox(horiz))
    with gallery:
        display(VBox(vert))

    i = 0
    for file in files:
        sketch = Sketch({})
        sketch.url2Sketch(url + file[0] +".yml")
        drawing_tool.erase()
        sketch.container[file[1]].draw()
        link = f"<a target=\"_blank\" href=\"{url + file[0] +'.yml'}\"><h3>{file[0]}</h3></a>"
        with outputs[i]:
            clear_output(wait=True)
            display(HTML(link),
                    SVG(Sketch.matplotlib2SVG()))
        i += 1
        time.sleep(0.1)

In [ ]: