Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from anonymous/texteditor_Submenu.py
Created April 26, 2014 15: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/11322528 to your computer and use it in GitHub Desktop.
Save zeffii/11322528 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 = "TEXT_MT_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
# layout.prop(self, 'txt.files_popup', '')
#layout.operator("object.select_all", text="Select/Deselect All")
# access this operator as a submenu
#layout.operator_menu_enum(
# "object.select_by_type", "type", text="Select All by Type...")
#layout.operator_menu_enum(
# "node.object.select_by_type", "type", text="Select All by Type...")
#row.operator('node.sverchok_script_template', text='Template')
for i in [2,3,4,5]:#self.avail_templates(self, context):
# print(i)
layout.operator("object.select_all", text="Select/Deselect All")
def menu_draw(self, context):
self.layout.menu("TEXT_MT_templates_submenu")
def register():
bpy.utils.register_class(SvTextSubMenu)
bpy.types.TEXT_MT_templates.append(menu_draw)
def unregister():
bpy.utils.unregister_class(SvTextSubMenu)
bpy.types.TEXT_MT_templates.remove(menu_draw)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment