parent
4af3c4c9ea
commit
5ebd842346
|
|
@ -20,16 +20,20 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import time
|
||||
import sqlite3
|
||||
import logging
|
||||
|
||||
import numpy as np
|
||||
from PyQt5.QtWidgets import QFileDialog, QApplication, QMessageBox
|
||||
import sqlite3
|
||||
import settings as stg
|
||||
from os import chdir
|
||||
import time
|
||||
|
||||
from PyQt5.QtWidgets import QFileDialog, QApplication, QMessageBox
|
||||
|
||||
import settings as stg
|
||||
from settings import ABS_name
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class CreateTableForSaveAs:
|
||||
|
||||
def __init__(self):
|
||||
|
|
@ -165,23 +169,32 @@ class CreateTableForSaveAs:
|
|||
|
||||
|
||||
def open_file_dialog(self):
|
||||
options = QFileDialog.Options()
|
||||
name = QFileDialog.getSaveFileName(
|
||||
caption="Save As", directory="", filter="AcouSed Files (*.acd)", options=QFileDialog.DontUseNativeDialog)
|
||||
name, _ = QFileDialog.getSaveFileName(
|
||||
caption="Save As",
|
||||
directory="",
|
||||
filter="AcouSed Files (*.acd)",
|
||||
options=QFileDialog.DontUseNativeDialog
|
||||
)
|
||||
|
||||
if name[0]:
|
||||
if name != "":
|
||||
filename = os.path.basename(name)
|
||||
if os.path.splitext(filename)[1] != ".acd":
|
||||
filename += ".acd"
|
||||
|
||||
stg.dirname_save_as = "/".join(name[0].split("/")[:-1]) + "/"
|
||||
stg.filename_save_as = name[0].split("/")[-1]
|
||||
logger.debug(f"selected save file: '{filename}'")
|
||||
|
||||
chdir(stg.dirname_save_as)
|
||||
stg.dirname_save_as = os.path.dirname(name)
|
||||
stg.filename_save_as = filename
|
||||
|
||||
try:
|
||||
os.chdir(stg.dirname_save_as)
|
||||
except OSError as e:
|
||||
logger.warning(f"chdir: {str(e)}")
|
||||
|
||||
start = time.time()
|
||||
self.create_table()
|
||||
print(f"end : {time.time() - start} sec")
|
||||
|
||||
else:
|
||||
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Save Error")
|
||||
msgBox.setIcon(QMessageBox.Warning)
|
||||
|
|
@ -192,7 +205,7 @@ class CreateTableForSaveAs:
|
|||
def create_table(self):
|
||||
|
||||
# Create a new database and open a database connection to allow sqlite3 to work with it.
|
||||
cnx = sqlite3.connect(stg.filename_save_as + '.acd')
|
||||
cnx = sqlite3.connect(stg.filename_save_as)
|
||||
|
||||
# Create database cursor to execute SQL statements and fetch results from SQL queries.
|
||||
cur = cnx.cursor()
|
||||
|
|
@ -459,6 +472,3 @@ class CreateTableForSaveAs:
|
|||
|
||||
# Close database connection
|
||||
cnx.close()
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,37 +20,50 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import numpy as np
|
||||
from PyQt5.QtWidgets import QFileDialog, QApplication, QWidget, QTabWidget
|
||||
import sqlite3
|
||||
from os import path, chdir
|
||||
import logging
|
||||
import numpy as np
|
||||
|
||||
from PyQt5.QtWidgets import QFileDialog, QApplication, QWidget, QTabWidget
|
||||
|
||||
import settings as stg
|
||||
from settings import BS_raw_data, acoustic_data
|
||||
|
||||
from View.acoustic_data_tab import AcousticDataTab
|
||||
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class ReadTableForOpen:
|
||||
|
||||
def __init__(self):
|
||||
self.opened = False
|
||||
|
||||
pass
|
||||
self.open_file_dialog()
|
||||
|
||||
def open_file_dialog(self):
|
||||
name, _ = QFileDialog.getOpenFileName(
|
||||
caption="Open Acoused file",
|
||||
directory="",
|
||||
filter="Acoused file (*.acd)",
|
||||
options=QFileDialog.DontUseNativeDialog
|
||||
)
|
||||
|
||||
name = QFileDialog.getOpenFileName(caption="Open Acoused file", directory="", filter="Acoused file (*.acd)",
|
||||
options=QFileDialog.DontUseNativeDialog)
|
||||
if name != "":
|
||||
stg.dirname_open = os.path.dirname(name)
|
||||
stg.filename_open = os.path.basename(name)
|
||||
|
||||
if name:
|
||||
try:
|
||||
os.chdir(stg.dirname_open)
|
||||
except OSError as e:
|
||||
logger.warning(f"chdir: {str(e)}")
|
||||
|
||||
stg.dirname_open = path.dirname(name[0])
|
||||
stg.filename_open = path.basename(name[0])
|
||||
|
||||
chdir(stg.dirname_open)
|
||||
self.sql_file_to_open = open(stg.filename_open)
|
||||
|
||||
self.read_table()
|
||||
self.opened = True
|
||||
|
||||
|
||||
def read_table(self):
|
||||
|
||||
|
|
@ -428,4 +441,3 @@ class ReadTableForOpen:
|
|||
|
||||
stg.BS_raw_data.append(np.reshape(stg.BS_raw_data_reshape[i],
|
||||
(len(stg.freq[i]), stg.depth[i].shape[1], stg.time[i].shape[1])))
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class UpdateTableForSave:
|
|||
def update_table(self):
|
||||
|
||||
# Create a new database and open a database connection to allow sqlite3 to work with it.
|
||||
cnx = sqlite3.connect(stg.filename_save_as + '.acd')
|
||||
cnx = sqlite3.connect(stg.filename_save_as)
|
||||
|
||||
# Create database cursor to execute SQL statements and fetch results from SQL queries.
|
||||
cur = cnx.cursor()
|
||||
|
|
@ -417,6 +417,3 @@ class UpdateTableForSave:
|
|||
|
||||
# Close database connection
|
||||
cnx.close()
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -262,13 +262,18 @@ class Ui_MainWindow(object):
|
|||
|
||||
def save_as(self):
|
||||
CreateTableForSaveAs()
|
||||
self.mainwindow.setWindowTitle("AcouSed - " + stg.filename_save_as + ".acd")
|
||||
self.mainwindow.setWindowTitle(
|
||||
"AcouSed - " +
|
||||
stg.filename_save_as
|
||||
)
|
||||
|
||||
def save(self):
|
||||
UpdateTableForSave()
|
||||
|
||||
def open(self):
|
||||
ReadTableForOpen()
|
||||
reader = ReadTableForOpen()
|
||||
if reader.opened:
|
||||
self.mainwindow.open_study_update_tabs()
|
||||
|
||||
def load_calibration_constant_values(self):
|
||||
cc_kt = CalibrationConstantKt()
|
||||
|
|
|
|||
18
main.py
18
main.py
|
|
@ -33,7 +33,7 @@ logging.basicConfig(
|
|||
)
|
||||
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
class MainApplication(QMainWindow):
|
||||
|
||||
|
|
@ -49,15 +49,18 @@ class MainApplication(QMainWindow):
|
|||
height = size.height()
|
||||
self.resize(int(PERCENT_SCREEN_SIZE*width), int(PERCENT_SCREEN_SIZE*height))
|
||||
try:
|
||||
self.read_table_open = ReadTableForOpen()
|
||||
# **************************************************
|
||||
# -------------- Acoustic data tab ---------------
|
||||
|
||||
self.acoustic_data_tab = AcousticDataTab(self.ui_mainwindow.tab1)
|
||||
print("0 AcousticDataTab ", id(AcousticDataTab))
|
||||
|
||||
self.acoustic_data_tab.combobox_ABS_system_choice.editTextChanged.connect(
|
||||
self.acoustic_data_tab.ABS_system_choice)
|
||||
self.acoustic_data_tab\
|
||||
.combobox_ABS_system_choice\
|
||||
.editTextChanged\
|
||||
.connect(
|
||||
self.acoustic_data_tab.ABS_system_choice
|
||||
)
|
||||
|
||||
# **************************************************
|
||||
# --------- Signal pre-processing data tab ----------
|
||||
|
|
@ -92,8 +95,6 @@ class MainApplication(QMainWindow):
|
|||
|
||||
# self.user_manual_tab = UserManualTab(self.ui_mainwindow.tab7)
|
||||
|
||||
self.ui_mainwindow.actionOpen.triggered.connect(self.trig_open)
|
||||
|
||||
# **************************************************
|
||||
# ---------------- Text File Error -----------------
|
||||
|
||||
|
|
@ -106,9 +107,7 @@ class MainApplication(QMainWindow):
|
|||
sortie.write(traceback.format_exc())
|
||||
# traceback.TracebackException.from_exception(e).print(file=sortie)
|
||||
|
||||
def trig_open(self):
|
||||
self.read_table_open.open_file_dialog()
|
||||
|
||||
def open_study_update_tabs(self):
|
||||
self.acoustic_data_tab.combobox_ABS_system_choice.setCurrentText(stg.ABS_name[0])
|
||||
self.acoustic_data_tab.fileListWidget.addFilenames(stg.filename_BS_raw_data)
|
||||
|
||||
|
|
@ -119,7 +118,6 @@ class MainApplication(QMainWindow):
|
|||
self.sample_data_tab.lineEdit_fine_sediment.setToolTip(stg.path_fine)
|
||||
# self.sample_data_tab.fill_table_fine()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# print("sys.argv:", [arg for arg in sys.argv])
|
||||
# app = MainApplication(sys.argv)
|
||||
|
|
|
|||
Loading…
Reference in New Issue