How to create gizmo such as Radius/Strength F/SHIFT+F shortcuts from sculpt mode in python?
So here is a Template
It can receive any property, note that strength is best to work with props that have min/max
Note that it should be properly implemented in your final modal class as working with globals like this is not ideal
i Did not implement the gradient effect, not sure if it that useful?
If you have any comment/question  about the code let me know,
Here is a demo of the shortcut working with some overlays props




import bpy, gpu, bgl, blf
from gpu_extras.presets import draw_circle_2d


#Bunch of globals needed 

#Private
RadiusModal=False
StrengthModal=False
prop_value=None
new_value=None 
init_mouse = None #= init mouse position
handlers= [] #=keep track of handlers 


def clean_handlers():
    for h in handlers:
        if h is not None:
            bpy.types.SpaceView3D.draw_handler_remove(h, &quot;WINDOW&quot;)
    handlers.clear()
    return None

def remap_value(value, min1=0, max1=0, min2=0, max2=0):
    return min2 + (value - min1) * (max2 - min2) / (max1 - min1)


# 88&quot;&quot;Yb    db    8888b.  88 88   88 .dP&quot;Y8     8b    d8  dP&quot;Yb  8888b.     db    88
# 88__dP   dPYb    8I  Yb 88 88   88 `Ybo.&quot;     88b  d88 dP   Yb  8I  Yb   dPYb   88
# 88&quot;Yb   dP__Yb   8I  dY 88 Y8   8P o.`Y8b     88YbdP88 Yb   dP  8I  dY  dP__Yb  88  .o
# 88  Yb dP&quot;&quot;&quot;&quot;Yb 8888Y&quot;  88 `YbodP' 8bodP'     88 YY 88  YbodP  8888Y&quot;  dP&quot;&quot;&quot;&quot;Yb 88ood8


def radius_gizmo_modal(api, property, event, Key=&quot;F&quot;, px_radius_at_1=100):  #-&gt; event == KEY
    global RadiusModal, prop_value, new_value, init_mouse, handlers
    

    if (RadiusModal==True):
        
        #if user leftclick, then apply change to property
        if (event.type==&quot;LEFTMOUSE&quot;): 
            print(&quot;[Radius]&gt;&gt; CONFIRM&quot;)
            
            setattr(api,property,new_value)
            
            #EndCleanup
            clean_handlers()
            RadiusModal=False
            prop_value=new_value=init_mouse=None
            bpy.context.area.tag_redraw()
            return {'RUNNING_MODAL'}
        
        #if user release key then quit modal witouth applying any props
        elif (event.type == Key) and  (event.value==&quot;RELEASE&quot;):
            print(&quot;[Radius]&gt;&gt; QUIT&quot;)
            
            #EndCleanup    
            clean_handlers()
            RadiusModal=False
            prop_value=new_value=init_mouse=None
            bpy.context.area.tag_redraw()
            return {'RUNNING_MODAL'}
        
        else:
            print(&quot;[Radius]&quot;)
            
            delta = (event.mouse_region_x - init_mouse[0] )/px_radius_at_1 #get mouse move on X
            new_value = prop_value + delta #translate screen unit to prop
            
            bpy.context.area.tag_redraw()
            return {'RUNNING_MODAL'}
    else:
        #if not in modal mode but user is pressing the key -&gt; Init Modal
        if (event.type==Key) and (not event.shift) and (event.value==&quot;PRESS&quot;) and (not event.is_repeat):
            print(&quot;[Radius]&gt;&gt; INIT&quot;)
            
            RadiusModal= True #Enable modal mode
            init_mouse= (event.mouse_region_x, event.mouse_region_y) #Store initial mouse position in global 
            prop_value=new_value= getattr(api, property) #Store property value in global
                
            #Add fixed circle 
            radius = px_radius_at_1 * prop_value
            def draw():
                bgl.glEnable(bgl.GL_BLEND)
                draw_circle_2d(init_mouse, [1,0.3,0.3,0.4], radius, segments=100)
                bgl.glDisable(bgl.GL_BLEND)
                
            h = bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')
            handlers.append(h)

            #Add Dynamic Circle 
            def draw():
                bgl.glEnable(bgl.GL_BLEND)
                radius =  px_radius_at_1 * new_value
                if radius&lt;1: radius = 1
                draw_circle_2d(init_mouse, [1,0.3,0.3,1], radius, segments=100)
                draw_circle_2d(init_mouse, [1,0.3,0.3,0.5], radius+1, segments=100)
                bgl.glDisable(bgl.GL_BLEND)
                
            h = bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')
            handlers.append(h)

            bpy.context.area.tag_redraw()
            return {'RUNNING_MODAL'}
    
    return None 



# .dP&quot;Y8 888888 88&quot;&quot;Yb 888888 88b 88  dP&quot;&quot;b8 888888 88  88     8b    d8  dP&quot;Yb  8888b.     db    88
# `Ybo.&quot;   88   88__dP 88__   88Yb88 dP   `&quot;   88   88  88     88b  d88 dP   Yb  8I  Yb   dPYb   88
# o.`Y8b   88   88&quot;Yb  88&quot;&quot;   88 Y88 Yb  &quot;88   88   888888     88YbdP88 Yb   dP  8I  dY  dP__Yb  88  .o
# 8bodP'   88   88  Yb 888888 88  Y8  YboodP   88   88  88     88 YY 88  YbodP  8888Y&quot;  dP&quot;&quot;&quot;&quot;Yb 88ood8

#Can work only for properties with min/max 

