diff options
| author | Steven Van Dorp <steven@vandorp.lu> | 2026-02-06 10:00:08 +0100 |
|---|---|---|
| committer | Steven Van Dorp <steven@vandorp.lu> | 2026-02-06 10:00:08 +0100 |
| commit | 0d8aeb6464103ec8e35c10c448bf08b0b9edc156 (patch) | |
| tree | 80ab47bf3e0f137856d8494753e774c8456c85c8 /bindings/main.py | |
Diffstat (limited to 'bindings/main.py')
| -rw-r--r-- | bindings/main.py | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/bindings/main.py b/bindings/main.py new file mode 100644 index 0000000..fbb8bb9 --- /dev/null +++ b/bindings/main.py @@ -0,0 +1,74 @@ +# class +import minimgui as ui + +class App: + def __init__(self): + self.time = 0 + + def loop(self, dt): + self.time += dt + ui.rectangle( + self.time, 0.1, + 0.2, 0.2, + color = 0x0000ffff + ) + +ui.run(App().loop) + +# global +""" +import minimgui as ui + +time = 0 +def loop(dt): + global time + time += dt + ui.rectangle( + time, 0.1, + 0.2, 0.2, + color = 0x0000ffff + ) + +ui.run() +""" + +# closure +""" +import minimgui as ui + +def app(): + time = 0 + def loop(dt): + nonlocal time + time += dt + ui.rectangle( + time, 0.1, + 0.2, 0.2, + color = 0x0000ffff + ) + return loop + +ui.run(app()) +""" + +# dataclass +""" +import minimgui as ui +from dataclasses import dataclass + +@dataclass +class State: + time: float = 0.0 +state = State() + +def loop(dt): + state.time += dt + ui.rectangle( + state.time, 0.1, + 0.2, 0.2, + color = 0x0000ffff + ) + +ui.run() +""" + |
