Bonjour à tous,

(je suis débutant...)
je souhaite lancer à partir d'une MainWindow une seconde MainWindow mais je n'y arrive pas... La fenêtre se lance mais disparait immédiatement.
le code suivant fonctionne (mais ne correspond pas à ce que je souhaite faire) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /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_())
et celui-ci ne fonctionne pas...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
#! /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_())
pourriez-vous m'éclairer ??
merci à tous