Skip to content

Instantly share code, notes, and snippets.

@kilon kilon/
Last active Sep 8, 2017

What would you like to do?
import bpy
import bgl
import blf
from morpheas import *
# this class is defining the action performed when the button is clicked
clase AButtonAction:
def onLeftClick(morph):
print("the button has been clicked")
morph.texture = "buttonClickedIcon"
def draw_callback_px(self, context):
#draw the morphs
class ModalDrawOperator(bpy.types.Operator):
"""Draw a line with the mouse"""
bl_idname = "view3d.modal_operator"
bl_label = "Simple Modal View3D Operator"
def __init__(self): = None
# create button
self.abutton = ButtonMorph(texture="buttonIcon",onLeftClickAction = AButtonAction)
def modal(self, context, event):
return {'RUNNING_MODAL'}
return {'PASS THROUGH'}
def invoke(self, context, event):
# create the world = World()
if context.area.type == 'VIEW_3D':
# the arguments we pass the the callback
args = (self, context)
# Add the region OpenGL drawing callback
# draw in view space with 'POST_VIEW' and 'PRE_VIEW'
self._handle = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_PIXEL')
self.mouse_path = []
return {'RUNNING_MODAL'}
else:{'WARNING'}, "View3D not found, cannot run operator")
return {'CANCELLED'}
def register():
def unregister():
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.