Except error QSplashScreen
Bonjour,
je suis actuellement en train de gérer les éventuelles erreurs lors de l’exécution d'un programme.
Pour simuler ces erreurs, je place simplement des "fautes de frappe" dans certaines lignes.
par exemple j'ajoute un "a" en ligne 19 pour voir comment le programme s'en sort.
NB: je suis sous Spyder.
En gardant l'exemple ci dessus (cas du "a" en ligne 19 ; et par rapport aux lignes de code ci dessous):
Le Qsplash qui s'affiche bien, puis l'arrivée sur le "a" implique bien une entrée dans le try de la ligne 31.
La console m'indique aussi correctement le résultat du print(sys.stderr) et le self.splash.close() est lui aussi correctement executé.
par contre, après cela, niveau console, il semble que quelque chose ne soit pas très propre là dedans...
En effet, normalement lorsque je ferme une application, la console me renvoie un : In [#]: que je comprend comme une invitation de la console m'indiquant qu'elle est prête à relancer quelque chose.
dans le cas ci dessus, la fermeture apparait incomplète, je n'ai pas de In [#] qui apparait dans la console et je suis obligé de restart le noyau pour relancer l'application... pourtant, en visuel, je n'ai aucune application à l'écran...
Des idées? pour faire un truc un peu plus propre?
ci dessous le main de lancement,
merci :-)
Code:
1 2 3 4 5 6 7 8
| from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QMessageBox, QSplashScreen
from widgets_instance_glob import creation_de_tous_les_widgets
from mise_en_forme_demande_glob import construction_fenetre
from test_prerequis_lancement import test_folder_access
import sys
import os |
Code:
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| class Fenetre_Principale(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
try:
check_parameters = False
check_parameters = test_folder_access(self)
except:
QMessageBox.information(QWidget(), "Pb d'acces reseau")
if check_parameters == True:
try:
erreur = "Erreur Lors de la création du Widget principal"
self.fenetre_widget = QWidget()
erreur = "Erreur Lors de la création des widgets relatifs aux onglets"
creation_de_tous_les_widgets(self)
erreur = "Erreur Lors de la construction de la fenetre, voir les layouts"
construction_fenetre(self)
erreur = "Erreur vis à vis du splashscreen"
self.splash.finish(self)
erreur = "Erreur Lors de l'affichage maximisé de la fenetre"
self.showMaximized()
except:
print(sys.stderr)
try:
self.splash.close()
except:
print("pas de splash screen instancié au moment de l'erreur")
QMessageBox.information(QWidget(), "Erreur d'execution", erreur)
sys.exit(1)
if __name__ == "__main__":
try:
test_acces = os.listdir(r"path")
except:
test_acces = False
QMessageBox.information(QWidget(), 'Demandeur inconnu ou aucun acces réseau ', "blabla de gestion d'erreur")
if not test_acces == False:
appli = QApplication(sys.argv)
fenetre_main = Fenetre_Principale()
sys.exit(appli.exec_()) |