Reimplementing event handler

Events in PyQt4 are processed often by reimplementing event handlers.

#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
ZetCode PyQt4 tutorial 

In this example, we reimplement an
event handler. 

author: Jan Bodnar
website: zetcode.com
last edited: October 2011
"""

import sys
from PyQt4 import QtGui, QtCore

class Example(QtGui.QWidget):

    def __init__(self):
        super(Example, self).__init__()

        self.initUI()

    def initUI(self):      

        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle(‘Event handler‘)
        self.show()

    def keyPressEvent(self, e):

        if e.key() == QtCore.Qt.Key_Escape:
            self.close()

def main():

    app = QtGui.QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())

if __name__ == ‘__main__‘:
    main()

In our example, we reimplement the keyPressEvent() event handler.

def keyPressEvent(self, e):

    if e.key() == QtCore.Qt.Key_Escape:
        self.close()

If we click the Escape button, the application terminates.

时间: 2024-08-25 01:31:23

Reimplementing event handler的相关文章

SAP Sybase IQ EVENT Each time a scheduled event handler is completed

16.0 SP04 > Reference: Statements and Options > SQL Statements Defines an event and its associated handler for automating predefined actions. Also defines scheduled actions. Quick Links: Go to Parameters Go to Examples Go to Usage Go to Standards Go

linux input设备如何固定event handler

在qt开发时,碰到的问题,usb输入设备(鼠标,usb 电容屏等)上电后会自动分配input节点,比如usb鼠标插着上电后,自动分配到/dev/input/event0 mouse0,插拔一次后,节点会自动往后增加,变为/dev/input/event1mouse1 对于鼠标类型的设备,/dev/input/mouseX 的所有消息都会汇总到/dev/input/mice,因此,qt的QWS_MOUSE_PROTO输入可以指定IntelliMouse=/dev/input/mice,鼠标插拔即使

SSIS ->> Event Handler

Event Handler支持在某个事件触发的时候定义好处理该事件的逻辑,比如错误事件触发是该怎么处理.它跟Control Flow界面相似,就好像执行了另外一个包一样.Event Handler不仅支持包内的task对象,还支持对Event Hanlder事件中的task. Event Handler可以触发组件级别或者包级别的事件,包括 FireBreakpointHit:这个一般应该用在调试时:FireError:错误发生时,这个也应该是最被常用到的:FireInformation:信息级

JPA project Change Event Handler问题解决[转]

转至:http://my.oschina.net/cimu/blog/278724 这是Eclipse中的一个GUG: Bug 386171 - JPA Java Change Event Handler (Waiting) 解决方法: 1.) 退出Myeclipse(或eclipse): 2.) 进入Myeclipse(或eclipse)的安装目录: linux中: mkdir disabled mkdir disabled/features disabled/plugins mv plugi

【转】JPA project Change Event Handler / 导致eclipse十分卡

这是Eclipse中的一个GUG: Bug 386171 - JPA Java Change Event Handler (Waiting) 解决方法: 1.) 退出Myeclipse(或eclipse): 2.) 进入Myeclipse(或eclipse)的安装目录: linux中: mkdir disabled mkdir disabled/features disabled/plugins mv plugins/org.eclipse.jpt.* disabled/plugins mv f

linux kernel的中断子系统之(四):High level irq event handler

一.前言 当外设触发一次中断后,一个大概的处理过程是: 1.具体CPU architecture相关的模块会进行现场保护,然后调用machine driver对应的中断处理handler 2.machine driver对应的中断处理handler中会根据硬件的信息获取HW interrupt ID,并且通过irq domain模块翻译成IRQ number 3.调用该IRQ number对应的high level irq event handler,在这个high level的handler中

[翻译]Event Handler Description 事件处理描述

Event Handler Description 事件处理描述 (自定义控件)   How should a new event handler be defined if it does not already belong to the base class? Let's look at this using the "TfrxEditControl" common control as an example: 一个新的事件处理程序应该如何定义,如果它不属于基类?让我们看看使用&

Event Handler

在Event Handler中,有一种特殊的Event Handler,称之为Synchronizer或者Denormalizer,其作用就是为了同步“Query Database”.Query Database是为查询提供数据源的存储机制,用户在UI上看到的查询数据均来源于此数据库.因此,CQRS不仅分离了用户操作,而且分离了数据源,这样做的一个最大的优点就是,设计人员可以根据UI的需求来配置和优化Query Database,例如,可以将Query Database设计为一张数据表对应一个U

解决在SharePoint 2010/2013部署自己的Event Handler后,抛出”不能加载被引用的第三方的程序集"的问题

今天在处理客户的一个问题的时候,我们已经把我们SharePoint EventHandler依赖的第三方的TIBCO.EMS.dll注册到GAC里面了,但是日志里面还是抛出了不能加载被引用的第三方的程序集的异常. 在描述解决方案之前,我在这里把相关背景交代一下,我们知道SharePoint提供了Event handler(用户操作事件钩子)让SharePoint用户开发自己的业务逻辑.SharePoint的Event Handler说白了就是,当SharePoint用户操作SharePoint的