zoukankan      html  css  js  c++  java
  • Hiero中的Events机制

    The hiero.core.events module allows you to register method callbacks to respond to events sent by Hiero. Hiero uses this for the callback mechanism to allow Python scripts to get notifications when interesting things happen. It also allows for the creation of custom event types and for sending custom events.

    译文:

    Hiero.core.events模块允许用户注册callbacks方法去响应Hiero运行中发生的事件,Hiero通过使用这个callbacks机制让python脚本能够在关联事件发生时收到通知。Hiero也允许用户自定义事件类生成自定义的事件。

     

    An event is an object which is passed to registered callbacks.

    译文:

    event实际上是一个被传递给已注册的callbacks的对象。Callbacks响应event的时候,event会作为一个对象传递给callbacks。

     

    If the event comes from Hiero itself (and is not a custom user registered event), it contains three attributes:

    译文:

    如果事件来源于Hiero自身,且不是用户自己注册事件,那么它会包含以下三个属性:

     

    1.    type - indicates the type of the EventType (e.g. kShowContextMenu) 类型

    2.    subtype - indicates the subtype of the EventType (e.g. kTimeline)    子类型

    3.    sender (generally a view, or action which triggered the event)       触发事件

     

    The type and subtype attributes indicate the type and subtype of the event, respectively. The sender is the object that sent the event, and varies by event type (and sometimes by subtype event).

    译文:

    Type及subtype都是包含了event类型,触发事件则是发出event的对象,类型不同,触发事件也不一而论。

     

    Note

    The subtype attribute can be None. This is the case if an event is sent without a subtype. Generally, the type and subtype are strings, usually from the EventType enumeration.

    译文:

    Subtype属性可以为空,这个因为发出的事件往往也是没有子类型。但一般来说,type和subtype都是字符串型,通常来自于eventype的清单。

     

    The most basic event callback takes the following form:

     

    def eventCallback(event):

      print "Event fired with type %s, subtype %s and sender %s" % (event.type, event.subtype, str(event.sender))

  • 相关阅读:
    linux重新编译内核
    无废话ubuntu 13.4w文件共享配置
    VB6关于判断模态窗体的问题
    在.NET中快速创建一个5GB、10GB或更大的空文件
    利用虚拟光驱实现 将WINDOWS文件供虚拟机中的UBUNTU共享
    论这场云盘大战,以及各网盘的优劣
    struts2 全局格式化,格式化时间,金钱,数字
    SQL SERVER 2000/2005/2008数据库数据迁移到Oracle 10G细述
    女攻城师走在移动互联网道路的这两年
    用正则匹配多行文本
  • 原文地址:https://www.cnblogs.com/hksac/p/4867929.html
Copyright © 2011-2022 走看看