Why Nostr? What is Njump?
2024-07-31 15:55:08

Alexandre B A Villares 🐍 on Nostr: If your #Python application has user interface "modes", how do you keep track of ...

If your #Python application has user interface "modes", how do you keep track of different modes and the "active mode"?

I always think about trying to use Enums, but end up using a tuple of strings and a global variable with an int for the active mode :((

It feels pretty clumsy to write
```if modes[active_mode] == 'MODE_NAME':
...

and


def toggle_mode():
global active_mode
active_mode = (active_mode + 1) % len(modes)

Author Public Key
npub13qa4ushxn7jwk2lwwmj4tsshq2953hrkwmmpg57875r06x3n4d3qenalcv