File dialog (QFileDialog) use to select files or directory contain the option QFileDialog.DontUseNativeDialog. This option allow to open the file dialog in front of the MainWindow takig into account the directory option.
parent
b15705ebb7
commit
ba7ae3979c
|
|
@ -1,4 +1,3 @@
|
||||||
import os.path
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QPushButton, QComboBox, QLineEdit, QLabel,
|
from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QPushButton, QComboBox, QLineEdit, QLabel,
|
||||||
|
|
@ -13,13 +12,11 @@ import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
# import matplotlib
|
|
||||||
# matplotlib.use("Qt5Agg")
|
|
||||||
from matplotlib.colors import LogNorm, CSS4_COLORS, BoundaryNorm
|
from matplotlib.colors import LogNorm, CSS4_COLORS, BoundaryNorm
|
||||||
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
|
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
|
||||||
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar
|
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar
|
||||||
|
|
||||||
from os import path, name
|
from os import path
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import locale
|
import locale
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
|
@ -37,37 +34,13 @@ from qtrangeslider import QLabeledDoubleRangeSlider
|
||||||
import Translation.constant_string as cs
|
import Translation.constant_string as cs
|
||||||
|
|
||||||
from Model.TableModel import TableModel
|
from Model.TableModel import TableModel
|
||||||
from Model.AquascatDataLoader import RawAquascatData
|
|
||||||
from Model.acoustic_data_loader import AcousticDataLoader
|
from Model.acoustic_data_loader import AcousticDataLoader
|
||||||
from Model.acoustic_data_loader_UBSediFlow import AcousticDataLoaderUBSediFlow
|
from Model.acoustic_data_loader_UBSediFlow import AcousticDataLoaderUBSediFlow
|
||||||
# from View.window_noise_level_averaged_profile import WindowNoiseLevelTailAveragedProfile
|
|
||||||
|
|
||||||
import settings as stg
|
import settings as stg
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
# class FloatDelegate(QItemDelegate):
|
|
||||||
# def __init__(self, decimals, parent=None):
|
|
||||||
# QItemDelegate.__init__(self, parent=parent)
|
|
||||||
# self.nDecimals = decimals
|
|
||||||
#
|
|
||||||
# def paint(self, painter, option, index):
|
|
||||||
# value = index.model().data(index, Qt.EditRole)
|
|
||||||
# try:
|
|
||||||
# number = float(value)
|
|
||||||
# painter.drawText(option.rect, Qt.AlignLeft, "{:.{}f}".format(number, self.nDecimals))
|
|
||||||
# except :
|
|
||||||
# QItemDelegate.paint(self, painter, option, index)
|
|
||||||
|
|
||||||
# class WidgetPlot(QWidget):
|
|
||||||
# def __init__(self, *args, **kwargs):
|
|
||||||
# QWidget.__init__(self, *args, **kwargs)
|
|
||||||
# self.setLayout(QVBoxLayout())
|
|
||||||
# self.canvas = FigureCanvas(self)
|
|
||||||
# self.toolbar = NavigationToolBar(self.canvas, self)
|
|
||||||
# self.layout().addWidget(self.toolbar)
|
|
||||||
# self.layout().addWidget(self.canvas)
|
|
||||||
|
|
||||||
|
|
||||||
class AcousticDataTab(QWidget):
|
class AcousticDataTab(QWidget):
|
||||||
|
|
||||||
|
|
@ -87,13 +60,14 @@ class AcousticDataTab(QWidget):
|
||||||
|
|
||||||
# Utiliser os.path.split() OU os.path.join()
|
# Utiliser os.path.split() OU os.path.join()
|
||||||
|
|
||||||
if name == 'posix':
|
# if name == 'posix':
|
||||||
self.path_icon = "./icons/"
|
# self.path_icon = "./icons/"
|
||||||
print("os.name = ", self.path_icon)
|
# print("os.name = ", self.path_icon)
|
||||||
else:
|
# else:
|
||||||
self.path_icon = r".\\icons\\"
|
# self.path_icon = r".\\icons\\"
|
||||||
print("os.name = ", self.path_icon)
|
# print("os.name = ", self.path_icon)
|
||||||
|
|
||||||
|
self.path_icon = "./icons/"
|
||||||
self.icon_folder = QIcon(self.path_icon + "folder.png")
|
self.icon_folder = QIcon(self.path_icon + "folder.png")
|
||||||
self.icon_apply_limits = QIcon(self.path_icon + "circle_green_arrow_right.png")
|
self.icon_apply_limits = QIcon(self.path_icon + "circle_green_arrow_right.png")
|
||||||
self.icon_triangle_left_to_begin = QIcon(self.path_icon + "triangle_left_to_begin.png")
|
self.icon_triangle_left_to_begin = QIcon(self.path_icon + "triangle_left_to_begin.png")
|
||||||
|
|
@ -1824,7 +1798,7 @@ class AcousticDataTab(QWidget):
|
||||||
if self.fileListWidget.count() > 0:
|
if self.fileListWidget.count() > 0:
|
||||||
stg.water_attenuation[self.fileListWidget.currentRow()].clear()
|
stg.water_attenuation[self.fileListWidget.currentRow()].clear()
|
||||||
for f in stg.freq[self.fileListWidget.currentRow()]:
|
for f in stg.freq[self.fileListWidget.currentRow()]:
|
||||||
if float(self.lineEdit_temperature.text()[:-3]) > 20:
|
if float(self.lineEdit_temperature.text()) > 20:
|
||||||
alpha = ((3.964 * 1e-4 -
|
alpha = ((3.964 * 1e-4 -
|
||||||
1.146 * 1e-5 * float(self.lineEdit_temperature.text()) +
|
1.146 * 1e-5 * float(self.lineEdit_temperature.text()) +
|
||||||
1.45 * 1e-7 * float(self.lineEdit_temperature.text()) ** 2 -
|
1.45 * 1e-7 * float(self.lineEdit_temperature.text()) ** 2 -
|
||||||
|
|
@ -1861,21 +1835,24 @@ class AcousticDataTab(QWidget):
|
||||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
msgBox.exec()
|
msgBox.exec()
|
||||||
elif self.combobox_ABS_system_choice.currentIndex() == 1:
|
elif self.combobox_ABS_system_choice.currentIndex() == 1:
|
||||||
filename = QFileDialog.getOpenFileNames(self, "Open file",
|
print("hello ", [stg.path_BS_raw_data[-1] if self.fileListWidget.count() > 0 else ""][0])
|
||||||
|
filename = QFileDialog.getOpenFileNames(self, "AQUAscat file",
|
||||||
[stg.path_BS_raw_data[-1] if self.fileListWidget.count() > 0 else ""][0],
|
[stg.path_BS_raw_data[-1] if self.fileListWidget.count() > 0 else ""][0],
|
||||||
"Aquascat file (*.aqa)")
|
"Aquascat file (*.aqa)",
|
||||||
for name in filename[0]:
|
options=QFileDialog.DontUseNativeDialog)
|
||||||
|
print("filenme ", filename)
|
||||||
|
for n in filename[0]:
|
||||||
|
|
||||||
stg.path_BS_raw_data.append(path.dirname(name))
|
stg.path_BS_raw_data.append(path.dirname(n))
|
||||||
stg.filename_BS_raw_data.append(path.basename(name))
|
stg.filename_BS_raw_data.append(path.basename(n))
|
||||||
stg.data_preprocessed.append(path.basename(name))
|
stg.data_preprocessed.append(path.basename(n))
|
||||||
|
|
||||||
print("stg.path_BS_raw_data ", stg.path_BS_raw_data)
|
print("stg.path_BS_raw_data ", stg.path_BS_raw_data)
|
||||||
print("stg.filename_BS_raw_data ", stg.filename_BS_raw_data)
|
print("stg.filename_BS_raw_data ", stg.filename_BS_raw_data)
|
||||||
print("stg.data_preprocessed ", stg.data_preprocessed)
|
print("stg.data_preprocessed ", stg.data_preprocessed)
|
||||||
|
|
||||||
elif self.combobox_ABS_system_choice.currentIndex() == 2:
|
elif self.combobox_ABS_system_choice.currentIndex() == 2:
|
||||||
filename = QFileDialog.getOpenFileName(self, "Open file",
|
filename = QFileDialog.getOpenFileName(self, "UBSediFlow file",
|
||||||
[stg.path_BS_raw_data[-1] if self.fileListWidget.count() > 0 else ""][0],
|
[stg.path_BS_raw_data[-1] if self.fileListWidget.count() > 0 else ""][0],
|
||||||
"UBSediFlow file (*.udt)")
|
"UBSediFlow file (*.udt)")
|
||||||
dir_name = path.dirname(filename[0])
|
dir_name = path.dirname(filename[0])
|
||||||
|
|
@ -2763,6 +2740,7 @@ class AcousticDataTab(QWidget):
|
||||||
# ["BS - " + f for f in stg.freq_text[self.fileListWidget.currentRow()]])))
|
# ["BS - " + f for f in stg.freq_text[self.fileListWidget.currentRow()]])))
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
print("hola")
|
||||||
self.tableModel = TableModel(stg.DataFrame_acoustic)
|
self.tableModel = TableModel(stg.DataFrame_acoustic)
|
||||||
self.tableView.setModel(self.tableModel)
|
self.tableView.setModel(self.tableModel)
|
||||||
# self.tableView.setItemDelegate(FloatDelegate(3))
|
# self.tableView.setItemDelegate(FloatDelegate(3))
|
||||||
|
|
|
||||||
|
|
@ -585,9 +585,14 @@ class SampleDataTab(QWidget):
|
||||||
# ------------------------------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------------------------------------------
|
||||||
# --- Function to select directory and file name of fine sediments sample data ---
|
# --- Function to select directory and file name of fine sediments sample data ---
|
||||||
def open_dialog_box_fine_sediment(self):
|
def open_dialog_box_fine_sediment(self):
|
||||||
filename_fine_sediment = QFileDialog.getOpenFileName(self, "Open file",
|
print("Fine sediment file", [stg.path_fine if stg.path_fine else stg.path_sand if stg.path_sand
|
||||||
"/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data",
|
else stg.path_BS_raw_data[-1] if self.combobox_acoustic_data.count() > 0 else ""][0])
|
||||||
"Fine sediment file (*.xls, *.ods)")
|
filename_fine_sediment = QFileDialog.getOpenFileName(
|
||||||
|
self, "Fine sediment file",
|
||||||
|
[stg.path_fine if stg.path_fine else stg.path_sand if stg.path_sand
|
||||||
|
else stg.path_BS_raw_data[-1] if self.combobox_acoustic_data.count() > 0 else ""][0],
|
||||||
|
"Fine sediment file (*.xlsx, *xls, *.ods)",
|
||||||
|
options=QFileDialog.DontUseNativeDialog)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
stg.path_fine = path.dirname(filename_fine_sediment[0])
|
stg.path_fine = path.dirname(filename_fine_sediment[0])
|
||||||
|
|
@ -608,9 +613,14 @@ class SampleDataTab(QWidget):
|
||||||
|
|
||||||
# --- Function to select directory and file name of sand sediments sample data ---
|
# --- Function to select directory and file name of sand sediments sample data ---
|
||||||
def open_dialog_box_sand_sediment(self):
|
def open_dialog_box_sand_sediment(self):
|
||||||
filename_sand_sediment = QFileDialog.getOpenFileName(self, "Open file",
|
print("Sand sediment file", [stg.path_sand if stg.path_sand else stg.path_fine if stg.path_fine
|
||||||
"/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data",
|
else stg.path_BS_raw_data[-1] if self.combobox_acoustic_data.count() > 0 else ""][0])
|
||||||
"Sand sediment file (*.xls, *.ods)")
|
filename_sand_sediment = QFileDialog.getOpenFileName(
|
||||||
|
self, "Sand sediment file",
|
||||||
|
[stg.path_sand if stg.path_sand else stg.path_fine if stg.path_fine
|
||||||
|
else stg.path_BS_raw_data[-1] if self.combobox_acoustic_data.count() > 0 else ""][0],
|
||||||
|
"Sand sediment file (*.xlsx, *xls, *.ods)",
|
||||||
|
options=QFileDialog.DontUseNativeDialog)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
stg.path_sand = path.dirname(filename_sand_sediment[0])
|
stg.path_sand = path.dirname(filename_sand_sediment[0])
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,10 @@ from os import path
|
||||||
from View.checkable_combobox import CheckableComboBox
|
from View.checkable_combobox import CheckableComboBox
|
||||||
|
|
||||||
from Model.acoustic_inversion_method_high_concentration import AcousticInversionMethodHighConcentration
|
from Model.acoustic_inversion_method_high_concentration import AcousticInversionMethodHighConcentration
|
||||||
from settings import depth_cross_section, BS_raw_data_pre_process_average, BS_raw_data_pre_process_SNR, BS_raw_data
|
from settings import depth_cross_section, BS_raw_data_pre_process_average, BS_raw_data_pre_process_SNR, BS_raw_data, \
|
||||||
|
path_calibration_file
|
||||||
|
|
||||||
|
|
||||||
# from virtual_env.bin.odfimg import directory
|
# from virtual_env.bin.odfimg import directory
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1241,16 +1244,19 @@ class SedimentCalibrationTab(QWidget):
|
||||||
|
|
||||||
def import_calibration_file(self):
|
def import_calibration_file(self):
|
||||||
|
|
||||||
filename = QFileDialog.getOpenFileName(self, "Open file",
|
filename = QFileDialog.getOpenFileName(
|
||||||
# [stg.path_BS_raw_data[-1] if stg.path_BS_raw_data[-1] != "" else ""][0],
|
self, "Open calibration",
|
||||||
"Calibration file (*.xls, *.ods, *csv)")
|
[stg.path_calibration_file if stg.path_calibration_file else
|
||||||
|
stg.path_BS_raw_data[
|
||||||
|
-1] if self.combobox_acoustic_data_choice.count() > 0 else ""][0],
|
||||||
|
"Calibration file (*.xls, *.ods, *csv)",
|
||||||
|
options=QFileDialog.DontUseNativeDialog)
|
||||||
|
|
||||||
dir_name = path.dirname(filename[0])
|
dir_name = path.dirname(filename[0])
|
||||||
name = path.basename(filename[0])
|
name = path.basename(filename[0])
|
||||||
|
|
||||||
stg.calibration_file.clear()
|
stg.path_calibration_import_file = dir_name
|
||||||
stg.calibration_file.append(dir_name)
|
stg.filename_calibration_import_file = name
|
||||||
stg.calibration_file.append(name)
|
|
||||||
print("stg.calibration_file ", stg.calibration_file)
|
|
||||||
|
|
||||||
self.lineEdit_import_calibration.clear()
|
self.lineEdit_import_calibration.clear()
|
||||||
self.lineEdit_import_calibration.setText(name)
|
self.lineEdit_import_calibration.setText(name)
|
||||||
|
|
@ -2080,7 +2086,12 @@ class SedimentCalibrationTab(QWidget):
|
||||||
|
|
||||||
def save_calibration(self):
|
def save_calibration(self):
|
||||||
|
|
||||||
dir_save_cal = QFileDialog.getExistingDirectory(caption="Save calibration")
|
dir_save_cal = QFileDialog.getExistingDirectory(
|
||||||
|
caption="Save calibration",
|
||||||
|
directory=[stg.path_calibration_save_file if stg.path_calibration_save_file else stg.path_BS_raw_data[-1] if self.combobox_acoustic_data_choice.count() > 0 else ""][0],
|
||||||
|
options=QFileDialog.DontUseNativeDialog)
|
||||||
|
|
||||||
|
stg.path_calibration_save_file = path.dirname(dir_save_cal)
|
||||||
|
|
||||||
cal_array = [[' ', stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[0][1]],
|
cal_array = [[' ', stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[0][1]],
|
||||||
stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[1][1]]],
|
stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[1][1]]],
|
||||||
|
|
|
||||||
|
|
@ -1478,9 +1478,10 @@ class SignalProcessingTab(QWidget):
|
||||||
def open_dialog_box(self):
|
def open_dialog_box(self):
|
||||||
|
|
||||||
if self.sender().objectName() == "pushbutton_noise_file":
|
if self.sender().objectName() == "pushbutton_noise_file":
|
||||||
filename = QFileDialog.getOpenFileName(self, "Open file",
|
filename = QFileDialog.getOpenFileNames(self, "AQUAscat Noise file",
|
||||||
"/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data",
|
[stg.path_BS_raw_data[-1] if self.combobox_fileListWidget.count() > 0 else ""][0],
|
||||||
"Aquascat file (*.aqa)")
|
"Aquascat file (*.aqa)",
|
||||||
|
options=QFileDialog.DontUseNativeDialog)
|
||||||
dir_name = path.dirname(filename[0])
|
dir_name = path.dirname(filename[0])
|
||||||
name = path.basename(filename[0])
|
name = path.basename(filename[0])
|
||||||
|
|
||||||
|
|
|
||||||
2
main.py
2
main.py
|
|
@ -5,7 +5,7 @@ from PyQt5.QtWidgets import QApplication, QMainWindow
|
||||||
from PyQt5.QtCore import QCoreApplication
|
from PyQt5.QtCore import QCoreApplication
|
||||||
|
|
||||||
from View.mainwindow import Ui_MainWindow
|
from View.mainwindow import Ui_MainWindow
|
||||||
from View.acoustic_data_tab0 import AcousticDataTab
|
from View.acoustic_data_tab import AcousticDataTab
|
||||||
from View.signal_processing_tab import SignalProcessingTab
|
from View.signal_processing_tab import SignalProcessingTab
|
||||||
from View.sample_data_tab import SampleDataTab
|
from View.sample_data_tab import SampleDataTab
|
||||||
from View.sediment_calibration_tab import SedimentCalibrationTab
|
from View.sediment_calibration_tab import SedimentCalibrationTab
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,9 @@ frequencies_for_calibration = []
|
||||||
range_lin_interp = []
|
range_lin_interp = []
|
||||||
M_profile_fine = []
|
M_profile_fine = []
|
||||||
|
|
||||||
calibration_file = []
|
path_calibration_save_file = ""
|
||||||
|
path_calibration_import_file = ""
|
||||||
|
filename_calibration_import_file = ""
|
||||||
|
|
||||||
ks = []
|
ks = []
|
||||||
sv = []
|
sv = []
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue