Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-10-08 06:21:41 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-10-08 06:21:41 +0300
commitf9a266a22629afee11a5b9abd04a28dcc1cdc277 (patch)
treecfcb5acdc521608f06f5149a17ca8b71d9e928b4 /release/scripts/modules/bpy_types.py
parenta856c5eccffba817a1e9ac499e0156fc6d4eb3c3 (diff)
UI: support passing a function to WorkSpace.status_text_set()
This allows Python operators to draw icons and other UI elements into the status bar.
Diffstat (limited to 'release/scripts/modules/bpy_types.py')
-rw-r--r--release/scripts/modules/bpy_types.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 29470895079..1a2eb12cd9f 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -184,6 +184,27 @@ class WindowManager(bpy_types.ID):
self.piemenu_end__internal(pie)
+class WorkSpace(bpy_types.ID):
+ __slots__ = ()
+
+ def status_text_set(self, text):
+ """
+ Set the status text or None to clear,
+ When text is a function, this will be called with the (header, context) arguments.
+ """
+ from bl_ui.space_statusbar import STATUSBAR_HT_header
+ draw_fn = getattr(STATUSBAR_HT_header, "_draw_orig", None)
+ if draw_fn is None:
+ draw_fn = STATUSBAR_HT_header._draw_orig = STATUSBAR_HT_header.draw
+
+ if not (text is None or isinstance(text, str)):
+ draw_fn = text
+ text = None
+
+ self.status_text_set_internal(text)
+ STATUSBAR_HT_header.draw = draw_fn
+
+
class _GenericBone:
"""
functions for bones, common between Armature/Pose/Edit bones.