forked from blender/blender
Sybren A. Stüvel
d85520f297
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. |
||
---|---|---|
.. | ||
__init__.py | ||
bug_report_url.py | ||
layout.py |