IDOM 0.0.0

_images/idom-logo.png

Libraries for defining and controlling interactive webpages with Python 3.6 and above.

Try it Now!

  • In a Jupyter Notebook - launch-binder

  • With an online editor - IDOM Sandbox

Early Days

IDOM is still young. If you have ideas or find a bug, be sure to post an issue or create a pull request. Thanks in advance!

At a Glance

Let’s use IDOM to create a simple slideshow which changes whenever a user clicks an image:

import idom

@idom.element
async def Slideshow(self, index=0):
    async def next_image(event):
        self.update(index + 1)

    return idom.html.img(
        {
            "src": f"https://picsum.photos/800/300?image={index}",
            "style": {"cursor": "pointer"},
            "onClick": next_image,
        }
    )

host, port = "localhost", 8765
server = idom.server.sanic.PerClientStateServer(Slideshow)
server.run(host, port)

Running this will serve our slideshow to "https://localhost:8765". You can try out a working example by enabling the widget below - clicking the image should cause it to change 🖱️

Note

You can display the same thing in a Jupyter Notebook using widgets!

idom.JupyterDisplay(f"https://{host}:{port}")

For info on working with IDOM in Jupyter see some examples.