How to make a button link to a DataLibrary using python?
i took the liberty to make an addon out of it.
It's a bit convoluted, so i made the simple version and EXTRA with file picker, it's mostly from
https://www.youtube.com/watch?v=9fuFDHR-UkE&amp;list=PLa1F2ddGya_8acrgoQr1fTeIuQtkSd6BW&amp;index=6
it adds a panel default 'N' key
the panel can be merged with existing panels by modifying bl_category
just create a file in your blender instal folder /Version Nr/Scripts/Addons/
name it anything.py
then in blender after a restart go to preference/addons search for &quot;Link data&quot; and enable it.
hope that saves you a headache. hehe

bl_info = {
    &quot;name&quot; : &quot;Link to Data Library&quot;,
    &quot;author&quot; : &quot;Daniel&quot;,
    &quot;description&quot; : &quot;Add description Here&quot;,
    &quot;blender&quot; : (2, 80, 0),
    &quot;version&quot; : (0, 0, 1),
    &quot;location&quot; : &quot;&quot;,
    &quot;warning&quot; : &quot;&quot;,
    &quot;category&quot; : &quot;Generic&quot;
}

import bpy

class OBJECT_OT_link_data(bpy.types.Operator):
    &quot;&quot;&quot;Tool tip thingy&quot;&quot;&quot;
    bl_label = &quot;Link Data&quot;
    bl_idname = &quot;object.link_data&quot;
    bl_options = {&quot;REGISTER&quot;, &quot;UNDO&quot;}
    bl_context = &quot;objectmode&quot;

    def execute(self, context):

        filepath = r&quot;C:\\path\example.blend&quot;

        coll_name = &quot;collection name&quot;

        link = False

        with bpy.data.libraries.load(filepath, link=link) as (data_from, data_to):
            data_to.collections = [c for c in data_from.collections if c.startswith(coll_name)]

        for coll in data_to.collections:
            if coll is not None:
               bpy.context.scene.collection.children.link(coll)

        return {&quot;FINISHED&quot;}

class VIEW3D_PT_Link_Data(bpy.types.Panel):
    &quot;&quot;&quot;Tool tip thingy&quot;&quot;&quot;
    bl_label = &quot;Link To Data&quot;
    bl_category = &quot;Link Data&quot;
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_context = &quot;objectmode&quot;

    def draw(self, context):
        layout = self.layout

        col = layout.column()

        col.operator(&quot;OBJECT_OT_link_data&quot;,
            text=&quot;link data&quot;,
            icon=&quot;PACKAGE&quot;
        )


def register():
    bpy.utils.register_class(OBJECT_OT_link_data)
    bpy.utils.register_class(VIEW3D_PT_Link_Data)

def unregister():
    bpy.utils.unregister_class(OBJECT_OT_link_data)
    bpy.utils.unregister_class(VIEW3D_PT_Link_Data)



if __name__ == &quot;__main__&quot;:
    register()



Modified version with EXTRA bits
bl_info = {
    &quot;name&quot; : &quot;Link to Data Library&quot;,
    &quot;author&quot; : &quot;Daniel&quot;,
    &quot;description&quot; : &quot;Add description Here&quot;,
    &quot;blender&quot; : (2, 80, 0),
    &quot;version&quot; : (0, 0, 1),
    &quot;location&quot; : &quot;&quot;,
    &quot;warning&quot; : &quot;&quot;,
    &quot;category&quot; : &quot;Generic&quot;
}

import bpy

class OBJECT_OT_link_data(bpy.types.Operator):
    &quot;&quot;&quot;Tool tip thingy&quot;&quot;&quot;
    bl_label = &quot;Link Data&quot;
    bl_idname = &quot;object.link_data&quot;
    bl_options = {&quot;REGISTER&quot;, &quot;UNDO&quot;}
    bl_context = &quot;objectmode&quot;

    def execute(self, context):

        filepath = bpy.path.abspath(context.scene.DanielLinkFile)

        coll_name = context.scene.DanielLinkCollection

        link = context.scene.DanielLink

        with bpy.data.libraries.load(filepath, link=link) as (data_from, data_to):
            data_to.collections = [c for c in data_from.collections if c.startswith(coll_name)]

        for coll in data_to.collections:
            if coll is not None:
               bpy.context.scene.collection.children.link(coll)

        return {&quot;FINISHED&quot;}

class VIEW3D_PT_Link_Data(bpy.types.Panel):
    &quot;&quot;&quot;Tool tip thingy&quot;&quot;&quot;
    bl_label = &quot;Link To Data&quot;
    bl_category = &quot;Link Data&quot;
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_context = &quot;objectmode&quot;

    def draw(self, context):
        layout = self.layout

        col = layout.column()

        col.prop(context.scene, &quot;DanielLinkFile&quot;)
        col.prop(context.scene, &quot;DanielLinkCollection&quot;)
        col.prop(context.scene, &quot;DanielLink&quot;)

        col.operator(&quot;OBJECT_OT_link_data&quot;,
            text=&quot;link data&quot;,
            icon=&quot;PACKAGE&quot;
        )


def register():
    bpy.types.Scene.DanielLinkFile = bpy.props.StringProperty(name=&quot;Link File&quot;,subtype=&quot;FILE_PATH&quot;, default=r&quot;C:\\path\example.blend&quot;)
    bpy.types.Scene.DanielLinkCollection = bpy.props.StringProperty(name=&quot;Link Collection&quot;,default=&quot;collection name&quot;)
    bpy.types.Scene.DanielLink = bpy.props.BoolProperty(name=&quot;Link&quot;,default=False)

    bpy.utils.register_class(OBJECT_OT_link_data)
    bpy.utils.register_class(VIEW3D_PT_Link_Data)

def unregister():
    del bpy.types.Scene.DanielLinkFile
    del bpy.types.Scene.DanielLinkCollection
    del bpy.types.Scene.DanielLink
    bpy.utils.unregister_class(OBJECT_OT_link_data)
    bpy.utils.unregister_class(VIEW3D_PT_Link_Data)



if __name__ == &quot;__main__&quot;:
    register()

```