How to display a list in the UI?

Hi everyone

Currently I have a material selectable by having them manually input the name

row = layout.row()
row.prop(Scene, “MaterialName”)

how would I change it so that they could also choose the material from a drop down menu?

Thanks

just add a menu operator !

First Operator

col.operator_menu_enum(‘view_3d.my_color1’, ‘colormenu1’, ‘Menu Selection’)



"""
 
class FIRSTOperator(bpy.types.Operator):     # When an option in the operator menu is clicked, this is called
 
 '''Operator'''
 bl_idname = 'view_3d.my_color1'
#   bl_idname = 'FIRSTOperator'
 bl_label = 'Operator'
 
 # Define possible operations
 
 colormenu1 = EnumProperty(items=(
  ('1', 'First', 'The first item'),
  ('2', 'Middle', 'The second item'),
  ('3', 'Last', 'The Third item')
 
           ))
 
 
 
 @classmethod
 def poll(cls, context):
  return context.object is not None
 
 
 def execute(self, context):
 
  global last_menu1          # Access global Var so we can later draw it in the panel
 
  last_menu1 = self.properties.colormenu1     # Store the choosen operation / Selection
  print ('selection   shade=',self.properties.colormenu1[0])
 

ect.




there is an example given in the text editor see menu for templates

happy bl

Attachments


I have a question, can such menus be expanded? or just enum properties

elaborate ?

any length you want it is an enum list defined in operator
but have to use Global vars to pass index

can you explain what you are trying to do ?

most of the time now I prefer to use Addmesh method for menu
with auto update when creating a new primitive.

happy bl