Skip to main content
changed panel to have editable property that always updates with selection, not just displays it
Source Link
patmo141
  • 775
  • 7
  • 16

Why not just access the selected object's name when you need it? Blender panels are updated when blender re-draws. This only happens with user interaction so blender will check the selected object at a rate that is appropriate and you never have to worry! That's what the whole "context" thing is for. Unless there is some other reason you need to monitor selection I think you might be over complicating things.

class MyPanel(bpy.types.Panel): def draw(self, context): layout = self.layout row = layout.row() if len(context.selected_objects): txtob = context.selected_objects[0].name  else:  txt = 'None'    row.labelprop(text =ob, txt"name") 

Why not just access the selected object's name when you need it? Blender panels are updated when blender re-draws. This only happens with user interaction so blender will check the selected object at a rate that is appropriate and you never have to worry! That's what the whole "context" thing is for. Unless there is some other reason you need to monitor selection I think you might be over complicating things.

class MyPanel(bpy.types.Panel): def draw(self, context): layout = self.layout row = layout.row() if len(context.selected_objects): txt = context.selected_objects[0].name  else:  txt = 'None'    row.label(text = txt) 

Why not just access the selected object's name when you need it? Blender panels are updated when blender re-draws. This only happens with user interaction so blender will check the selected object at a rate that is appropriate and you never have to worry! That's what the whole "context" thing is for. Unless there is some other reason you need to monitor selection I think you might be over complicating things.

class MyPanel(bpy.types.Panel): def draw(self, context): layout = self.layout row = layout.row() if len(context.selected_objects): ob = context.selected_objects[0] row.prop(ob, "name") 
Source Link
patmo141
  • 775
  • 7
  • 16

Why not just access the selected object's name when you need it? Blender panels are updated when blender re-draws. This only happens with user interaction so blender will check the selected object at a rate that is appropriate and you never have to worry! That's what the whole "context" thing is for. Unless there is some other reason you need to monitor selection I think you might be over complicating things.

class MyPanel(bpy.types.Panel): def draw(self, context): layout = self.layout row = layout.row() if len(context.selected_objects): txt = context.selected_objects[0].name else: txt = 'None' row.label(text = txt)