Selection in a panel for blender 2.8

I have created a panel in which I like to make elements selectable. I know that before the 2.8 version, it was

row.prop(obj, ‘select’, …)

to add a checkbox in the panel.

I know the new way to select an object is : obj.select_set(state=True) but how to do that in a panel ?
I tried :

row.prop(obj, ‘select_set’, …)

not working.
Here my draw code :

def draw(self, context):
layout = self.layout
scene = context.scene
objs = scene.objects

    layout.label(text = "Lights in current scene")
    for obj in objs:
        if obj.type == 'LIGHT':
            row = layout.row()
            # here the code to select a light
            row.prop(, 'type', text='') # type of the light (sun, area, spot, point)
            row.prop(obj, 'name',text='') 
            row.prop(, 'color', text='') # color of the light
            row.prop(, 'energy', text='') # power of the light

Can someone help me how to select a light (or anything) in a panel ?


You can get the old method back by adding a BoolProperty to bpy.types.Object, and setting its get/set callbacks to the new functions.

import bpy

class PANEL_PT_simple(bpy.types.Panel):
    bl_label = ""
    bl_space_type = "VIEW_3D"
    bl_region_type = "WINDOW"

    def draw(self, context):
        obj = context.object
        if obj:
            layout = self.layout
            layout.prop(obj, "select")

if __name__ == '__main__': = bpy.props.BoolProperty(
        set=lambda o, val: o.select_set(val),
        get=lambda o: o.select_get())


Thanks a lot, It isn’t working in the main fonction but I put the code in the register fonction and it work like a charm.