用python控制web
idom的Python项目详细描述
IDOM
用于使用Python3.6及更高版本创建和控制交互式网页的库
我还年轻。如果你有想法或者发现一个bug,一定要发布一个 issue 或创建一个 pull request提前谢谢!
Try it Now
点击上面的徽章开始!它会带你去Jupyter Notebooks 由Binder主持,有一些很好的例子。
或者现在安装
pip install idom
一目了然
idom可以用来创建一个简单的幻灯片,每当用户单击一个图像时,它就会改变。
importidom@idom.elementasyncdefSlideshow(self,index=0):asyncdefnext_image(event):self.update(index+1)url=f"https://picsum.photos/800/300?image={index}"returnidom.node("img",src=url,onClick=next_image)server=idom.server.sanic.PerClientState(Slideshow)server.daemon("localhost",8765).join()
运行此命令将为幻灯片放映提供"https://localhost:8765/client/index.html"
你甚至可以在笔记本上显示同样的东西!
idom.display("jupyter","https://localhost:8765/stream")
每次点击都会导致图像改变(当然不会在这里)