nmwsharp / nmwsharp/polyscope

Addition to callbacks & custom UIs - Python

Offen
#279 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
C++
Sterne
2.2k
Forks
242
Ø Merge
11 Min.
Gemergte PRs (30 T.)
1

Beschreibung

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)

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der verlinkten Dokumentationsseite zu Callbacks und benutzerdefinierten UIs und sieh dir die umgebenden Beispiele an. Füge den gezeigten auf Python-Modulen basierenden Ansatz zum Speichern von UI-gesteuerten Werten neben den bestehenden Hinweisen zu global und nonlocal hinzu, wobei variables.py und main.py als Beispiel verwendet werden. Als erledigt gilt, wenn die Seite diese Alternative klar erklärt und das Beispiel mit der Callback-API konsistent ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.