[Bf-committers] Python Event Listeners and Notifiers

Dan Eicher dan at trollwerks.org
Tue Nov 2 04:38:20 CET 2010

Been poking at this for a couple days and figured I'd post it to the ML
before I spent too much time on it.

Registration (non-automagic) works like operators, menus and KeyingSetInfo
(which I didn't even know existed). There's some simple logic and an
optional poll function to determine if execute() should be called
in response to an event.

A simple test case that prints to the console on a frame change event:

import bpy

class foo(bpy.types.Listener):
    bl_idname = "foo"
    bl_label = "foo"
    bl_description = "foo goodness"
    bl_category = "SCENE"
    bl_data = "FRAME"

    def poll(self, context, note):
        if note.data == "SCENE":
            return True
        return False

    def execute(self, context, note):
        print('Frame:', context.scene.frame_current)

if __name__ == "__main__":

The notifiers still need some cleaning up and probably a means to fire them
from scripts.

The WIP patch -- http://www.pasteall.org/16578/diff


More information about the Bf-committers mailing list