# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'testform.ui'
#
# Created: Sun Feb 6 10:26:44 2005
#      by: The PyQt User Interface Compiler (pyuic) 3.13
#
# WARNING! All changes made in this file will be lost!


import sys
from qt import *
    

class Form2(QMainWindow):

    def __init__(self,parent = None,name = None,fl = 0):
        QMainWindow.__init__(self,parent,name,fl)
        self.statusBar()

        if not name:
            self.setName("Form2")


        self.setCentralWidget(QWidget(self,"qt_central_widget"))

        self.pushButton13 = QPushButton(self.centralWidget(),"pushButton13")
        self.pushButton13.setGeometry(QRect(70,30,136,27))



        self.languageChange()

        self.resize(QSize(267,124).expandedTo(self.minimumSizeHint()))
        self.clearWState(Qt.WState_Polished)

        self.connect(self.pushButton13,SIGNAL("clicked()"),self.close)


    def languageChange(self):
        self.setCaption(self.__tr("Form2"))
        self.pushButton13.setText(self.__tr("pushButton13"))


    def closeEvent(self, e):
        print "in close event"
        e.accept()

    def __tr(self,s,c = None):
        return qApp.translate("Form2",s,c)

    def init(self):
        self.statusBar().hide()

class Form3(QMainWindow):
    def eventFilter(self, object, event):
        if event and (event.type() == QEvent.Close):# or event.type() == QEvent.Hide):
            print "woohoo"
        return False


    def closeEvent(self, e):
        print "in close event"
        e.accept()
    def init(self):
        self.statusBar().hide()
    def __init__(self,parent = None,name = None,fl = 0):
        QMainWindow.__init__(self,parent,name,fl)
        self.statusBar()
        #self.installEventFilter(self )
        self.clearWState(Qt.WState_Polished)


if __name__ == "__main__":
    a = QApplication(sys.argv)
    QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
    if False:
        w = Form2()
        a.setMainWidget(w)
        w.init()
        w.show()
    else:
        import qt_ui_loader
        wnd = Form3()
        wnd_c = qt_ui_loader.create( 'testform.ui', wnd,None,True )
        a.setMainWidget(wnd_c)
        wnd.init()
        #from new import instancemethod
        #wnd_c.closeEvent = instancemethod(wnd.closeEvent,wnd_c,wnd_c.__class__)
        wnd_c.installEventFilter( wnd )
        wnd_c.show()
    a.exec_loop()

