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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QFileDialog, QDialog
from PyQt5 import uic, QtCore
class MainWindowOPO(QMainWindow):
def __init__(self, parent = None):
### Portion du code qui permet de convertir l'interface .ui de QtDesigner en .py
super(MainWindowOPO, self).__init__() # Call the inherited classes __init__ method
uic.loadUi('MainWindowOPO.ui', self) # Load the .ui file
################################################################################
### Action lie a la barre des menus
self.actionLoad.triggered.connect(self.actionLoadExperiment)
self.pushButtonPivotal.clicked.connect(self.onPushButtonPivotal)
def onPushButtonPivotal(self): ### Procedure pour pivoter une courbe entre deux points (regression lineaire pour avoir les deux points a zero)
self.pivotalWindow = PopUpPivotal()
self.pivotalWindow.setWindowModality(QtCore.Qt.ApplicationModal)
self.pivotalWindow.show()
def actionLoadExperiment(self):
dialog = QFileDialog()
experiment_filename = dialog.getOpenFileName()
self.loaded_filename = experiment_filename[0]
return self.loaded_filename
###################################################################################################
class PopUpPivotal(QDialog):
def __init__(self, parent = None):
super(PopUpPivotal, self).__init__() # Call the inherited classes __init__ method
uic.loadUi('PopUpPivotal.ui', self) # Load the .ui file
self.pushButtonPivotal.clicked.connect(self.onPushButtonPivotal)
def onPushButtonPivotal(self):
t = MainWindowOPO().actionLoadExperiment()
print(t)
self.close()
#############################################################################################
### Code minimal pour afficher l'interface graphique
if __name__.endswith('__main__'):
if not QApplication.instance():
MainApp = QApplication(sys.argv)
else :
MainApp = QApplication.instance()
mainWindow = MainWindowOPO()
mainWindow.show()
rc = MainApp.exec_()
sys.exit(rc) |
Partager