Addition to callbacks & custom UIs - Python
Nessuno ha ancora preso questa issue.
- Lingua principale
- C++
- Stelle
- 2.2k
- Fork
- 242
- Merge medio
- 11m
- PR unite (30g)
- 1
Descrizione
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)
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dalla pagina di documentazione collegata su callbacks e UIs personalizzate e osserva gli esempi circostanti. Aggiungi l’approccio mostrato basato su un modulo Python per memorizzare i valori controllati dalla UI accanto alle indicazioni esistenti su global e nonlocal, usando variables.py e main.py come esempio. Il lavoro è completo quando la pagina spiega chiaramente questa alternativa e l’esempio è coerente con la callback API.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100