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))

  • 相关阅读:
    贪婪算法
    递归 快速排序
    递归 判断数组最大数字
    加法递归
    快速排序
    二分查找
    介绍求解AX=b:可解性与解的结构
    消元法求解线性方程组
    内容说明-线性代数
    gis
  • 原文地址:https://www.cnblogs.com/hksac/p/4867929.html
Copyright © 2011-2022 走看看