bdk-blender/scripts/modules/bl_ui_utils
Sybren A. Stüvel d85520f297 Python: bl_ui_utils.layout.operator_context context manager
Introduce a context manager that temporarily overrides a UILayout's
operator context.

Instead of writing this:

```py
default_op_context = layout.context
layout.context = 'OTHER_VALUE'
layout.do_stuff()
layout.context = default_op_context
```

you can now write this:

```py
from bl_ui_utils.layout import operator_context

with operator_context(layout, 'OTHER_VALUE'):
    layout.do_stuff()
```

This is also exception-safe; it will always ensure the layout's operator
context is restored when the `with` body is exited, regardless of
whether that's done with an exception or regularly.

Idea in-the-hallway approved by @Sergey.
2023-04-07 11:34:48 +02:00
..
__init__.py
bug_report_url.py
layout.py Python: bl_ui_utils.layout.operator_context context manager 2023-04-07 11:34:48 +02:00