[Bf-extensions-cvs] [827c5e62] master: UI Classes Overvew: Avoid failure when called outside the Text editor

lijenstina noreply at git.blender.org
Wed Mar 7 08:27:56 CET 2018


Commit: 827c5e62e8f121f8f946f1f5f514f7751b1d684a
Author: lijenstina
Date:   Wed Mar 7 08:26:23 2018 +0100
Branches: master
https://developer.blender.org/rBA827c5e62e8f121f8f946f1f5f514f7751b1d684a

UI Classes Overvew: Avoid failure when called outside the Text editor

Bump version to 1.0.2
Minor style tweaks
Add a condition to the assignment of the active text block

===================================================================

M	development_ui_classes.py

===================================================================

diff --git a/development_ui_classes.py b/development_ui_classes.py
index 18b692f4..f03b7bb5 100644
--- a/development_ui_classes.py
+++ b/development_ui_classes.py
@@ -21,7 +21,7 @@
 bl_info = {
     "name": "UI Classes Overview",
     "author": "lijenstina",
-    "version": (1, 0, 1),
+    "version": (1, 0, 2),
     "blender": (2, 78, 0),
     "location": "Text Editor > Properties",
     "description": "Print the UI classes in a text-block",
@@ -33,15 +33,15 @@ bl_info = {
 
 import bpy
 from bpy.types import (
-        Operator,
-        Panel,
-        PropertyGroup,
-        )
+    Operator,
+    Panel,
+    PropertyGroup,
+)
 from bpy.props import (
-        BoolProperty,
-        EnumProperty,
-        PointerProperty,
-        )
+    BoolProperty,
+    EnumProperty,
+    PointerProperty,
+)
 
 
 class TEXT_PT_ui_cheat_sheet(Panel):
@@ -128,7 +128,10 @@ class TEXT_OT_ui_cheat_sheet(Operator):
                 textblock.write(('\n' if not searchable else '').join(sorted(op_string_ui[cls_name])))
                 textblock.write(close_line)
 
-            context.space_data.text = bpy.data.texts[file_name]
+            # try to set the created text block to active
+            if context.area.type in {"TEXT_EDITOR"}:
+                bpy.context.space_data.text = bpy.data.texts[file_name]
+
             self.report({'INFO'}, "See %s textblock" % file_name)
 
             return {'FINISHED'}
@@ -152,21 +155,21 @@ class text_ui_cheat_props(PropertyGroup):
                ('Header', "Headers", "Print Header UI types"),
                ),
         default='all',
-        )
+    )
     searchable = BoolProperty(
         name="Format searchable",
         description="Generate the list as Python dictionary,\n"
                     "using the format Class: Path",
         default=False
-        )
+    )
 
 
 # Register
 classes = (
-        TEXT_OT_ui_cheat_sheet,
-        TEXT_PT_ui_cheat_sheet,
-        text_ui_cheat_props
-        )
+    TEXT_OT_ui_cheat_sheet,
+    TEXT_PT_ui_cheat_sheet,
+    text_ui_cheat_props
+)
 
 
 def register():



More information about the Bf-extensions-cvs mailing list