[PyKDE] Still having problems with multiple windows

Boudewijn Rempt boud at valdyas.org
Sat Feb 1 11:19:01 GMT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 01 February 2003 08:15, star gazer wrote:
> If anyone could
> give me a clean , clear example that may help.

It's really quite simple:

#!/usr/bin/env python

from qt import *

class DialogWindow(QDialog):

    def __init__(self, *args):
        QDialog.__init__(self, *args)
        self.layout = QHBoxLayout(self)
        self.bn = QPushButton("Button" + str(self), self)
        self.layout.addWidget(self.bn)
        self.connect(self.bn, SIGNAL("clicked()"),
                     self.hide);
        
class CommandWindow(QPushButton):

    def __init__(self, *args):
        QPushButton.__init__(self, *args)
        self.connect(self, SIGNAL("clicked()"),
                     self.slotAddWindow)
        self.windows = []
                     
    def slotAddWindow(self):
        w = DialogWindow(self)
        self.windows.append(w)
        w.show()
        w.setFocus()
        
        
def main(argv):
    app = QApplication(argv)
    mw = CommandWindow("Add new window", None)
    app.setMainWidget(mw)
    mw.show()
    mw.connect(app, SIGNAL('lastWindowClosed()'), app, SLOT('quit()'))
    app.exec_loop()

if __name__ == "__main__":
    main(sys.argv)



- -- 
Boudewijn Rempt | http://www.valdyas.org/index2.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE+O55fdaCcgCmN5d8RAtusAJ94YXAz3Z29shWu7r1AY4bb7JZ8OQCg3y4A
ly3XrFknktmgWXmTdXN3Lpk=
=ln7w
-----END PGP SIGNATURE-----




More information about the PyQt mailing list