def METHOD_NAME(event: tkinter.Event[dirtree.DirectoryTree]) -> None:
    tree: dirtree.DirectoryTree = event.widget
    try:
        [item] = tree.selection()
    except ValueError:
        return
    path = dirtree.get_path(item)
    if path is None or not is_venv(path):
        return
    project_root = dirtree.get_path(tree.find_project_id(item))
    assert project_root is not None
    def on_change(*junk: object) -> None:
        assert project_root is not None
        set_venv(project_root, path if var.get() else None)
        tree.refresh()  # needed on windows
    var = tkinter.BooleanVar(value=(get_venv(project_root) == path))
    var.trace_add("write", on_change)
    cast(Any, tree.contextmenu).garbage_collection_is_lol = var
    tree.contextmenu.add_checkbutton(label="Use this Python venv", variable=var)