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)

    #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 = layout.row(align=True)

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

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

if name == "main": register()



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.