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

  • 相关阅读:
    python Matplotlib数据可视化神器安装与基本应用
    linux笔记
    appium自动化环境搭建
    C#实现局域网聊天 通讯 Socket TCP 多人
    layui 关闭弹出层方法
    allure生成漂亮的测试报告
    python内置测试框架unittest
    Python安全编程
    Python Web自动化测试
    Docker从入门到放弃
  • 原文地址:https://www.cnblogs.com/hksac/p/4867929.html
Copyright © 2011-2022 走看看