L'affichage d'une seconde fenetre ne se fait pas

Fermé
Signaler
Messages postés
79
Date d'inscription
samedi 24 septembre 2016
Statut
Membre
Dernière intervention
12 mai 2021
-
Bonjour, bonsoir,

J'ai un sous menu dans une fenêtre. Celui-ci est sensé ouvrir une seconde fenêtre lorsque l'on clique dessus.
Lors de l’exécution, la 1ere fenêtre s'affiche mais pas la seconde.
Au lieu de cela le programme se termine (semble-t-il normalement).
Je joints le code si quelqu'un veut bien y jeter un œil.
Merci de votre aide.

Je suis sous Python 3.7
J'utilise Pycharm comme IDE
Le seconde fenêtre a été créée avec QtDesigner

import sys
from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication
from PyQt5 import QtCore, QtGui, QtWidgets

class basicMenubar(QMainWindow):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self.initUI()

def initUI(self):

self.setGeometry(0, 0, 500, 500)

ouvrirAction = QAction('&Ouvrir', self)
ouvrirAction.setShortcut('Ctrl+Q')
ouvrirAction.setStatusTip('Ouvrir visuClient')
ouvrirAction.triggered.connect(Ui_Form_visucli.affichVisuCli)
self.statusBar()

menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(ouvrirAction)


self.setWindowTitle('PyQt5 Basic Menubar')
self.show()




# ----------------------------------------------------------------------------------------------------------------------

class Ui_Form_visucli(object):
def setupUi(self, Form_visucli):
Form_visucli.setObjectName("Form_visucli")
Form_visucli.resize(1061, 294)
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
Form_visucli.setFont(font)
self.cBox_nomClient = QtWidgets.QComboBox(Form_visucli)
self.cBox_nomClient.setGeometry(QtCore.QRect(10, 50, 121, 21))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.cBox_nomClient.setFont(font)
self.cBox_nomClient.setObjectName("cBox_nomClient")
self.cBox_nomClient.addItem("")
self.cBox_nomClient.addItem("")
self.cBox_nomClient.addItem("")
self.cBox_nomClient.addItem("")
self.cBox_nomClient.addItem("")
self.cBox_nomClient.addItem("")
self.cBox_nomClient.addItem("")
self.cBox_nomClient.addItem("")
self.label_nom = QtWidgets.QLabel(Form_visucli)
self.label_nom.setGeometry(QtCore.QRect(250, 60, 71, 16))
font = QtGui.QFont()
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.label_nom.setFont(font)
self.label_nom.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_nom.setObjectName("label_nom")
self.label_prenom = QtWidgets.QLabel(Form_visucli)
self.label_prenom.setGeometry(QtCore.QRect(240, 90, 81, 16))
font = QtGui.QFont()
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.label_prenom.setFont(font)
self.label_prenom.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_prenom.setObjectName("label_prenom")
self.label_adresse = QtWidgets.QLabel(Form_visucli)
self.label_adresse.setGeometry(QtCore.QRect(230, 120, 91, 16))
font = QtGui.QFont()
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.label_adresse.setFont(font)
self.label_adresse.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_adresse.setObjectName("label_adresse")
self.label_cdp = QtWidgets.QLabel(Form_visucli)
self.label_cdp.setGeometry(QtCore.QRect(220, 150, 101, 16))
font = QtGui.QFont()
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.label_cdp.setFont(font)
self.label_cdp.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_cdp.setObjectName("label_cdp")
self.label_ville = QtWidgets.QLabel(Form_visucli)
self.label_ville.setGeometry(QtCore.QRect(270, 180, 47, 13))
font = QtGui.QFont()
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.label_ville.setFont(font)
self.label_ville.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_ville.setObjectName("label_ville")
self.LineEd_nom = QtWidgets.QLineEdit(Form_visucli)
self.LineEd_nom.setGeometry(QtCore.QRect(360, 60, 113, 20))
self.LineEd_nom.setObjectName("LineEd_nom")
self.LineEd_Prenom = QtWidgets.QLineEdit(Form_visucli)
self.LineEd_Prenom.setGeometry(QtCore.QRect(360, 90, 113, 20))
self.LineEd_Prenom.setObjectName("LineEd_Prenom")
self.LineEd_adresse = QtWidgets.QLineEdit(Form_visucli)
self.LineEd_adresse.setGeometry(QtCore.QRect(360, 120, 113, 20))
self.LineEd_adresse.setObjectName("LineEd_adresse")
self.LineEd_cdp = QtWidgets.QLineEdit(Form_visucli)
self.LineEd_cdp.setGeometry(QtCore.QRect(360, 150, 113, 20))
self.LineEd_cdp.setObjectName("LineEd_cdp")
self.LineEd_ville = QtWidgets.QLineEdit(Form_visucli)
self.LineEd_ville.setGeometry(QtCore.QRect(360, 180, 113, 20))
self.LineEd_ville.setObjectName("LineEd_ville")
self.tableWidget = QtWidgets.QTableWidget(Form_visucli)
self.tableWidget.setGeometry(QtCore.QRect(510, 50, 541, 141))
self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setColumnCount(5)
self.tableWidget.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(4, item)

self.retranslateUi(Form_visucli)
QtCore.QMetaObject.connectSlotsByName(Form_visucli)

def retranslateUi(self, Form_visucli):
_translate = QtCore.QCoreApplication.translate
Form_visucli.setWindowTitle(_translate("Form_visucli", "Visualisation d\'un client"))
self.cBox_nomClient.setItemText(0, _translate("Form_visucli", "Charlise Theron"))
self.cBox_nomClient.setItemText(1, _translate("Form_visucli", "Scarlett Johansson"))
self.cBox_nomClient.setItemText(2, _translate("Form_visucli", "Megan Fox"))
self.cBox_nomClient.setItemText(3, _translate("Form_visucli", "Jessica Alba"))
self.cBox_nomClient.setItemText(4, _translate("Form_visucli", "Michelle Pfeiffer"))
self.cBox_nomClient.setItemText(5, _translate("Form_visucli", "Cameron Diaz"))
self.cBox_nomClient.setItemText(6, _translate("Form_visucli", "Jean Seberg"))
self.cBox_nomClient.setItemText(7, _translate("Form_visucli", "Natalie Portman"))
self.label_nom.setText(_translate("Form_visucli", "Nom"))
self.label_prenom.setText(_translate("Form_visucli", "Prénom"))
self.label_adresse.setText(_translate("Form_visucli", "Adresse"))
self.label_cdp.setText(_translate("Form_visucli", "Code postal"))
self.label_ville.setText(_translate("Form_visucli", "Ville"))
item = self.tableWidget.horizontalHeaderItem(0)
item.setText(_translate("Form_visucli", "id_Veh"))
item = self.tableWidget.horizontalHeaderItem(1)
item.setText(_translate("Form_visucli", "New Column"))
item = self.tableWidget.horizontalHeaderItem(2)
item.setText(_translate("Form_visucli", "id_Cli"))
item = self.tableWidget.horizontalHeaderItem(3)
item.setText(_translate("Form_visucli", "veh_marque"))
item = self.tableWidget.horizontalHeaderItem(4)
item.setText(_translate("Form_visucli", "veh_date"))


def affichVisuCli(self):
Form_visucli = QtWidgets.QWidget()
ui = Ui_Form_visucli()
ui.setupUi(Form_visucli)
Form_visucli.setWindowModality(QtCore.Qt.ApplicationModal).show()


if __name__ == '__main__':

app = QApplication(sys.argv)
ex = basicMenubar()
sys.exit(app.exec_())




Configuration: Windows / Firefox 82.0