[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1258] contrib/py/scripts/addons/ system_icon_get.py: Version 1.4.1
Bart Crouch
bartius.crouch at gmail.com
Thu Dec 9 11:53:47 CET 2010
Revision: 1258
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1258
Author: crouch
Date: 2010-12-09 11:53:47 +0100 (Thu, 09 Dec 2010)
Log Message:
-----------
Version 1.4.1
- Icon list is generated only at activation, not on each redraw
- Scroller is also displayed in console window
- Layout improvements
Thanks again to Dany Lebel (and Luca Bonavita)
Modified Paths:
--------------
contrib/py/scripts/addons/system_icon_get.py
Modified: contrib/py/scripts/addons/system_icon_get.py
===================================================================
--- contrib/py/scripts/addons/system_icon_get.py 2010-12-09 09:27:29 UTC (rev 1257)
+++ contrib/py/scripts/addons/system_icon_get.py 2010-12-09 10:53:47 UTC (rev 1258)
@@ -22,10 +22,11 @@
bl_addon_info = {
'name': 'Icons',
'author': 'Crouch, N.tox, PKHG, Campbell Barton, Dany Lebel',
- 'version': (1, 4, 0),
+ 'version': (1, 4, 1),
'blender': (2, 5, 6),
'api': 33479,
- 'location': 'Text window > Properties panel (ctrl+F)',
+ 'location': 'Text window > Properties panel (ctrl+F) or '\
+ 'Console > Console menu',
'warning': '',
'description': 'Click an icon to display its name and copy it '\
'to the clipboard',
@@ -38,6 +39,13 @@
import bpy
+def create_icon_list():
+ list = bpy.types.UILayout.bl_rna.functions['prop'].\
+ parameters['icon'].items.keys()
+ list.remove("BLENDER")
+ return list
+
+
class IconProps(bpy.types.IDPropertyGroup):
"""
Fake module like class
@@ -48,9 +56,10 @@
class WM_OT_icon_info(bpy.types.Operator):
bl_label = "Icon Info"
+ bl_description = "Click to copy this icon name to the clipboard"
icon = bpy.props.StringProperty()
icon_scroll = bpy.props.IntProperty()
-
+
def invoke(self, context, event):
bpy.data.window_managers['WinMan'].clipboard = self.icon
self.report({'INFO'}, "Icon ID: %s" % self.icon)
@@ -62,56 +71,85 @@
bl_region_type = "UI"
bl_label = "All icons"
- @staticmethod
- def _icon_list():
- list = sorted(bpy.types.UILayout.bl_rna.functions['prop'].\
- parameters['icon'].items.keys())
- list.remove("BLENDER") # hack for icon that messes up layout
- return list
+ def __init__(self, x):
+ self.amount = 10
+ self.icon_list = create_icon_list()
- @staticmethod
- def _amount():
- return 10
-
def draw(self, context):
- split = self.layout.split(percentage=0.05)
+ box = self.layout.box()
# scroll view
if not context.scene.icon_props.expand:
- split.prop(context.scene.icon_props, "expand",
+ row = box.row()
+ row.prop(context.scene.icon_props, "expand",
icon="TRIA_RIGHT", icon_only=True, emboss=False)
- split.prop(context.scene.icon_props, "scroll", slider=True)
-
- row = self.layout.row(align=True)
- for icon in self._icon_list()[context.scene.icon_props.scroll-1:
- context.scene.icon_props.scroll-1+self._amount()]:
- row.operator("wm.icon_info", text="", icon=icon).icon = icon
+ row.prop(context.scene.icon_props, "scroll")
+
+ row = box.row(align=True)
+ for icon in self.icon_list[context.scene.icon_props.scroll-1:
+ context.scene.icon_props.scroll-1+self.amount]:
+ row.operator("wm.icon_info", text=" ", icon=icon,
+ emboss=False).icon = icon
# expanded view
else:
- split.prop(context.scene.icon_props, "expand",
+ row = box.row()
+ row.prop(context.scene.icon_props, "expand",
icon="TRIA_DOWN", icon_only=True, emboss=False)
- row = split.row()
+ row = row.row()
row.active = False
- row.prop(context.scene.icon_props, "scroll", slider=True)
-
- col = self.layout.column(align=True)
- for i, icon in enumerate(self._icon_list()):
- if i % self._amount() == 0:
+ row.prop(context.scene.icon_props, "scroll")
+
+ col = box.column(align=True)
+ row = col.row(align=True)
+ for i, icon in enumerate(self.icon_list):
+ if i % self.amount == 0:
row = col.row(align=True)
- row.operator("wm.icon_info", text="", icon=icon).icon = icon
+ row.operator("wm.icon_info", text=" ", icon=icon,
+ emboss=False).icon = icon
+class CONSOLE_HT_icons(bpy.types.Header):
+ bl_space_type = 'CONSOLE'
+
+ def __init__(self, x):
+ self.amount = 10
+ self.icon_list = create_icon_list()
+
+ def draw(self, context):
+ # scroll view
+ if context.scene.icon_props.console:
+ layout = self.layout
+ layout.separator()
+ row = layout.row()
+ row.prop(context.scene.icon_props, "scroll")
+ row = layout.row(align=True)
+
+ for icon in self.icon_list[context.scene.icon_props.scroll-1:
+ context.scene.icon_props.scroll-1+self.amount]:
+ row.operator("wm.icon_info", text="", icon=icon,
+ emboss=False).icon = icon
+
+
+def menu_func(self, context):
+ self.layout.prop(bpy.context.scene.icon_props, 'console')
+
+
def register():
- icons_total = len(bpy.types.OBJECT_PT_icons._icon_list())
- icons_per_row = bpy.types.OBJECT_PT_icons._amount()
+ icons_total = len(create_icon_list())
+ icons_per_row = 10
bpy.types.Scene.icon_props = bpy.props.PointerProperty(type = IconProps)
+ IconProps.console = bpy.props.BoolProperty(
+ name='Show System Icons',
+ description='Display the Icons in the console header', default=False)
+ IconProps.expand = bpy.props.BoolProperty(default=False,
+ description="Expand, to display all icons at once")
IconProps.scroll = bpy.props.IntProperty(default=1, min=1,
max=icons_total - icons_per_row + 1,
description="Drag to scroll icons")
- IconProps.expand = bpy.props.BoolProperty(default=False,
- description="Expand, to display all icons at once")
+
+ bpy.types.CONSOLE_MT_console.append(menu_func)
def unregister():
@@ -119,9 +157,14 @@
del bpy.context.scene['icon_props']
try:
del bpy.types.Scene.icon_props
+ bpy.types.CONSOLE_MT_console.remove(menu_func)
except:
pass
+ if __name__ == "__main__":
+ # unregistering is only done automatically when run as add-on
+ bpy.types.unregister(OBJECT_PT_icons)
+ bpy.types.unregister(CONSOLE_HT_icons)
if __name__ == "__main__":
- register()
+ register()
\ No newline at end of file
More information about the Bf-extensions-cvs
mailing list