Adding icon to toolshelf in 2.8 I've been struggling all day to add icon with action from loop tools (circularize selection). Firstly I've added a hotkey into my keymap:



Then I looked into it's structure and tried to make it happen with ui_tool_simple template in scripting tab.

I came up with something like this:

# This example adds an object mode tool to the toolbar.
# This is just the circle-select and lasso tools tool.
import bpy
from bpy.types import WorkSpaceTool

class MyTool(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='EDIT_MESH'

    # The prefix of the idname should be your add-on name.
    bl_idname = "ui_plus.circularize"
    bl_label = "Circularize"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
    "Move selected vertices into a circle shape"
    )
    bl_icon = "ops.generic.select_circle"
    bl_widget = None
    bl_keymap = (
        ("mesh.looptools_circle", {"type": 'LEFTMOUSE', "value": 'PRESS'}, 
        {"properties": [False, "best", True, 100, False, False, False, 1, True]})
    )

    # bpy.ops.mesh.looptools_circle(custom_radius=False, fit='best', flatten=True, influence=100, lock_x=False, lock_y=False, lock_z=False, radius=1, regular=True)

    def draw_settings(context, layout, tool):
        props = tool.operator_properties("mesh.looptools_circle")
        layout.prop(props, "custom_radius")
        layout.prop(props, "fit")
        layout.prop(props, "flatten")
        layout.prop(props, "influence")
        layout.prop(props, "lock_x")
        layout.prop(props, "lock_y")
        layout.prop(props, "lock_z")
        layout.prop(props, "radius")
        layout.prop(props, "regular")

def register():
    bpy.utils.register_tool(MyTool, after={"builtin.scale_cage"}, separator=True, group=True)

def unregister():
    bpy.utils.unregister_tool(MyTool)

if __name__ == "__main__":
    register()


Although it just gives bunch of errors.

Traceback (most recent call last):
  File "\ui_tool_simple.py", line 45, in &lt;module&gt;
  File "\ui_tool_simple.py", line 39, in register
  File "2.80\scripts\modules\bpy\utils\__init__.py", line 795, in register_tool
    tool_converted = tool_from_class(tool_cls)
  File "2.80\scripts\modules\bpy\utils\__init__.py", line 792, in tool_from_class
    cls._km_action_simple(kc, context_descr, tool_def.label, keymap_data)
  File "2.80\scripts\startup\bl_ui\space_toolsystem_common.py", line 317, in _km_action_simple
    keymap_fn[0](km)
  File "2.80\scripts\startup\bl_ui\space_toolsystem_common.py", line 52, in keymap_fn
    keymap_init_from_data(km, keymap_fn.keymap_data)
  File "2.80\scripts\modules\bl_keymap_utils\io.py", line 231, in keymap_init_from_data
    for (kmi_idname, kmi_args, kmi_data) in km_items:
ValueError: too many values to unpack (expected 3)
Error: Python script failed, check the message in the system console


If I delete draw_settings, it will let go - no errors, but when I press newly created button nothing happens. When I hold mouse and drag it only moves selected faces. 



PS. Commented line meaning:

    # bpy.ops.mesh.looptools_circle(custom_radius=False, fit='best', flatten=True, influence=100, lock_x=False, lock_y=False, lock_z=False, radius=1, regular=True)


Is what python console says is being done when pressing shift + ctrl + c (as a hotkey from keymap)
To everyone who wanted to also know why this doesn't work - here after long fight I managed to make it work, here's code:

# This example adds an object mode tool to the toolbar.
# This is just the circle-select and lasso tools tool.
import bpy
from bpy.types import WorkSpaceTool

class Circularize(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='EDIT_MESH'

    # The prefix of the idname should be your add-on name.
    bl_idname = "ui_plus.circularize"
    bl_label = "Circularize"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "Move selected vertices into a circular shape"
    )
    bl_icon = "ops.generic.select_circle"
    bl_widget = None
    bl_keymap = (
        ("mesh.looptools_circle", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": [("custom_radius", False), ("radius", 1)]}),
        )


def register():
    bpy.utils.register_tool(Circularize, after={"builtin.scale_cage"}, separator=True, group=True)

def unregister():
    bpy.utils.unregister_tool(Circularize)

if __name__ == "__main__":
    register()