一个受react.js启发的组件,用于在google colaboratory中构建一个简单的反应式ui。

ColabComponent的Python项目详细描述


COLAB组件

一个受react.js启发的组件,用于在google colaboratory中构建一个简单的反应式ui。

为什么?

有时需要对数据执行一些手动操作。为什么不在colab中构建一个自定义桌面应用呢?

我在react框架的启发下构建了这个组件,在我看来,react框架为快速原型式开发提供了最好的工具,非常适合于自定义数据探索和数据分析工具。

怎么做?

google.colab包提供了在output中运行python函数的接口。再加上python笔记本可以在html上完全呈现,您可以使用python、html、css和javascript构建ui!

安装

在单元格中运行:

!pip3 install ColabComponent

所有必需的依赖项都安装在google提供的环境中。

如何使用?

包使用面向对象的继承,并基于基本类Component

组件api

property nametypedescriptionoverridable
rendermethodthe basic method, where the ui and effects are defined
component_did_mountmethoda hook that is called, when the component is mounted
component_did_updatemethoda hook that is called, when the component is updated
displaymethodrun to display the component
register_effectmethodregisters a python function such that it can be used within the HTML code
statedictholds the info about the state of the component
set_statemethodthe preferred way of updating the component state

示例

fromColabComponentimportComponentclassCounter(Component):def__init__(self):super().__init__()self.state={'number':1}self.use_add=self.register_effect('add',self.add)defrender(self):returnf'''      <h1>{self.state['number']}</h1>      <button onclick="{self.use_add()}">+1</button>    '''defcomponent_did_mount(self):print('mounted')defcomponent_did_update(self):print('updated')defadd(self):self.set_state({'number':self.state['number']+1})Counter().display()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java为什么hashmap对整数值求和   使用copyFromRealm发送副本时,从错误线程访问java领域异常   java NDK支持是一个实验性的特性,所有用例都还不支持。Android Studio中的错误?   Java从resultSet生成查询并执行新查询   youtube如何使用Java+Google数据API测量上传比特率   如何从Java调用Xtend代码?   在java中,如何清除每个方法中的字节[]数组以保护值不被内存转储?   java UTF8编码与Base64编码   (与java inorder一起提供的反应式处理和反应式反应器:MWIO.3)   带toString的java Building 9x9   java如何在GridLayout中根据手机屏幕对齐按钮?   将字符串值解析为整数时出现java错误   java activeMQ接收器倒带丢失?   jfree图表中范围标记标签的java包装文本   java Android播放列表查询不准确。。。?   当请求中的头{“Accept”:“application/octetstream”}出现错误时,java返回JSON   javanet。ucanaccess。jdbc。UcanaccessSQLException   java Hibernate注释用于自动增量,但如果在保存之前设置了值,则还应保存该值