index_copy.py is a copy of index.py (I want to test with the copy ) and the total script is a desktop apllication created with the Qt Designer and PyQt5.
index.py:
[python]
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# import os :
import os
from os import path
import sys
from pathlib import Path
import logging
# Fix qt import error
# Include this file before import PyQt5
def _append_run_path():
if getattr(sys, 'frozen', False):
pathlist = []
# If the application is run as a bundle, the pyInstaller bootloader
# extends the sys module by a flag frozen=True and sets the app
# path into variable _MEIPASS'.
pathlist.append(sys._MEIPASS)
# the application exe path
_main_app_path = os.path.dirname(sys.executable)
pathlist.append(_main_app_path)
# append to system path enviroment
os.environ["PATH"] += os.pathsep + os.pathsep.join(pathlist)
logging.error("current PATH: %s", os.environ['PATH'])
_append_run_path()
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.uic import loadUiType
###########################################################################
import time
import datetime
##########################################################################
# import du module math pour travailler avec la methode log10 :
import math
##########################################################################
# import du module sqlite3 pour travailler avec table et bdd :
import sqlite3
#################################################################################
#import du module Prettytable pour avoir contenu du fichier texte bien organise :
from prettytable import from_db_cursor
################################################################################
# appel aux contenus des fichiers externes (info.py,raccourcis_clavier.py) :
#################################################################################
from app_ddm import Ui_MainWindow
# import contenu du fichier info.py :
from info import *
#####################################
# import contenu du fichier raccourcis_clavier.py :
from raccourcis_clavier import *
############################################################################
# import UI_File :
FORM_CLASS,_ = loadUiType(path.join(path.dirname(__file__),"app_ddm.ui"))
#Initiate UI_File :
class MainApp(QMainWindow,FORM_CLASS) :
def __init__(self,parent=None) :
super(MainApp,self).__init__(parent)
QMainWindow.__init__(self)
self.setupUi(self)
self.window_UI()
###############################################################
#Fonction pour afficher la fenetre d'information sur l'application
def window_a_propos_de_l_application(self):
self.window=QtWidgets.QMainWindow()
self.ui=info_Window()
self.ui.setup_info(self.window)
self.window.show()
def window_raccourcis_clavier(self):
self.window=QtWidgets.QMainWindow()
self.ui=raccourci_clavier_Window()
self.ui.setup_raccourci_clavier(self.window)
self.window.show()
def resource_path(self,relative_path):
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
print(base_path)
except Exception:
base_path = os.path.abspath(".")
print(base_path)
return os.path.join(base_path, relative_path)
################################################################################
def window_UI(self):
#root = QFileInfo(__file__).absolutePath() #for absolute path of the icons
self.setWindowTitle("correction ddm faisceau")
self.setFixedWidth(836)
self.setFixedHeight(510)
#####################################################
# appel de la fonction d'action sur les boutons :
#####################################################
self.actions_sur_les_boutons()
########################################################
# appel des fonctions d'affichage des unites de mesure :
########################################################
self.afficher_unite_de_mesure_loc35R()
self.afficher_unite_de_mesure_gp35R()
self.afficher_unite_de_mesure_loc35L()
self.afficher_unite_de_mesure_gp35L()
########################################################
# appel de la fonction d'affichage de la date :
########################################################
self.afficher_date_ils35R()
self.afficher_date_ils35L()
#########################################################
# appel de la fonction d'affichage de l'heure :
########################################################
self.timer = QTimer(self)
self.timer.timeout.connect(self.afficher_time_ils35L)
self.timer.timeout.connect(self.afficher_time_ils35R)
self.timer.start(1000)
######################################################
# appel des fonctions d'etats des checkbuttons :
######################################################
self.etat_checkbutton_valeur_de_correction_loc35R()
self.etat_checkbutton_valeur_de_correction_gp35R()
self.etat_checkbutton_valeur_de_correction_loc35L()
self.etat_checkbutton_valeur_de_correction_gp35L()
#############################################################
#option pour rendre lineEdit_declaration_OK_or_NO invisibe :
#############################################################
self.lineEdit_declaration_OK_or_NO_cev_loc35R.setVisible(False)
self.lineEdit_declaration_OK_or_NO_cev_gp35R.setVisible(False)
self.lineEdit_declaration_OK_or_NO_cev_loc35L.setVisible(False)
self.lineEdit_declaration_OK_or_NO_cev_gp35L.setVisible(False)
###########################################################
#pour renommer les tabs du QTabwidget partie cev (ILS 35R):
###########################################################
self.tabWidget_tabs_cev_ils35R.setTabText(0, "loc 35R")
self.tabWidget_tabs_cev_ils35R.setTabText(1, "gp 35R")
###########################################################
#pour renommer les tabs du QTabwidget partie cev (ILS 35L):
###########################################################
self.tabWidget_tabs_cev_ils35L.setTabText(0, "loc 35L")
self.tabWidget_tabs_cev_ils35L.setTabText(1, "gp 35L")
############################################################
# appel de la fonction d'animation de la page d'aceuil :
############################################################
self.animationImage()
###############################################################################################################################################
##################################################################################
# Fonction conceernant les commandes effectuees par les boutons et sous menus #
# ################################################################################
#Fonction pour les commandes effectuees par les boutons et sous menus :
def actions_sur_les_boutons(self):
#actions sur les boutons du menu :
########################################################
#pour ouvrir l'image d'acceuil :
#########################################################
self.actionhome.triggered.connect(self.Click_Acceuil_On_menu_Acceuil)
###########################################################
#pour ouvrir la page du container ILS 35R :
###########################################################
self.actionILS_35R.triggered.connect(self.Click_On_menu_Fichier_ILS35R)
###########################################################
#pour ouvrir la page du container ILS 35R :
###########################################################
self.actionILS_35L.triggered.connect(self.Click_On_menu_Fichier_ILS35L)
###########################################################
#pour ouvrir la fenetre Toplevel Information :
###########################################################
self.actionA_propos_de_l_application.triggered.connect(self.window_a_propos_de_l_application)
###########################################################
# pur ouvrir la fenetre Toplevel Raccourcis clavier :
###########################################################
self.actionRaccourcis_clavier.triggered.connect(self.window_raccourcis_clavier)
###########################################################
#pour effectuer la commande de fermeture de l'application :
###########################################################
self.actionQuitter_2.triggered.connect(self.fermer_application)
###########################################################
##p pour rendre les Tab associees au meu invisible
###########################################################
self.tabWidget_Acceuil.tabBar().setVisible(False)
#######################################################################
#actions effectuees par les boutons du bloc lateral gauche (ILS 35R) :
#######################################################################
self.pushButton_ils35R.clicked.connect(self.Click_On_Button_home_ils35R)
self.pushButton_loc35R.clicked.connect(self.Click_On_Button_loc35R)
self.pushButton_gp35R.clicked.connect(self.Click_On_Button_gp35R)
self.pushButton_ils35R_archives_cev.clicked.connect(self.click_On_Button_archives_cev_ils35R)
self.tabWidget_bloc_ILS35R.tabBar().setVisible(False)
########################################################################
#actions effectuees par les boutons du bloc lateral gauche (ILS 35L)
########################################################################
self.pushButton_ils35L.clicked.connect(self.Click_On_Button_home_ils35L)
self.pushButton_loc35L.clicked.connect(self.Click_On_Button_loc35L)
self.pushButton_gp35L.clicked.connect(self.Click_On_Button_gp35L)
self.pushButton_ils35L_archives_cev.clicked.connect(self.click_On_Button_archives_cev_ils35L)
self.tabWidget_bloc_ILS35L.tabBar().setVisible(False)
########################################################################
#afficher unite de mesure selon la valeur choisie (ILS 35R) :
########################################################################
#signal fin edition pour linedit entraine event (afficher_unite_de_mesure_loc35R)
self.lineEdit_ddm_voulue_au_sol_cev_loc35R.editingFinished.connect(self.afficher_unite_de_mesure_loc35R)
self.lineEdit_ddm_voulue_au_sol_cev_gp35R.editingFinished.connect(self.afficher_unite_de_mesure_gp35R)
########################################################################
#afficher unite de mesure selon la valeur choisie e (ILS 35L) :
########################################################################
self.lineEdit_ddm_voulue_au_sol_cev_loc35L.editingFinished.connect(self.afficher_unite_de_mesure_loc35L)
self.lineEdit_ddm_voulue_au_sol_cev_gp35L.editingFinished.connect(self.afficher_unite_de_mesure_gp35L)
########################################################################
#pour valider la correction et l'afficher (ILS 35R) :
########################################################################
#loc 35R:
self.pushButton_valider_cev_loc35R.clicked.connect(self.calcul_de_la_correction_ddm_faisceau_loc35R)
#gp 35R:
self.pushButton_valider_cev_gp35R.clicked.connect(self.calcul_de_la_correction_ddm_faisceau_gp35R)
#########################################################################
#pour valider la correction et l'afficher (ILS 35L) :
##########################################################################
#loc 35L:
self.pushButton_valider_cev_loc35L.clicked.connect(self.calcul_de_la_correction_ddm_faisceau_loc35L)
#gp 35L:
self.pushButton_valider_cev_gp35L.clicked.connect(self.calcul_de_la_correction_ddm_faisceau_gp35L)
############################################################################
#pour initialiser le contenu des champs (ILS 35R) :
#############################################################################
#loc35R
self.pushButton_initialiser_cev_loc35R.clicked.connect(self.initialiser_inputs_loc35R)
#gp35R
self.pushButton_initialiser_cev_gp35R.clicked.connect(self.initialiser_inputs_gp35R)
################################################################################
#pour initialiser le contenu des champs (ILS 35L) :
################################################################################
#loc35L
self.pushButton_initialiser_cev_loc35L.clicked.connect(self.initialiser_inputs_loc35L)
#gp35L
self.pushButton_initialiser_cev_gp35L.clicked.connect(self.initialiser_inputs_gp35L)
################################################################################
# pour controler l'etat du checkbutton loc 35R :
################################################################################
self.checkBox_cev_loc35R.stateChanged.connect(self.etat_checkbutton_valeur_de_correction_loc35R)
################################################################################
# pour controler l'etat du checkbutton loc 35L :
################################################################################
self.checkBox_cev_loc35L.clicked.connect(self.etat_checkbutton_valeur_de_correction_loc35L)
################################################################################
# pour controler l'etat du checkbutton gp 35R :
################################################################################
self.checkBox_cev_gp35R.clicked.connect(self.etat_checkbutton_valeur_de_correction_gp35R)
################################################################################
# pour controler l'etat du checkbutton gp 35L :
################################################################################
self.checkBox_cev_gp35L.clicked.connect(self.etat_checkbutton_valeur_de_correction_gp35L)
################################################################################
#Pour archiver dans la bdd loc35R :
################################################################################
self.pushButton_archiver_cev_loc35R.clicked.connect(self.create_database_ils35R_and_table_loc35R)
###############################################################################
#Pour afficher contenu de la bdd loc 35R :
###############################################################################
self.pushButton_rafraichir_data_table_cev_loc35R.clicked.connect(self.afficher_contenu_table_loc35R)
################################################################################
# pour afficher les corrections confirmees loc 35R :
################################################################################
self.pushButton_correction_confirmee_loc35R.clicked.connect(self.selectionner_correction_confirmee_loc35R)
##############################################################################
#pour sauvegarder contenu de la table loc 35R dans un fichier texte :
##############################################################################
self.pushButton_enregistrer_data_dans_fichier_cev_loc35R.clicked.connect(self.create_file_from_loc35R)
################################################################################
#Pour archiver dans la bdd gp 35R :
################################################################################
self.pushButton_archiver_cev_gp35R.clicked.connect(self.create_database_ils35R_and_table_gp35R)
###############################################################################
#Pour afficher contenu de la bdd gp 35R :
###############################################################################
self.pushButton_rafraichir_data_table_cev_gp35R.clicked.connect(self.afficher_contenu_table_gp35R)
################################################################################
#apres click sur bouton "correction confirmee" gp 35R :
################################################################################
self.pushButton_correction_confirmee_gp35R.clicked.connect(self.selectionner_correction_confirmee_gp35R)
################################################################################
#pour sauvegarder contenu de la table gp 35R dans un fichier texte :
################################################################################
self.pushButton_enregistrer_data_dans_fichier_cev_gp35R.clicked.connect(self.create_file_from_gp35R)
################################################################################
#Pour archiver dans la bdd loc35L :
################################################################################
self.pushButton_archiver_cev_loc35L.clicked.connect(self.create_database_ils35L_and_table_loc35L)
###############################################################################
#Pour afficher contenu de la bdd loc 35L :
###############################################################################
self.pushButton_rafraichir_data_table_cev_loc35L.clicked.connect(self.afficher_contenu_table_loc35L)
################################################################################
# pour afficher les corrections confirmees loc 35L :
################################################################################
self.pushButton_correction_confirmee_loc35L.clicked.connect(self.selectionner_correction_confirmee_loc35L)
##############################################################################
#pour sauvegarder contenu de la table loc 35L dans un fichier texte :
##############################################################################
self.pushButton_enregistrer_data_dans_fichier_cev_loc35L.clicked.connect(self.create_file_from_loc35L)
################################################################################
#Pour archiver dans la bdd gp 35L :
################################################################################
self.pushButton_archiver_cev_gp35L.clicked.connect(self.create_database_ils35L_and_table_gp35L)
###############################################################################
#Pour afficher contenu de la bdd gp 35L :
###############################################################################
self.pushButton_rafraichir_data_table_cev_gp35L.clicked.connect(self.afficher_contenu_table_gp35L)
################################################################################
#apres click sur bouton "correction confirmee" gp 35L :
################################################################################
self.pushButton_correction_confirmee_gp35L.clicked.connect(self.selectionner_correction_confirmee_gp35L)
################################################################################
#pour sauvegarder contenu de la table gp 35L dans un fichier texte :
################################################################################
self.pushButton_enregistrer_data_dans_fichier_cev_gp35L.clicked.connect(self.create_file_from_gp35L)
#######################################################################################################################################
###########################################################################
# fonction pour afficher l'animation durant l'execution de l'application :
###########################################################################
def animationImage(self):
box_animation=QPropertyAnimation(self.label_Acceuil,b"geometry")
box_animation.setDuration(2500)
box_animation.setStartValue(QRect(0,0,0,0))
box_animation.setEndValue(QRect(0,-20 ,845 ,550 ))
box_animation.start()
self.box_animation=box_animation
####################################################
#Fonctions d'affichage de la date et de l'heure :
####################################################
##############################
#### pour le bloc ILS 35R :
##############################
# fonction date :
def afficher_date_ils35R(self):
our_date_ils35R=time.strftime(" %d / %m / %Y")
self.label_date_ils35R.setText('%s ' % our_date_ils35R)
# fonction heure :
def afficher_time_ils35R(self):
our_time_ils35R=time.strftime(" %H : %M : %S")
self.label_time_ils35R.setText(' %s' % our_time_ils35R)
##############################
#### pour le bloc ILS 35L :
##############################
# fonction date :
def afficher_date_ils35L(self):
our_date_ils35L=time.strftime(" %d / %m / %Y")
self.label_date_ils35L.setText('%s ' % our_date_ils35L)
# fonction heure :
def afficher_time_ils35L(self):
our_time_ils35L=time.strftime(" %H : %M : %S")
self.label_time_ils35L.setText(' %s' % our_time_ils35L)
#################################################
#Fonction pour fermer l'application :
#################################################
def fermer_application(self) :
sys.exit()
############################################################################################################
################################################################
# Fonctions d'affichage unite de mesure #
################################################################
#################################################
# affichage unite de mesure pour loc 35R :
#################################################
def afficher_unite_de_mesure_loc35R(self):
#fonction pour convertir les points en virgules :
def convertire_loc35R(nombre) :
caractere_loc35R=[',',';',':','.','-','_']
for loop in caractere_loc35R :
nombre= str(nombre).replace(loop,'.')
return nombre
ddm_voulue_au_sol_loc35R=self.lineEdit_ddm_voulue_au_sol_cev_loc35R.text()
ddm_voulue_au_sol_loc35R=convertire_loc35R(ddm_voulue_au_sol_loc35R)
#print(ddm_voulue_au_sol_loc35R)
if ddm_voulue_au_sol_loc35R =='' :
ddm_voulue_au_sol_loc35R='0'
self.lineEdit_ddm_voulue_au_sol_cev_loc35R.setText('')
self.label_lineEdit_ddm_avion_labo_loc35R.setText('')
self.label_unite_mesure_ddm_voulue_cev_loc35R.setText('')
self.label_mon1_avant_cev_loc35R.setText('')
self.label_mon2_avant_cev_loc35R.setText('')
self.label_mon1_apres_cev_loc35R.setText('')
self.label_mon2_apres_cev_loc35R.setText('')
self.label_dB_cev_loc35R.setText('')
else :
if (0<float(ddm_voulue_au_sol_loc35R) <1) :
self.label_unite_mesure_ddm_voulue_cev_loc35R.setText('ddm')
self.label_lineEdit_ddm_avion_labo_loc35R.setText('ddm')
self.label_mon1_avant_cev_loc35R.setText('ddm')
self.label_mon2_avant_cev_loc35R.setText('ddm')
self.label_mon1_apres_cev_loc35R.setText('ddm')
self.label_mon2_apres_cev_loc35R.setText('ddm')
self.label_dB_cev_loc35R.setText('dB')
elif(float(ddm_voulue_au_sol_loc35R) >100 ) :
self.label_unite_mesure_ddm_voulue_cev_loc35R.setText('μA')
self.label_lineEdit_ddm_avion_labo_loc35R.setText('μA')
self.label_mon1_avant_cev_loc35R.setText('μA')
self.label_mon2_avant_cev_loc35R.setText('μA')
self.label_mon1_apres_cev_loc35R.setText('μA')
self.label_mon2_apres_cev_loc35R.setText('μA')
self.label_dB_cev_loc35R.setText('dB')
else :
self.lineEdit_ddm_voulue_au_sol_cev_loc35R.setText('')
self.label_lineEdit_ddm_avion_labo_loc35R.setText('')
self.label_unite_mesure_ddm_voulue_cev_loc35R.setText('')
self.label_mon1_avant_cev_loc35R.setText('')
self.label_mon2_avant_cev_loc35R.setText('')
self.label_mon1_apres_cev_loc35R.setText('')
self.label_mon2_apres_cev_loc35R.setText('')
self.label_dB_cev_loc35R.setText('')
##################################################
# affichage unite de mesure pour loc 35L :
##################################################
def afficher_unite_de_mesure_loc35L(self):
#fonction pour convertir les points en virgules :
def convertire_loc35L(nombre) :
caractere_loc35L=[',',';',':','.','-','_']
for loop in caractere_loc35L :
nombre= str(nombre).replace(loop,'.')
return nombre
ddm_voulue_au_sol_loc35L=self.lineEdit_ddm_voulue_au_sol_cev_loc35L.text()
ddm_voulue_au_sol_loc35L=convertire_loc35L(ddm_voulue_au_sol_loc35L)
if ddm_voulue_au_sol_loc35L =='' :
ddm_voulue_au_sol_loc35L='0'
self.lineEdit_ddm_voulue_au_sol_cev_loc35L.setText('')
self.label_lineEdit_ddm_avion_labo_loc35L.setText('')
self.label_unite_mesure_ddm_voulue_cev_loc35L.setText('')
self.label_mon1_avant_cev_loc35L.setText('')
self.label_mon2_avant_cev_loc35L.setText('')
self.label_mon1_apres_cev_loc35L.setText('')
self.label_mon2_apres_cev_loc35L.setText('')
self.label_dB_cev_loc35L.setText('')
else :
if (0<float(ddm_voulue_au_sol_loc35L) <1) :
self.label_unite_mesure_ddm_voulue_cev_loc35L.setText('ddm')
self.label_lineEdit_ddm_avion_labo_loc35L.setText('ddm')
self.label_mon1_avant_cev_loc35L.setText('ddm')
self.label_mon2_avant_cev_loc35L.setText('ddm')
self.label_mon1_apres_cev_loc35L.setText('ddm')
self.label_mon2_apres_cev_loc35L.setText('ddm')
self.label_dB_cev_loc35L.setText('dB')
elif(float(ddm_voulue_au_sol_loc35L) >100 ) :
self.label_unite_mesure_ddm_voulue_cev_loc35L.setText('μA')
self.label_lineEdit_ddm_avion_labo_loc35L.setText('μA')
self.label_mon1_avant_cev_loc35L.setText('μA')
self.label_mon2_avant_cev_loc35L.setText('μA')
self.label_mon1_apres_cev_loc35L.setText('μA')
self.label_mon2_apres_cev_loc35L.setText('μA')
self.label_dB_cev_loc35L.setText('dB')
else :
self.lineEdit_ddm_voulue_au_sol_cev_loc35L.setText('')
self.label_lineEdit_ddm_avion_labo_loc35L.setText('')
self.label_unite_mesure_ddm_voulue_cev_loc35L.setText('')
self.label_mon1_avant_cev_loc35L.setText('')
self.label_mon2_avant_cev_loc35L.setText('')
self.label_mon1_apres_cev_loc35L.setText('')
self.label_mon2_apres_cev_loc35L.setText('')
self.label_dB_cev_loc35L.setText('')
####################################################
# affichage de l'unite de mesure pour gp 35R :
####################################################
def afficher_unite_de_mesure_gp35R(self):
#fonction pour convertir les points en virgules :
def convertire_gp35R(nombre) :
caractere_gp35R=[',',';',':','.','-','_']
for loop in caractere_gp35R :
nombre= str(nombre).replace(loop,'.')
return nombre
ddm_voulue_au_sol_gp35R=self.lineEdit_ddm_voulue_au_sol_cev_gp35R.text()
ddm_voulue_au_sol_gp35R=convertire_gp35R(ddm_voulue_au_sol_gp35R)
if ddm_voulue_au_sol_gp35R =='' :
ddm_voulue_au_sol_gp35R='0'
self.lineEdit_ddm_voulue_au_sol_cev_gp35R.setText('')
self.label_lineEdit_ddm_avion_labo_gp35R.setText('')
self.label_unite_mesure_ddm_voulue_cev_gp35R.setText('')
self.label_mon1_avant_cev_gp35R.setText('')
self.label_mon2_avant_cev_gp35R.setText('')
self.label_mon1_apres_cev_gp35R.setText('')
self.label_mon2_apres_cev_gp35R.setText('')
self.label_dB_cev_gp35R.setText('')
else :
if (0<float(ddm_voulue_au_sol_gp35R) <1) :
self.label_unite_mesure_ddm_voulue_cev_gp35R.setText('ddm')
self.label_lineEdit_ddm_avion_labo_gp35R.setText('ddm')
self.label_mon1_avant_cev_gp35R.setText('ddm')
self.label_mon2_avant_cev_gp35R.setText('ddm')
self.label_mon1_apres_cev_gp35R.setText('ddm')
self.label_mon2_apres_cev_gp35R.setText('ddm')
self.label_dB_cev_gp35R.setText('dB')
elif(float(ddm_voulue_au_sol_gp35R) >=75) :
self.label_unite_mesure_ddm_voulue_cev_gp35R.setText('μA')
self.label_lineEdit_ddm_avion_labo_gp35R.setText('μA')
self.label_mon1_avant_cev_gp35R.setText('μA')
self.label_mon2_avant_cev_gp35R.setText('μA')
self.label_mon1_apres_cev_gp35R.setText('μA')
self.label_mon2_apres_cev_gp35R.setText('μA')
self.label_dB_cev_gp35R.setText('dB')
else :
self.lineEdit_ddm_voulue_au_sol_cev_gp35R.setText('')
self.label_lineEdit_ddm_avion_labo_gp35R.setText('')
self.label_unite_mesure_ddm_voulue_cev_gp35R.setText('')
self.label_mon1_avant_cev_gp35R.setText('')
self.label_mon2_avant_cev_gp35R.setText('')
self.label_mon1_apres_cev_gp35R.setText('')
self.label_mon2_apres_cev_gp35R.setText('')
self.label_dB_cev_gp35R.setText('')
################################################
# affichage unite de mesure pour gp 35L :
###############################################
def afficher_unite_de_mesure_gp35L(self):
#fonction pour convertir les points en virgules :
def convertire_gp35L(nombre) :
caractere_gp35L=[',',';',':','.','-','_']
for loop in caractere_gp35L :
nombre= str(nombre).replace(loop,'.')
return nombre
ddm_voulue_au_sol_gp35L=self.lineEdit_ddm_voulue_au_sol_cev_gp35L.text()
ddm_voulue_au_sol_gp35L=convertire_gp35L(ddm_voulue_au_sol_gp35L)
#print(ddm_voulue_au_sol_gp35L)
if ddm_voulue_au_sol_gp35L =='' :
ddm_voulue_au_sol_gp35L='0'
self.lineEdit_ddm_voulue_au_sol_cev_gp35L.setText('')
self.label_lineEdit_ddm_avion_labo_gp35L.setText('')
self.label_unite_mesure_ddm_voulue_cev_gp35L.setText('')
self.label_mon1_avant_cev_gp35L.setText('')
self.label_mon2_avant_cev_gp35L.setText('')
self.label_mon1_apres_cev_gp35L.setText('')
self.label_mon2_apres_cev_gp35L.setText('')
self.label_dB_cev_gp35L.setText('')
else :
if (0<float(ddm_voulue_au_sol_gp35L) <1) :
self.label_unite_mesure_ddm_voulue_cev_gp35L.setText('ddm')
self.label_lineEdit_ddm_avion_labo_gp35L.setText('ddm')
self.label_mon1_avant_cev_gp35L.setText('ddm')
self.label_mon2_avant_cev_gp35L.setText('ddm')
self.label_mon1_apres_cev_gp35L.setText('ddm')
self.label_mon2_apres_cev_gp35L.setText('ddm')
self.label_dB_cev_gp35L.setText('dB')
elif(float(ddm_voulue_au_sol_gp35L) >=75) :
self.label_unite_mesure_ddm_voulue_cev_gp35L.setText('μA')
self.label_lineEdit_ddm_avion_labo_gp35L.setText('μA')
self.label_mon1_avant_cev_gp35L.setText('μA')
self.label_mon2_avant_cev_gp35L.setText('μA')
self.label_mon1_apres_cev_gp35L.setText('μA')
self.label_mon2_apres_cev_gp35L.setText('μA')
self.label_dB_cev_gp35L.setText('dB')
else :
self.lineEdit_ddm_voulue_au_sol_cev_gp35L.setText('')
self.label_lineEdit_ddm_avion_labo_gp35L.setText('')
self.label_unite_mesure_ddm_voulue_cev_gp35L.setText('')
self.label_mon1_avant_cev_gp35L.setText('')
self.label_mon2_avant_cev_gp35L.setText('')
self.label_mon1_apres_cev_gp35L.setText('')
self.label_mon2_apres_cev_gp35L.setText('')
self.label_dB_cev_gp35L.setText('')
############################################################################################################
######################################################
# Fonctions d'affichage de l'etat du checkbutton #
# ####################################################
################################################################################
# etat checkbutton de confirmation de la bonne valeur de correction loc35R :
################################################################################
def etat_checkbutton_valeur_de_correction_loc35R(self):
if self.checkBox_cev_loc35R.isChecked()==True :
self.textEdit_affichage_erreurs_cev_loc35R.setText('<center><h2 style=" color:#00aa00;">Confirmation</h2></center><span style=" color:#00aa00;font-weight:bold;">La dernière valeur introduite pour la correction de la ddm faisceau a été confirmée par les operateurs en vol.</span>')
self.lineEdit_declaration_OK_or_NO_cev_loc35R.setText("OK")
else:
self.textEdit_affichage_erreurs_cev_loc35R.setText("")
self.lineEdit_declaration_OK_or_NO_cev_loc35R.setText("NO")
#self.lineEdit_declaration_OK_or_NO_cev_loc35R.setStyleSheet(
#"""QLineEdit {color: red }""")
############################################################################
#etat checkbutton de confirmation de la bonne valeur de correction gp 35R :
############################################################################
def etat_checkbutton_valeur_de_correction_gp35R(self):
if self.checkBox_cev_gp35R.isChecked()==True :
self.textEdit_affichage_erreurs_cev_gp35R.setText('<center><h2 style=" color:#00aa00;">Confirmation</h2></center><span style=" color:#00aa00;font-weight:bold;">La dernière valeur introduite pour la correction de la ddm faisceau a été confirmée par les operateurs en vol.</span>')
self.lineEdit_declaration_OK_or_NO_cev_gp35R.setText("OK")
else:
self.textEdit_affichage_erreurs_cev_gp35R.setText(" ")
self.lineEdit_declaration_OK_or_NO_cev_gp35R.setText("NO")
###########################################################################
#etat checkbutton de confirmation de la bonne valeur de correction loc35L :
###########################################################################
def etat_checkbutton_valeur_de_correction_loc35L(self):
if self.checkBox_cev_loc35L.isChecked()==True :
self.textEdit_affichage_erreurs_cev_loc35L.setText('<center><h2 style=" color:#00aa00;">Confirmation</h2></center><span style=" color:#00aa00;font-weight:bold;">La dernière valeur introduite pour la correction de la ddm faisceau a été confirmée par les operateurs en vol.</span>')
self.lineEdit_declaration_OK_or_NO_cev_loc35L.setText("OK")
else:
self.textEdit_affichage_erreurs_cev_loc35L.setText(" ")
self.lineEdit_declaration_OK_or_NO_cev_loc35L.setText("NO")
###########################################################################
#etat checkbutton de confirmation de la bonne valeur de correction gp 35L:
###########################################################################
def etat_checkbutton_valeur_de_correction_gp35L(self):
if self.checkBox_cev_gp35L.isChecked()==True :
self.textEdit_affichage_erreurs_cev_gp35L.setText('<center><h2 style=" color:#00aa00;">Confirmation</h2></center><span style=" color:#00aa00;font-weight:bold;">La dernière valeur introduite pour la correction de la ddm faisceau a été confirmée par les operateurs en vol.</span>')
self.lineEdit_declaration_OK_or_NO_cev_gp35L.setText("OK")
else:
self.textEdit_affichage_erreurs_cev_gp35L.setText(" ")
self.lineEdit_declaration_OK_or_NO_cev_gp35L.setText("NO")
################################################################################################################################################
################################################################
# Fonctions de calcul de la correction de la ddm faisceaaau #
# ##############################################################
#######################################################
# correction de la ddm faisceaaau pour loc 35R :
#######################################################
def calcul_de_la_correction_ddm_faisceau_loc35R (self):
#fonction convertir point virgules :
def convertir_loc35R(nombre) :
caractere_loc35R=[',',';',':','.','-','_']
for loop in caractere_loc35R :
nombre= str(nombre).replace(loop,'.')
return nombre
ddm_voulue_au_sol_loc35R=self.lineEdit_ddm_voulue_au_sol_cev_loc35R.text()
ddm_voulue_au_sol_loc35R=convertir_loc35R(ddm_voulue_au_sol_loc35R)
ddm_voulue_au_sol_loc35R=float(ddm_voulue_au_sol_loc35R)
ddm_lue_avion_labo_loc35R=self.lineEdit_ddm_avion_labo_cev_loc35R.text()
ddm_lue_par_avion_labo_loc35R=convertir_loc35R(ddm_lue_avion_labo_loc35R)
ddm_lue_par_avion_labo_loc35R=float(ddm_lue_par_avion_labo_loc35R)
try:
correction_loc35R= 20*(math.log10(ddm_lue_par_avion_labo_loc35R/ddm_voulue_au_sol_loc35R))
correction_loc35R=round(correction_loc35R,3)
correction_loc35R =str(correction_loc35R)
self.lineEdit_correction_cev_loc35R.setText(correction_loc35R)
self.textEdit_affichage_erreurs_cev_loc35R.setText("")
except:
self.textEdit_affichage_erreurs_cev_loc35R.setText('<center><h2 style="color:#FF0000">Erreur</h2></center><span style="font-weight:bold;font-size:15px;color:#FF0000">Un des champs est nul ou invalide. Remplir tous les champs, puis refaire l\'operation de calcul.</span>')
###########################################################
# correction de la ddm faisceaaau pour gp 35R :
###########################################################
def calcul_de_la_correction_ddm_faisceau_gp35R (self):
#fonction convertir point virgules :
def convertir_gp35R(nombre) :
caractere_gp35R=[',',';',':','.','-','_']
for loop in caractere_gp35R :
nombre= str(nombre).replace(loop,'.')
return nombre
ddm_voulue_au_sol_gp35R=self.lineEdit_ddm_voulue_au_sol_cev_gp35R.text()
ddm_voulue_au_sol_gp35R=convertir_gp35R(ddm_voulue_au_sol_gp35R)
ddm_voulue_au_sol_gp35R=float(ddm_voulue_au_sol_gp35R)
ddm_lue_avion_labo_gp35R=self.lineEdit_ddm_avion_labo_cev_gp35R.text()
ddm_lue_par_avion_labo_gp35R=convertir_gp35R(ddm_lue_avion_labo_gp35R)
ddm_lue_par_avion_labo_gp35R=float(ddm_lue_par_avion_labo_gp35R)
try:
correction_gp35R= 20*(math.log10(ddm_lue_par_avion_labo_gp35R/ddm_voulue_au_sol_gp35R))
correction_gp35R=round(correction_gp35R,3)
correction_gp35R =str(correction_gp35R)
self.lineEdit_correction_cev_gp35R.setText(correction_gp35R)
self.textEdit_affichage_erreurs_cev_gp35R.setText("")
except:
self.textEdit_affichage_erreurs_cev_gp35R.setText('<center><h2 style="color:#FF0000">Erreur</h2></center><span style="font-weight:bold;font-size:15px;color:#FF0000">Un des champs est nul ou invalide. Remplir tous les champs, puis refaire l\'operation de calcul.</span>')
#############################################################
# correction de la ddm faisceaaau pour loc 35L :
#############################################################
def calcul_de_la_correction_ddm_faisceau_loc35L (self):
#fonction convertir point virgules :
def convertir_loc35L(nombre) :
caractere_loc35L=[',',';',':','.','-','_']
for loop in caractere_loc35L :
nombre= str(nombre).replace(loop,'.')
return nombre
ddm_voulue_au_sol_loc35L=self.lineEdit_ddm_voulue_au_sol_cev_loc35L.text()
ddm_voulue_au_sol_loc35L=convertir_loc35L(ddm_voulue_au_sol_loc35L)
ddm_voulue_au_sol_loc35L=float(ddm_voulue_au_sol_loc35L)
ddm_lue_avion_labo_loc35L=self.lineEdit_ddm_avion_labo_cev_loc35L.text()
ddm_lue_par_avion_labo_loc35L=convertir_loc35L(ddm_lue_avion_labo_loc35L)
ddm_lue_par_avion_labo_loc35L=float(ddm_lue_par_avion_labo_loc35L)
try:
correction_loc35L= 20*(math.log10(ddm_lue_par_avion_labo_loc35L/ddm_voulue_au_sol_loc35L))
correction_loc35L=round(correction_loc35L,3)
correction_loc35L=str(correction_loc35L)
self.lineEdit_correction_cev_loc35L.setText(correction_loc35L)
self.textEdit_affichage_erreurs_cev_loc35L.setText("")
except:
self.textEdit_affichage_erreurs_cev_loc35L.setText('<center><h2 style="color:#FF0000">Erreur</h2></center><span style="font-weight:bold;font-size:15px;color:#FF0000">Un des champs est nul ou invalide. Remplir tous les champs, puis refaire l\'operation de calcul.</span>')
#########################################################
# correction de la ddm faisceaaau pour gp 35L
#########################################################
def calcul_de_la_correction_ddm_faisceau_gp35L (self):
#fonction convertir point virgules :
def convertir_gp35L(nombre) :
caractere_gp35L=[',',';',':','.','-','_']
for loop in caractere_gp35L :
nombre= str(nombre).replace(loop,'.')
return nombre
ddm_voulue_au_sol_gp35L=self.lineEdit_ddm_voulue_au_sol_cev_gp35L.text()
ddm_voulue_au_sol_gp35L=convertir_gp35L(ddm_voulue_au_sol_gp35L)
ddm_voulue_au_sol_gp35L=float(ddm_voulue_au_sol_gp35L)
ddm_lue_avion_labo_gp35L=self.lineEdit_ddm_avion_labo_cev_gp35L.text()
ddm_lue_par_avion_labo_gp35L=convertir_gp35L(ddm_lue_avion_labo_gp35L)
ddm_lue_par_avion_labo_gp35L=float(ddm_lue_par_avion_labo_gp35L)
try:
correction_gp35L= 20*(math.log10(ddm_lue_par_avion_labo_gp35L/ddm_voulue_au_sol_gp35L))
correction_gp35L=round(correction_gp35L,3)
correction_gp35L=str(correction_gp35L)
self.lineEdit_correction_cev_gp35L.setText(correction_gp35L)
self.textEdit_affichage_erreurs_cev_gp35L.setText("")
except:
self.textEdit_affichage_erreurs_cev_gp35L.setText('<center><h2 style="color:#FF0000">Erreur</h2></center><span style="font-weight:bold;font-size:15px;color:#FF0000">Un des champs est nul ou invalide. Remplir tous les champs, puis refaire l\'operation de calcul.</span>')
##############################################################
#fonctions d'initialisation pour loc 3R des lineEdit :
##############################################################
def initialiser_inputs_loc35R(self):
self.lineEdit_ddm_avion_labo_cev_loc35R.setText("")
self.lineEdit_correction_cev_loc35R.setText("")
self.lineEdit_ddm_voulue_au_sol_cev_loc35R.setText("")
self.textEdit_affichage_erreurs_cev_loc35R.setText("")
self.lineEdit_mon1_avant_cev_loc35R.setText("")
self.lineEdit_mon2_avant_cev_loc35R.setText("")
self.lineEdit_mon1_apres_cev_loc35R.setText("")
self.lineEdit_mon2_apres_cev_loc35R.setText("")
self.label_mon1_avant_cev_loc35R.setText("")
self.label_mon2_avant_cev_loc35R.setText("")
self.label_mon1_apres_cev_loc35R.setText("")
self.label_mon2_apres_cev_loc35R.setText("")
self.label_unite_mesure_ddm_voulue_cev_loc35R.setText("")
self.label_lineEdit_ddm_avion_labo_loc35R.setText("")
self.lineEdit_declaration_OK_or_NO_cev_loc35R.setText("")
self.label_dB_cev_loc35R.setText("")
self.checkBox_cev_loc35R.setCheckState(Qt.Unchecked)
################################################################
#fonctions d'initialisation pour gp 3R des lineEdit :
################################################################
def initialiser_inputs_gp35R(self):
self.lineEdit_ddm_avion_labo_cev_gp35R.setText("")
self.lineEdit_correction_cev_gp35R.setText("")
self.lineEdit_ddm_voulue_au_sol_cev_gp35R.setText("")
self.textEdit_affichage_erreurs_cev_gp35R.setText("")
self.lineEdit_mon1_avant_cev_gp35R.setText("")
self.lineEdit_mon2_avant_cev_gp35R.setText("")
self.lineEdit_mon1_apres_cev_gp35R.setText("")
self.lineEdit_mon2_apres_cev_gp35R.setText("")
self.label_mon1_avant_cev_gp35R.setText("")
self.label_mon2_avant_cev_gp35R.setText("")
self.label_mon1_apres_cev_gp35R.setText("")
self.label_mon2_apres_cev_gp35R.setText("")
self.label_unite_mesure_ddm_voulue_cev_gp35R.setText("")
self.label_lineEdit_ddm_avion_labo_gp35R.setText("")
self.lineEdit_declaration_OK_or_NO_cev_gp35R.setText("")
self.label_dB_cev_gp35R.setText("")
self.checkBox_cev_gp35R.setCheckState(Qt.Unchecked)
#################################################################
#fonctions d'initialisation pour loc 35L des lineEdit :
#################################################################
def initialiser_inputs_loc35L(self):
self.lineEdit_ddm_avion_labo_cev_loc35L.setText("")
self.lineEdit_correction_cev_loc35L.setText("")
self.lineEdit_ddm_voulue_au_sol_cev_loc35L.setText("")
self.textEdit_affichage_erreurs_cev_loc35L.setText("")
self.lineEdit_mon1_avant_cev_loc35L.setText("")
self.lineEdit_mon2_avant_cev_loc35L.setText("")
self.lineEdit_mon1_apres_cev_loc35L.setText("")
self.lineEdit_mon2_apres_cev_loc35L.setText("")
self.label_mon1_avant_cev_loc35L.setText("")
self.label_mon2_avant_cev_loc35L.setText("")
self.label_mon1_apres_cev_loc35L.setText("")
self.label_mon2_apres_cev_loc35L.setText("")
self.label_unite_mesure_ddm_voulue_cev_loc35L.setText("")
self.label_lineEdit_ddm_avion_labo_loc35L.setText("")
self.lineEdit_declaration_OK_or_NO_cev_loc35L.setText("")
self.label_dB_cev_loc35L.setText("")
self.checkBox_cev_loc35L.setCheckState(Qt.Unchecked)
###############################################################
# fonctions d'initialisation pour gp 35L des lineEdit :
###############################################################
def initialiser_inputs_gp35L(self):
self.lineEdit_ddm_avion_labo_cev_gp35L.setText("")
self.lineEdit_correction_cev_gp35L.setText("")
self.lineEdit_ddm_voulue_au_sol_cev_gp35L.setText("")
self.textEdit_affichage_erreurs_cev_gp35L.setText("")
self.lineEdit_mon1_avant_cev_gp35L.setText("")
self.lineEdit_mon2_avant_cev_gp35L.setText("")
self.lineEdit_mon1_apres_cev_gp35L.setText("")
self.lineEdit_mon2_apres_cev_gp35L.setText("")
self.label_mon1_avant_cev_gp35L.setText("")
self.label_mon2_avant_cev_gp35L.setText("")
self.label_mon1_apres_cev_gp35L.setText("")
self.label_mon2_apres_cev_gp35L.setText("")
self.label_unite_mesure_ddm_voulue_cev_gp35L.setText("")
self.label_lineEdit_ddm_avion_labo_gp35L.setText("")
self.lineEdit_declaration_OK_or_NO_cev_gp35L.setText("")
self.label_dB_cev_gp35L.setText("")
self.checkBox_cev_gp35L.setCheckState(Qt.Unchecked)
######################################################################################################################################
################################################
# database LOC 35R #
################################################
########################################################
#Fonctions archivage pour loc 35R :
########################################################
def create_database_ils35R_and_table_loc35R(self):
#fonction convertir point virgules :
def convertir_database_ils35R(nombre) :
caractere_loc35R=[',',';',':','.','-','_']
for loop in caractere_loc35R :
nombre= str(nombre).replace(loop,'.')
return nombre
#scriptDirectory=os.path.dirname(os.path.realpath(__file__)) #chemin vers le dossier contenant le script index.py
#path_directory=scriptDirectory + '\\data_base' #creation du chemin vers le dossier data_base
#os.makedirs(path_directory, exist_ok=True) # creation du dossier data_base
bundle_dir_data_base = getattr(sys, '_MEIPASS', path.abspath(path.dirname(__file__)))
path_to_data_base = path.join(bundle_dir_data_base, 'data_base')
os.makedirs(path_to_data_base, exist_ok=True)
#les valeurs qui vont etre introduites dans les champs de la table
# apres chaque operation de stockage " click sur le bouton archiver de l'application"
mon1_avant_cev_loc35R=self.lineEdit_mon1_avant_cev_loc35R.text()
ddm_mon1_avant_cev_loc35R=convertir_database_ils35R(mon1_avant_cev_loc35R)+' '+self.label_mon1_avant_cev_loc35R.text()
mon2_avant_cev_loc35R=self.lineEdit_mon2_avant_cev_loc35R.text()
ddm_mon2_avant_cev_loc35R=convertir_database_ils35R(mon2_avant_cev_loc35R)+' '+self.label_mon2_avant_cev_loc35R.text()
mon1_apres_cev_loc35R=self.lineEdit_mon1_apres_cev_loc35R.text()
ddm_mon1_apres_cev_loc35R=convertir_database_ils35R(mon1_apres_cev_loc35R)+' '+self.label_mon2_apres_cev_loc35R.text()
mon2_apres_cev_loc35R=self.lineEdit_mon2_apres_cev_loc35R.text()
ddm_mon2_apres_cev_loc35R=convertir_database_ils35R(mon2_apres_cev_loc35R)+' ' +self.label_mon2_apres_cev_loc35R.text()
ddm_avion_labo_cev_loc35R=self.lineEdit_ddm_avion_labo_cev_loc35R.text()
ddm_lue_avion_labo_cev_loc35R=convertir_database_ils35R(ddm_avion_labo_cev_loc35R)+' '+self.label_lineEdit_ddm_avion_labo_loc35R.text()
date_lecture_cev_loc35R =str(time.strftime("%d-%m-%Y"))
time_lecture_cev_loc35R = str(time.strftime('%H:%M:%S'))
ddm_correction_cev_loc35R = self.lineEdit_correction_cev_loc35R.text() +' ' + 'dB'
ddm_voulue_au_sol_cev_loc35R = self.lineEdit_ddm_voulue_au_sol_cev_loc35R.text()
ddm_voulue_au_sol_cev_loc35R=convertir_database_ils35R(ddm_voulue_au_sol_cev_loc35R)+' ' +self.label_unite_mesure_ddm_voulue_cev_loc35R.text()
ddm_confirmation_avion_labo_cev_loc35R=self.lineEdit_declaration_OK_or_NO_cev_loc35R.text()
connexion = sqlite3.connect(path_to_data_base + '\\ils35R.db')
# Get a cursor object
curseur = connexion.cursor()
# Check if table loc35R does not exist and create it
curseur.execute('''CREATE TABLE IF NOT EXISTS loc35R
(date_cev_loc35R text, time_cev_loc35R text,lecture_ddm_mon1_avant_cev_loc35R text, lecture_ddm_mon2_avant_cev_loc35R text,
lecture_ddm_mon1_apres_cev_loc35R text , lecture_ddm_mon2_apres_cev_loc35R text, lecture_ddm_voulue_au_sol_cev_loc35R text,
lecture_ddm_avion_labo_cev_loc35R text, correction_cev_loc35R text, declaration_avion_labo_cev_loc35R text ) ''')
#affichage Rappel pas d'enregistrement actuellement avec l'etat des champs vides :
if (self.lineEdit_mon1_avant_cev_loc35R.text()=="") or (self.lineEdit_mon2_avant_cev_loc35R.text()=="") or (self.lineEdit_mon1_apres_cev_loc35R.text()=="") or (self.lineEdit_mon2_apres_cev_loc35R.text()=="") or (self.lineEdit_correction_cev_loc35R.text()=="") or (self.lineEdit_ddm_avion_labo_cev_loc35R.text()=="") :
self.textEdit_affichage_erreurs_cev_loc35R.setText('<center><h2 style=" color:#FF0000;">Rappel</h2></center><span style="color:#FF0000; font-weight: bold;font-size:15px;">Il n\'ya pas eu d\'enregistrement dans la base de données puisqu\'un des champs est invalide.</span>')
else:
#insertion des donnees de la bdd à partir de la table cree "loc35R" :
curseur.execute('''INSERT INTO loc35R VALUES (?,?,?,?,?,?,?,?,?,?) ''',
(date_lecture_cev_loc35R,time_lecture_cev_loc35R, ddm_mon1_avant_cev_loc35R, ddm_mon2_avant_cev_loc35R, ddm_mon1_apres_cev_loc35R, ddm_mon2_apres_cev_loc35R, ddm_voulue_au_sol_cev_loc35R, ddm_lue_avion_labo_cev_loc35R, ddm_correction_cev_loc35R, ddm_confirmation_avion_labo_cev_loc35R))
# Commit the change
connexion.commit()
#affichage Felecitation:succes d'enregistrement dans la bdd :
self.textEdit_affichage_erreurs_cev_loc35R.setText('<center><h2 style=" color:#00aa00;">Félicitation</h2></center>''<span style=" color:#00aa00;font-size:15px;font-weight: bold;">L\'enregistrement dans la base de données a été effectué avec succès.</span>')
#fermeture du cursor
curseur.close()
#fermeture de la connexion à la bdd
connexion.close()
###################################################################
#affichage du contenu de la table "loc35R" :
###################################################################
def messageInfo(self):
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setText("<center><h1 style='color:#AD4F09;'>Information</h1></center>")
msg.setInformativeText("<span style='color:#FF0000; font-weight: bold;font-size:15px;'>pas d’informations enregistrées dans la base de données à afficher</span>")
msg.setWindowTitle("Sauvegarde dans la base de données")
msg.exec_()
def afficher_contenu_table_loc35R(self):
#script_path_ils35R = os.path.dirname(os.path.realpath(__file__))#récupérer le répertoire courant
#new_path_ils35R=script_path_ils35R + '\\data_base' #concaténer au path ci-dessus le path du dossier data_base
#os.makedirs(new_path_ils35R, exist_ok=True) #creer le dossier data_base au nouveau path
bundle_dir_data_base_loc35R = getattr(sys, '_MEIPASS', path.abspath(path.dirname(__file__)))
path_to_data_base_loc35R = path.join(bundle_dir_data_base_loc35R, 'data_base')
os.makedirs(path_to_data_base, exist_ok=True)
conn = sqlite3.connect(path_to_data_base_loc35R + '\\ils35R.db')
curseur=conn.cursor()
try:
c=curseur.execute("SELECT * FROM loc35R")
liste_for_table_cev_loc35R=c.fetchall()
# set row count
self.tableWidget_cev_loc35R.setRowCount(len(liste_for_table_cev_loc35R))
#insertion des donnees de la bdd dans la Qtablewidget:
for nb_lignes in range(len(liste_for_table_cev_loc35R)):
for nombre_colonnes in range(10):
self.tableWidget_cev_loc35R.setItem(nb_lignes,nombre_colonnes, QTableWidgetItem(liste_for_table_cev_loc35R[nb_lignes][nombre_colonnes]))
#mettre la couleur verte pour la ligne contenant la confirmation 'OK'
if (self.tableWidget_cev_loc35R.item(nb_lignes,nombre_colonnes).text())=='OK' :
for j in range(nombre_colonnes+1):
self.tableWidget_cev_loc35R.item(nb_lignes,j).setBackground(QtGui.QColor(0, 204, 0))
self.tableWidget_cev_loc35R.resizeRowsToContents()
self.tableWidget_cev_loc35R.resizeColumnsToContents()
#fermeture du cursor
curseur.close()
#fermeture de la connexion à la bdd
conn.close()
except :
self.messageInfo()
###################################################################
# fonction afficher la selection des corrections confirmer :
###################################################################
def selectionner_correction_confirmee_loc35R (self):
#script_path_ils35R = os.path.dirname(os.path.realpath(__file__))#récupérer le répertoire courant
#new_path_ils35R=script_path_ils35R + '\\data_base' #concaténer au path ci-dessus le path du dossier data_base
#os.makedirs(new_path_ils35R, exist_ok=True) #creer le dossier data_base au nouveau path
bundle_dir_data_base = getattr(sys, '_MEIPASS', path.abspath(path.dirname(__file__)))
path_to_data_base = path.join(bundle_dir_data_base, 'data_base')
os.makedirs(path_to_data_base, exist_ok=True)
conn = sqlite3.connect(path_to_data_base + '\\ils35R.db')
curseur=conn.cursor()
try :
c=curseur.execute("SELECT * FROM loc35R WHERE declaration_avion_labo_cev_loc35R='OK' ")
#nbre de ligne de la table dont la colonne confirmation='OK'
liste_selectionner_correction_confirmee=c.fetchall()
nbr_rows=len(liste_selectionner_correction_confirmee)
# set row count
self.tableWidget_cev_loc35R.setRowCount(nbr_rows)
for nb in range(nbr_rows):
for nombre in range(10):
self.tableWidget_cev_loc35R.setItem(nb,nombre, QTableWidgetItem(liste_selectionner_correction_confirmee[nb][nombre]))
#Adjust size of rows and columns of the Table
self.tableWidget_cev_loc35R.resizeRowsToContents()
self.tableWidget_cev_loc35R.resizeColumnsToContents()
# Commit the change
conn.commit()
#fermeture du cursor
curseur.close()
#fermeture de la connexion à la bdd
conn.close()
except :
self.messageInfo()
###############################################################################################
#Fonction d'alerte quand on veut enregistrer des donnees qui n0exite encore dans la bdd :
###############################################################################################
def messageInfo_filesave(self):
msg_filesave_loc35R = QMessageBox()
msg_filesave_loc35R.setIcon(QMessageBox.Information)
msg_filesave_loc35R.setText("<center><h1 style='color:#AD4F09;'>Rappel</h1></center>")
msg_filesave_loc35R.setInformativeText("<span style='color:#FF0000; font-weight: bold;font-size:15px;'>Il n'ya pas actuellement d’informations enregistrées dans la base de données, afin de pouvoir les sauvegarder dans un fichier texte.</span>")
msg_filesave_loc35R.setWindowTitle("Sauvegarde dans un fichier texte")
msg_filesave_loc35R.exec_()
############################################################################################
#Fonction pour creer un fichier texte et sauvegarder dedans le contenu de la bdd :
############################################################################################
def create_file_from_loc35R(self):
#script_path_ils35R = os.path.dirname(os.path.realpath(__file__))#récupérer le répertoire courant
#new_path_ils35R=script_path_ils35R + '\\data_base' #concaténer au path ci-dessus le path du dossier data_base
#os.makedirs(new_path_ils35R, exist_ok=True) #creer le dossier data_base au nouveau path
#script_path_filesave_loc35R = os.path.dirname(os.path.realpath(__file__))#récupérer le répertoire courant
#new_path_filesave_loc35R=script_path_filesave_loc35R + '\\filesave' #concaténer au path ci-dessus le path du dossier data_base
#os.makedirs(new_path_filesave_loc35R, exist_ok=True) #creer le dossier data_base au nouveau path
bundle_dir_data_base_loc35R = getattr(sys, '_MEIPASS', path.abspath(path.dirname(__file__)))
path_to_data_base_loc35R = path.join(bundle_dir_data_base, 'data_base')
os.makedirs(path_to_data_base_loc35R, exist_ok=True)
bundle_dir_text_file_loc35R = getattr(sys, '_MEIPASS', path.abspath(path.dirname(__file__)))
path_to_text_file_loc35R = path.join(bundle_dir_text_file_loc35R, 'filesave')
os.makedirs(path_to_text_file_loc35R, exist_ok=True)
try:
conn_file_from_loc35R = sqlite3.connect(path_to_data_base_loc35R + '\\ils35R.db')
curseur_file_from_loc35R=conn_file_from_loc35R.cursor()
c_file_from_loc35R=curseur_file_from_loc