Support setting a link on traits
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 30/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
调研方向
从 HasTraits 和 Float 入口以及提议的 SourceLink/FloatText 示例开始,然后阅读链接的 ipywidgets 讨论,了解之前的设计背景。定义向后兼容的 API,并验证设置 trait link 后是否能按预期绑定 view,而无需保留字段引用。
由索引模型根据 Issue 内容生成。
描述
I'm looking to start using a standard pattern in our UIs to split our model and views, similar to the points discussed in https://github.com/jupyter-widgets/ipywidgets/issues/2296. However when extending to more complex or nested views it's rather inconvenient to have to define all the links separately as we need to hold a reference to every field.
Instead I'd been keen to introduce the ability to set links directly on traits. This way I can bind to the view's traits without needing to hold a reference to the object. Proposing something along the following lines so that it's backwards compatible with current traitlet usage.
from traitlets import SourceLink, Float, HasTraits
import ipywidgets as widgets
class Model(HasTraits):
a = Float()
def view(model):
return widgets.HBox([
widgets.Label("Value A"),
widgets.FloatText(value = SourceLink(model, "a"))
])
x1 = Model()
view(x1)
Having tested locally I think this is easily achievable with minimal changes. However before submitting a PR I wanted to check if any views or comments on the idea or how to approach it.
- 主要语言
- Python
- 星标
- 653
- 派生
- 217
- 平均合并
- 2 天 21 小时
- 30 天内合并 PR
- 2
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ipython/traitlets 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 65/100
-
难度 1/5 1-3 小时 新手友好度 65/100
-
good first issue
难度 1/5 1 小时以内 新手友好度 85/100
-
documentation
难度 1/5 1 小时以内 新手友好度 65/100
-
难度 3/5 1-2 天 新手友好度 45/100
查看 ipython/traitlets 的全部 Issue
相似的 Issue
-
essnmx good first issue
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 65/100
syfoud/Simulated_Scepter#174 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Giskard-AI/giskard-oss#2840 · 1 条评论 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success 未关闭area: repo bug perceived difficulty: 2
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
yeti-platform/yeti#1380 ·