def strength_gizmo_modal(api, property, event, Key=&quot;F&quot;, prop_min=0, prop_max=1, min_radius=37, max_radius=217, show_gradient=True, show_font=True): #-&gt; event == SHIFT+KEY
    global StrengthModal, prop_value, new_value, init_mouse, handlers
    
    if (StrengthModal==True):
        
        #if user leftclick, then apply change to property
        if (event.type==&quot;LEFTMOUSE&quot;): 
            print(&quot;[Strength]&gt;&gt; CONFIRM&quot;)
            
            new_value= remap_value( new_value, min1=min_radius, max1=max_radius, min2=prop_min, max2=prop_max, )
            setattr(api,property,new_value)
            
            #EndCleanup
            clean_handlers()
            StrengthModal=False
            prop_value=new_value=init_mouse=None
            bpy.context.area.tag_redraw()
            return {'RUNNING_MODAL'}
        
        #if user release key then quit modal witouth applying any props
        elif (event.type == Key) and  (event.value==&quot;RELEASE&quot;):
            print(&quot;[Strength]&gt;&gt; QUIT&quot;)
            
            #EndCleanup    
            clean_handlers()
            StrengthModal=False
            prop_value=new_value=init_mouse=None
            bpy.context.area.tag_redraw()
            return {'RUNNING_MODAL'}
        
        else:
            print(&quot;[Strength]&quot;)
            
            delta = (event.mouse_region_x - init_mouse[0] )
            new_value = prop_value + delta #translate screen unit to prop
            if new_value&gt;max_radius: new_value=max_radius
            elif new_value&lt;min_radius: new_value=min_radius
            
            bpy.context.area.tag_redraw()
            return {'RUNNING_MODAL'}
    else:
        #if not in modal mode but user is pressing the key -&gt; Init Modal
        if (event.type==Key) and (event.shift) and (event.value==&quot;PRESS&quot;) and (not event.is_repeat):
            print(&quot;[Strength]&gt;&gt; INIT&quot;)
            
            StrengthModal= True #Enable modal mode
            init_mouse= (event.mouse_region_x, event.mouse_region_y) #Store initial mouse position in global 
            prop_value=new_value= remap_value( getattr(api, property), min1=prop_min, max1=prop_max, min2=min_radius, max2=max_radius, ) #Store &amp; remap property value in global
            
            #Add fixed circle 
            def draw():
                bgl.glEnable(bgl.GL_BLEND)
                draw_circle_2d(init_mouse, [1,0.3,0.3,0.5], min_radius, segments=100)
                draw_circle_2d(init_mouse, [1,0.3,0.3,0.5], max_radius, segments=100)
                bgl.glDisable(bgl.GL_BLEND)
                
            h = bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')
            handlers.append(h)

            #Add Dynamic Circle 
            def draw():
                bgl.glEnable(bgl.GL_BLEND)
                draw_circle_2d(init_mouse, [1,0.3,0.3,1], new_value, segments=100)
                draw_circle_2d(init_mouse, [1,0.3,0.3,0.5], new_value+1, segments=100)
                bgl.glDisable(bgl.GL_BLEND)
                
            h = bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')
            handlers.append(h)

            #Draw Gradient 
            if show_gradient:
                pass
                # def draw():
                #     bgl.glEnable(bgl.GL_BLEND)
                #     print(&quot;=?&quot;,new_value,&quot;,&quot;,max_radius)
                #     rang = int(new_value)
                #     opac = 1.0/rang
                #     print(rang)
                #     for i in range(rang):
                #         draw_circle_2d(init_mouse, [0,0,0,0.5], rang, segments=100)
                #     bgl.glDisable(bgl.GL_BLEND)
                    
                # h = bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')
                # handlers.append(h)

            #Draw Value as Text
            if show_font: 
                def draw(self, context):
                    txt_height = 38
                    projected_result = remap_value( new_value, min1=min_radius, max1=max_radius, min2=prop_min, max2=prop_max, )
                    digits = len(str(projected_result).split(&quot;.&quot;)[0])
                    text = f&quot;{projected_result:.3f}&quot; if digits&lt;=1 else f&quot;{projected_result:.2f}&quot; if digits==2 else f&quot;{projected_result:.1f}&quot; if digits==3 else f&quot;{int(projected_result)}&quot; #dynamic decimal truncing
                    pos_x = init_mouse[0]-(min_radius/1.3)
                    pos_y = init_mouse[1]-(txt_height/4)

                    blf.position(0,pos_x, pos_y, 0)
                    blf.color(0, 1, 1, 1, 1)
                    blf.size(0, txt_height, txt_height)
                    blf.draw(0, text)

                h = bpy.types.SpaceView3D.draw_handler_add( draw, (None, None), 'WINDOW', 'POST_PIXEL')
                handlers.append(h)

            bpy.context.area.tag_redraw()
            return {'RUNNING_MODAL'}

    return None 




#Example of Incorporation within a modal operator 

class ModalOperator(bpy.types.Operator):
    bl_idname = &quot;object.modal_operator&quot;
    bl_label = &quot;Simple Modal Operator&quot;
        
                    
    def modal(self, context, event):
        
        #Incorpore block above in workflow like this, must be on top of peckorder as it will ignore below
        r = radius_gizmo_modal( bpy.context.space_data.overlay, &quot;grid_scale&quot;, event, Key=&quot;F&quot;)
        if r is not None: return r
        r = strength_gizmo_modal( bpy.context.space_data.overlay, &quot;wireframe_opacity&quot;, event, Key=&quot;F&quot;) #For Min/Max Props, default==normalized prop
        if r is not None: return r

        #Rest of modal
        print(&quot;Running rest of modal code..&quot;)
        
        if event.type in {'ESC'}:
            return {'CANCELLED'}
        
        bpy.context.area.tag_redraw()
        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}

#Force Reload

try:
    bpy.utils.unregister_class(ModalOperator)
except:
    pass
bpy.utils.register_class(ModalOperator)