[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1094] contrib/py/scripts/addons/ system_icon_get.py: moved icon script to contrib

Brendon Murphy meta.androcto1 at gmail.com
Sat Oct 16 03:20:05 CEST 2010


Revision: 1094
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1094
Author:   meta-androcto
Date:     2010-10-16 03:19:58 +0200 (Sat, 16 Oct 2010)

Log Message:
-----------
moved icon script to contrib

Added Paths:
-----------
    contrib/py/scripts/addons/system_icon_get.py

Added: contrib/py/scripts/addons/system_icon_get.py
===================================================================
--- contrib/py/scripts/addons/system_icon_get.py	                        (rev 0)
+++ contrib/py/scripts/addons/system_icon_get.py	2010-10-16 01:19:58 UTC (rev 1094)
@@ -0,0 +1,70 @@
+# retrieving the masterlist with all icon names
+bl_addon_info = {
+    'name': 'Display All Icons',
+    'author': '',
+    'version': '0.3.2',
+    'blender': (2, 5, 3),
+    'location': 'Object > Properties',
+    'description': 'Fetch Icons * display',
+    'url': 'http://wiki.blender.org/index.php/Extensions:2.5/Py/' \
+        'Scripts/',
+    'category': 'System'}
+import bpy
+try:
+    import urllib.request
+    file = urllib.request.urlopen('https://svn.blender.org/svnroot/bf-blender/trunk/blender/source/blender/editors/include/UI_icons.h')
+except:
+    print("Couldn't find the urllib module or was unable to connect to the internet")
+    file = False
+if file:
+    lines = str(file.read()).split('\\n')
+else:
+    lines = []
+
+# get the icon names of existing non-blank icons
+icons = []
+for l in lines:
+    if l[:9] == 'DEF_ICON(':
+        n = l.strip().split('(')[1].split(')')[0]
+        if n[:10] != 'ICON_BLANK':
+            icons.append(n[5:])
+
+# create custom operator for each icon
+def printdoc_invoke(self, context, event):
+    print(self.bl_description)
+    return{'FINISHED'}
+for i in icons:
+    c = type(i,(bpy.types.Operator,),dict(bl_idname="ICONDISPLAY_OT_"+i, bl_label="ICONDISPLAY_OT_"+i, bl_description=i))
+    setattr(c, 'invoke', printdoc_invoke)
+    bpy.types.register(c)
+
+# draw the panel with the icons
+class OBJECT_PT_icons(bpy.types.Panel):
+    bl_space_type = "PROPERTIES"
+    bl_region_type = "WINDOW"
+    bl_context = "object"
+    bl_label = "All icons"
+    
+    def draw(self, context):
+        amount = 10
+        cols = []
+        layout = self.layout
+        split = layout.split(percentage=1.0/amount)
+        for i in range(amount):
+            cols.append(split.column())
+        for i in range(len(icons)):
+            col = cols[i%amount].row()
+            try:
+                col.operator("icondisplay."+icons[i], text="", icon=icons[i])
+            except:
+                col.operator("icondisplay."+icons[i], text="new")
+
+###################################
+def register():
+    pass
+
+def unregister():
+    pass
+
+if __name__ == "__main__":
+    register()




More information about the Bf-extensions-cvs mailing list