Selection.grow() is not represented on canvas

Yes ants are bit lazy :ant::zzz:, but you can force them to refresh the path by calling 2 * invert_selection.

Maybe some one will do a bug report about lazy ants…

from krita import Krita

def grow_selection(pixels=1):
    app = Krita.instance()
    invert_selection = app.action('invert_selection')

    doc = app.activeDocument()
    if not doc:
        print("No document found")
        return
        
    selection = doc.selection()
    if not selection:
        print("No selection found")
        return
        
    selection.grow(pixels, pixels)
    
    print(f"new selection width: {selection.width()}")
    print(f"new selection height: {selection.height()}")
    
    doc.setSelection(selection)
    # doc.refreshProjection()

    invert_selection.trigger()
    invert_selection.trigger()
    

grow_selection(10)

/AkiR

2 Likes