I'm working in a Python application that have to launch multiples windows. The soft works, but the cmd is spammed by lines:
"QLayout: Attempting to add QLayout "" to splash_direction_App "", which already has a layout"
"QLayout::addChildLayout: layout "" already has a parent"
by searching on the internet, i found that's an issue with my inheritance définition, especially with the layout ones. but i can''t manage to resolve the issue.
class App(QtWidgets.QWidget):
""" Process de connexion au logiciel de ticketing"""
def __init__(self):
super().__init__()
self.setWindowTitle("tests")
self.resize(400,200)
self.move(1500,100)
self.setup_Main_UI()
self.setStyleSheet("font: 10pt;")
#####Mise en forme de la fenetre de connexion
def setup_Main_UI(self):
self.log_layout=QtWidgets.QGridLayout(self)
self.log_layout.setAlignment(Qt.AlignCenter)
#main label
self.log_Title=QtWidgets.QLabel("Identification")
self.log_Title.setAlignment(Qt.AlignCenter)
self.log_Title.setAlignment(Qt.AlignHCenter)
self.log_Title.setStyleSheet("font: bold;")
self.log_Title_spacer_layout=QtWidgets.QVBoxLayout()
self.log_Title_spacer=QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
self.log_Title_spacer_layout.addSpacerItem(self.log_Title_spacer)
#button Admin
self.identifiant_label=QtWidgets.QLabel("Identifiant")
self.identifiant_Entry=QtWidgets.QLineEdit(self)
self.mdp_label=QtWidgets.QLabel("Mot de passe")
self.mdp_Entry=QtWidgets.QLineEdit(self)
self.mdp_Entry.setEchoMode(QtWidgets.QLineEdit.Password)
self.error_label=QtWidgets.QLabel("")
self.log_button=QtWidgets.QPushButton("Connexion")
self.log_button.clicked.connect(self.log_ID)
self.log_layout.addWidget(self.log_Title,0,0)
self.log_layout.addLayout(self.log_Title_spacer_layout,1,0)
self.log_layout.addWidget(self.identifiant_label,2,0)
self.log_layout.addWidget(self.identifiant_Entry,2,1)
self.log_layout.addWidget(self.mdp_label, 3,0)
self.log_layout.addWidget(self.mdp_Entry, 3,1)
self.log_layout.addWidget(self.error_label,5,1)
self.log_layout.addWidget(self.log_button, 7,1)
def log_ID (self):
""" Analyse de l'identifiant et mdp, puis lancement du bon interface utilisateur Utilisateur/administrateur/direction"""
self.identifiant=self.identifiant_Entry.text()
self.mdp=self.mdp_Entry.text()
verrouille=True
while verrouille :
logging_value=(self.identifiant,[self.mdp])
if logging_value in super_user.items():
self.splash_App_launch()
self.close()
verrouille=False
def splash_App_launch(self):
"""Lance la fenêtre de choix de connexion admin en cas de clic sur le bouton
"""
# crée la 2ème fenêtre
self.splash_App = splash_App()
# rend modale la 2ème fenêtre (la 1ère fenêtre sera inactive)
self.splash_App.setWindowModality(QtCore.Qt.ApplicationModal)
# affiche la 2ème fenêtre
self.splash_App.show()
self.close()
class splash_App(QtWidgets.QWidget):
"""Fenetre de choix pour les utilisateurs ayant plsueirs accès"""
def __init__(self):
super(splash_App,self).__init__()
self.setWindowTitle("Mails service carte expert")
self.resize(400,200)
self.move(1500,100)
self.setStyleSheet("font: 10pt;")
self.main_layout=QtWidgets.QGridLayout(self)
self.main_layout.setAlignment(Qt.AlignCenter)
#main label
self.main_Title=QtWidgets.QLabel("Outils de ticketing mails Carte Expert")
self.main_Title.setAlignment(Qt.AlignCenter)
self.main_Title.setAlignment(Qt.AlignHCenter)
self.main_Title.setStyleSheet("font: bold;")
#button Admin
self.Admin_Layout=QtWidgets.QHBoxLayout(self)
self.Admin_Button=QtWidgets.QPushButton("", self)
self.Admin_Button.setIconSize(QtCore.QSize(64,64))
self.Admin_Button.setMaximumWidth(64)
self.Admin_spacer=QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
self.Admin_label=QtWidgets.QLabel("Accès Administrateur")
self.Admin_Button.clicked.connect(self.close_open_UI_admin)
self.Admin_Layout.addWidget(self.Admin_Button)
self.Admin_Layout.addSpacerItem(self.Admin_spacer)
self.Admin_Layout.addWidget(self.Admin_label)
#spacers
self.Title_spacer=QtWidgets.QSpacerItem(0,0,QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Minimum)
self.icones_spacer=QtWidgets.QSpacerItem(50,50,QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
#button Utilisateur
self.User_Layout=QtWidgets.QHBoxLayout(self)
self.User_Button=QtWidgets.QPushButton("", self)
self.User_Button.setIconSize(QtCore.QSize(64,64))
self.User_Button.setMaximumWidth(64)
self.User_label=QtWidgets.QLabel("Accès Utilisateur")
self.User_spacer=QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
self.User_Button.clicked.connect(self.close_open_UI_user)
self.User_Layout.addWidget(self.User_Button)
self.User_Layout.addSpacerItem(self.User_spacer)
self.User_Layout.addWidget(self.User_label)
self.Glob_icon_layout=QtWidgets.QHBoxLayout()
self.Glob_icon_layout.addLayout(self.User_Layout)
self.Glob_icon_layout.addSpacerItem(self.icones_spacer)
self.Glob_icon_layout.addLayout(self.Admin_Layout)
self.main_layout.addWidget(self.main_Title,1,0)
self.main_layout.setVerticalSpacing(50)
self.main_layout.addLayout(self.Glob_icon_layout,3,0)
def close_open_UI_admin(self):
"""ferme la fenetre et lance l'environnement choisi"""
self.UI_admin=Ui_Admin_livrable.App_Admin()
self.UI_admin.setWindowModality(QtCore.Qt.ApplicationModal)
self.UI_admin.show()
self.close()
def close_open_UI_user(self):
"""ferme la fenetre et lance l'environnement choisi"""
self.UI_user=Ui_User_livrable.App_User()
self.UI_user.setWindowModality(QtCore.Qt.ApplicationModal)
self.UI_user.show()
self.close()