Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from anonymous/texteditor_Submenu.py
Created April 26, 2014 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/11323969 to your computer and use it in GitHub Desktop.
Save zeffii/11323969 to your computer and use it in GitHub Desktop.
import bpy
import os
from bpy.props import EnumProperty
class SvTextSubMenu(bpy.types.Menu):
bl_idname = "templates_submenu"
bl_label = "Select"
def avail_templates(self, context):
sv_path = os.path.dirname(os.path.realpath(__file__))
script_dir = "node_script_templates"
path = os.path.join(sv_path, script_dir)
items = [(t, t, "") for t in next(os.walk(path))[2]]
return items
files_popup = EnumProperty(
items=avail_templates,
name='template_files',
description='choose file to load as template')
def draw(self, context):
layout = self.layout
for i in [3,3,3,3]: #self.avail_templates(context):
# print(i)
layout.operator("object.select_all", text="Select/Deselect All")
def menu_draw(self, context):
print('im called here')
self.layout.menu("templates_submenu")
def register():
# bpy.utils.register_module(__name__)
bpy.types.TEXT_MT_format.append(menu_draw)
def unregister():
# bpy.utils.register_module(__name__)
bpy.types.TEXT_MT_format.remove(menu_draw)
if __name__ == "__main__":
print('i am registered')
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment