Addition to callbacks & custom UIs - Python

未关闭
#279 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
45/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
documentation

调研方向

从链接的 callbacks 和自定义 UIs 文档页面开始,并检查周围的示例。在现有的 global 和 nonlocal 指导旁边,加入所展示的基于 Python 模块、用于存储由 UI 控制的值的方法,并使用 variables.py 和 main.py 作为示例。完成的标准是页面清楚地解释这一替代方案,并且示例与 callback API 保持一致。

由索引模型根据 Issue 内容生成。

描述

https://polyscope.run/py/features/callbacks_and_UIs/#creating-custom-uis

#If we want to use local variables & assign to them in the UI code below, 
# we need to mark them as nonlocal. This is because of how Python scoping 
# rules work, not anything particular about Polyscope or ImGui.
# Of course, you can also use any other kind of python variable as a controllable 
# value in the UI, such as a value from a dictionary, or a class member. Just be 
# sure to assign the result of the ImGui call to the value, as in the examples below.
# 
# If these variables are defined at the top level of a Python script file (i.e., not
# inside any method), you will need to use the `global` keyword instead of nonlocal`.

If you want to avoid using declarations global or nonlocal,
you can also use different module to store these values and call it on main module as below

variables.py
is_true: bool = False

main.py

import variables as vr

def callback()
        change, vr.is_true = psim.Checkbox("Selection box", vr.is_true)
主要语言
C++
星标
2.2k
派生
242
平均合并
11 分钟
30 天内合并 PR
1

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nmwsharp/polyscope 的其他 Issue

查看 nmwsharp/polyscope 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。