diff options
author | lijenstina <lijenstina@gmail.com> | 2018-03-07 10:26:23 +0300 |
---|---|---|
committer | lijenstina <lijenstina@gmail.com> | 2018-03-07 10:26:23 +0300 |
commit | 827c5e62e8f121f8f946f1f5f514f7751b1d684a (patch) | |
tree | 8d03a669999d6c35b4e9aafd35e042207a33731f /development_ui_classes.py | |
parent | 0f3294a07904c411cd85e7c2f0f0fd8c3d9d865e (diff) |
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
Diffstat (limited to 'development_ui_classes.py')
-rw-r--r-- | development_ui_classes.py | 35 |
1 files changed, 19 insertions, 16 deletions
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(): |