[PyQt] Multiple QMainWindow

gizmoog oguillemot at polenn.com
Tue Jul 7 10:55:06 BST 2009


I'm new in python and pyQt.
I try to launch a second MainWindow from a first MainWindow but it doesn't
work. The widget just pops and disappears immediatly.
The following code works but that's not what I want...

/usr/bin/python
#-*-coding: utf-8 -*-
from PyQt4.QtGui import *
from PyQt4.QtCore import *

import os,sys

#! /usr/bin/python
#-*-coding: utf-8 -*-
from PyQt4.QtGui import *


class fenPrincipale(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

if __name__=="__main__":
    a=QApplication(sys.argv)
    f=fenPrincipale()
    f.show()
    f2=fenPrincipale()
    f2.show()
    
    sys.exit(a.exec_())

and this one doesn't work:


#! /usr/bin/python
#-*-coding: utf-8 -*-
from PyQt4.QtGui import *
from PyQt4.QtCore import *

import os,sys

#! /usr/bin/python
#-*-coding: utf-8 -*-
from PyQt4.QtGui import *


class fenPrincipale(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        
        f2=fenSecondaire()
        f2.show()
        
class fenSecondaire(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

if __name__=="__main__":
    a=QApplication(sys.argv)
    f=fenPrincipale()
    f.show()
    sys.exit(a.exec_())


Could you help me ??
many thanks.
-- 
View this message in context: http://www.nabble.com/Multiple-QMainWindow-tp24369800p24369800.html
Sent from the PyQt mailing list archive at Nabble.com.



More information about the PyQt mailing list