ldo/ShaderTools — comment on commit 31523ba5c684b17b5db1721d5a0208c7afeb685e
File:  line 0
By ldo:

This is one change where you might disagree whether the new code is better than the old one or not. The main issue is with defining a custom panel containing the buttons for invoking the functions of the script.

Karim’s original code did this by defining a Panel subclass with a “magic” name (beginning with “OBJECT_PT_”). When blender sees something being registered with a name of various special forms like this, it will automatically invoke that to display itself in some particular part of the user interface. In this case, the special name prefix, combined with the values specified for the bl_space_type, bl_region_type and bl_context attributes, will cause the panel to appear under the materials tab of the Properties window.

My code does this in a different way: instead of registering an operator with a magic name, I explicitly call a Blender object that takes care of registering callbacks for defining panels in the appropriate UI area. In this case, MATERIAL_PT_context_material handles panels in the materials tab of the Properties window.

Unfortunately, none of these special callback-management objects is explained in the current Blender documentation. The best I have been able to do is put together a list of their names here:

http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Advanced_Tutorials/Python_Scripting/Object,_Action,_Settings_New#Undocumented_Blender

At least they all behave the same way: call their “append” method to add your callback, and their “remove” method to remove your callback.