0
$\begingroup$

So,I was trying to access these key indentifiers in the greasepencil color data block in a menu for "faster switching" between GPcolors- bpy.context.scene.grease_pencil.palettes.active.colors.keys() Tried using bpy_struct's like row.prop ,row.template_list,row.menu,however couldn't get any output.Any way to access these key identifiers in a menu?

mport bpy from bpy.types import Menu

class GPcolorsMenu(bpy.types.Menu): bl_label = "GPcolors" bl_idname = "gpencil.GPcolorSwitch"

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

    #display active palette 
    palette = bpy.context.scene.grease_pencil.palettes.active
    row = layout.row(align=True)
    row.label(palette.name, icon_value=layout.icon(palette))



    col = layout.column(align=True)
    col.separator()

    #display GPcolor [keys()] for switching in a menu 

    key = bpy.context.scene.grease_pencil.palettes.active.colors.keys()
    for i in key:
        row = layout.row(align=True)
        row.prop(i,'name',text='')

    #row = layout.row(align=True)
    #layout.template_list(key)  

def register(): bpy.utils.register_class(GPcolorsMenu)

def unregister(): bpy.utils.unregister_class(GPcolorsMenu)

if name == "main": register()

bpy.ops.wm.call_menu(name=GPcolorsMenu.bl_idname)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.