0

react to all events (test code)

Hi all,

I am trying to write a python snippet that echos all events in RV so I can get a grip on the various event types used in RV and their attributes.

I have read the documentation on bind() and it says:

     The most basic version of bind() takes the name of the event and a function to call when the event occurs

Is it possible to bind a function to all events though?

 

Cheers,

frank

댓글 3개

  • 0
    Avatar
    Alan Trombla

    Hi Frank,

    If you add "-debug events" as the final args to an RV command line, you'll get info about all the events emitted and processed by RV (you might want to redirect the output to a file).  In the output, when an event is "handled" that means processing is stopped at that point (otherwise the same event may be processed by many bindings).  The latest versions of RV including timing information here, so you can see how long it takes to process various events.

    I'd also recommend checking out the table that describes the Event object interface (Chap 5 of the ref manual) here:

    http://www.tweaksoftware.com/static/documentation/rv/current/html/rv_reference.html#magicparlabel-1917

    Note that different events have different interfaces (for example most of the "internal" events have "contents()" but pointer events do not).

    Hope that helps,

    Alan

     

  • 0
    Avatar
    Michael Morehouse

    For future reference, this works fairly well:

     

    for event, doc in sorted(rv.commands.bindings()):
        def _builder(event):
            def got(s):
                try:
                    try:
                      try:
                         try:
                            print('GOT::%s, %s --> STRING %s' % (event, s.contents(), rv.commands.getStringProperty(s.contents())))
                         except:
                            print('GOT::%s, %s --> INT %s' % (event, s.contents(), rv.commands.getIntegerProperty(s.contents())))
                      except:
                         print('GOT::%s, %s --> FLOAT %s' % (event, s.contents(), rv.commands.getFloatProperty(s.contents())))
                      except:
                         print('GOT::%s, %s' % (event, s.contents()))
                   except:
                      print('GOT::%s' % event)
                s.reject()
             return got

          rv.commands.bind('default', 'global', event, _builder(event), doc)

    It's not pretty, but it allows you to do a bit more than just echo events.

  • 0
    Avatar
    Michael Morehouse

    Should point out that the above works only with:

    from __future__ import print_command

     

댓글을 남기려면 로그인하세요.