Sculpt Mode Brush Widget

Has anyone written a script that creates a pop-up type widget in sculpt mode to choose brushes in the 3d view? I was thinking about writing one, but didn’t want to waste my time if there was already one. I did some searching but didn’t see anything.

this is the closest you can get:

import bpy
from bl_ui.properties_paint_common import UnifiedPaintPanel

def main(context):
    for ob in context.scene.objects:
        print(ob)

class SCULPT_MT_brush_menu(bpy.types.Menu):
    """Tooltip"""
    bl_idname = "SCULPT_MT_brush_menu"
    bl_label = "Sculpt Brush"
    
    def draw(self, context):
        layout = self.layout
        
        #toolsettings = context.tool_settings
        #settings = UnifiedPaintPanel.paint_settings(context)
        #brush = settings.brush
        #layout.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8)
        
        flow = layout.column_flow(columns=4)
        for brush in bpy.data.brushes:
            if brush.use_paint_sculpt:
                col = flow.column()
                #col.label(icon_value=layout.icon(brush)) # doesn't get the previews in menus
                props = col.operator("wm.context_set_id", text=brush.name)
                props.data_path = "tool_settings.sculpt.brush"
                props.value = brush.name

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    bl_options = {'REGISTER', 'UNDO'}

    @classmethod
    def poll(cls, context):
        return context.active_object is not None
    
    def invoke(self, context, event):
        context.window_manager.invoke_props_popup(self, event)
        return {'FINISHED'}

    def execute(self, context):
        main(context)
        return {'FINISHED'}
    
    def draw(self, context):
        layout = self.layout

        toolsettings = context.tool_settings
        #settings = self.paint_settings(context)
        settings = UnifiedPaintPanel.paint_settings(context)
        brush = settings.brush

        if not context.particle_edit_object:
            col = layout.split().column()
            col.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8)
            #col.template_icon_view(settings, "brush") # doesn't work?

            flow = layout.column_flow(columns=4)
            for brush in bpy.data.brushes:
                if brush.use_paint_sculpt:
                    col = flow.column()
                    col.label(icon_value=layout.icon(brush)) # doesn't get the previews in menus
                    props = col.operator("wm.context_set_id", text=brush.name)
                    props.data_path = "tool_settings.sculpt.brush"
                    props.value = brush.name


def register():
    bpy.utils.register_class(SimpleOperator)
    bpy.utils.register_class(SCULPT_MT_brush_menu)


def unregister():
    bpy.utils.unregister_class(SimpleOperator)
    bpy.utils.unregister_class(SCULPT_MT_brush_menu)


if __name__ == "__main__":
    register()

bpy.ops.wm.call_menu(name=SCULPT_MT_brush_menu.bl_idname)

Also run “Simple Operator” over 3D View using spacebar. The actual preview icons are shown here, although they are small (and you can’t increase their size). Buttons can be clicked once, this is a known limitation (it’s not supposed to have operators there).

In the menu, the icons aren’t the actual brush preview images, seems to be not supported by UILayout.icon() in this context.

This is what I am looking for, and I saw this in the forum, thanx, but the only thing is that I can’t get this installed and running with a hotkey. Any explanations about how to install it please?

it’s not an addon and does not add a shortcut.

refer to the docs:
http://www.blender.org/documentation/blender_python_api_2_70a_release/info_tutorial_addon.html

it’s fairly simple to make it a proper addon with hotkey

It’s quite a extense doc…
If it is such easy why don’t you put the addon code for other people as well?
I think it would be a good thing for everybody.

well, I have real work to do, and I don’t see a demand for such an addon, plus is has severe shortcomings.