Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from anonymous/text_editor_Submenu2.py
Created April 26, 2014 18:33
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/11327515 to your computer and use it in GitHub Desktop.
Save zeffii/11327515 to your computer and use it in GitHub Desktop.
import bpy
import os
from bpy.props import EnumProperty, StringProperty
class SvScriptLoader(bpy.types.Operator):
""" Load Scripts into TextEditor """
bl_idname = "node.script_template"
bl_label = "Sverchok script template"
bl_options = {'REGISTER', 'UNDO'}
# from object in
script_path = StringProperty(name='script path')
def execute(self, context):
print(self.script_path)
bpy.ops.text.open(
filepath="C:\\blender_trunk\\2.70\\scripts\\templates_py\\ui_panel.py", internal=True)
return {'FINISHED'}
class SvTextSubMenu(bpy.types.Menu):
bl_idname = "TEXT_MT_templates_submenu"
bl_label = "Sv NodeScripts"
bl_options = {'REGISTER', 'UNDO'}
def draw(self, context):
layout = self.layout
m = [['brooo','brooo.py'], ['neeeee','neeee.py']]
for name, p in m:
layout.operator("node.script_template", text=name).script_path=p
def menu_draw(self, context):
self.layout.menu("TEXT_MT_templates_submenu")
def register():
bpy.utils.register_class(SvScriptLoader)
bpy.utils.register_class(SvTextSubMenu)
bpy.types.TEXT_MT_templates.append(menu_draw)
def unregister():
bpy.utils.unregister_class(SvScriptLoader)
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