diff --git a/icons_imgs/image_not_found.png b/icons_imgs/image_not_found.png new file mode 100644 index 0000000..b93e555 Binary files /dev/null and b/icons_imgs/image_not_found.png differ diff --git a/main.py b/main.py index 1215da2..cac0f1c 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,12 @@ import sys import os +from pandas import read_csv from PyQt5.QtWidgets import (QMainWindow, - QApplication,) + QApplication, + QMessageBox,) from PyQt5.QtGui import QPixmap from PyQt5 import uic +from PyQt5.QtCore import QFileInfo qt_creator_file = "main_window.ui" @@ -13,9 +16,47 @@ class MyApp(QMainWindow, Ui_MainWindow): def __init__(self): super().__init__() self.setupUi(self) + self.show() + self.load_db() + self.display_signals() + self.search_bar.textChanged.connect(self.display_signals) + self.result_list.itemSelectionChanged.connect(self.display_spectrogram) + + def load_db(self): + try: + db = read_csv(os.path.join('Data', 'db.csv'), + sep = '*', + header = None, + prefix = 'signal_') + except FileNotFoundError: + self.signal_names = '' + self.search_bar.setDisabled(True) + box = QMessageBox(self) + box.setStyleSheet(""" + color:#FFFFFF; + """) + box.setWindowTitle("No database") + box.setText("No database available.\n" + "Go to Updates->Download database.") + box.show() + else: + self.signal_names = db['signal_0'] + + def display_signals(self): + self.result_list.clear() + for signal in self.signal_names: + if self.search_bar.text().lower() in signal.lower(): + self.result_list.addItem(signal) + + def display_spectrogram(self): + spectrogram_name = self.result_list.currentItem().text() + path_spectr = os.path.join("Data", "Spectra", spectrogram_name + ".jpg") + if not QFileInfo(path_spectr).exists(): + path_spectr = os.path.join("icons_imgs", "image_not_found.png") + self.spectrogram.setPixmap(QPixmap(path_spectr)) + if __name__ == '__main__': my_app = QApplication(sys.argv) w = MyApp() - w.show() sys.exit(my_app.exec_()) \ No newline at end of file diff --git a/main_window.ui b/main_window.ui index 6814df7..5f2a926 100644 --- a/main_window.ui +++ b/main_window.ui @@ -6,76 +6,131 @@ 0 0 - 800 - 527 + 1000 + 800 MainWindow - background-color: #464646 + QWidget { + background-color: #464646 +} + +QPushButton { + color: #FFFFFF +} + +QProgressBar { + /*border: 2px solid grey;*/ + border-radius: 8px; + background-color: #7a7a7a +} + +QProgressBar::chunk { + background-color: #1d5eff; + width: 20px; + border-radius: 7px +} + + - + + + + 0 + 0 + + Qt::Horizontal - - - - - - - - - - - Search a signal name. - - - color: rgb(255, 255, 255); + + + + 0 + 0 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 2 + + + + + + + + Search a signal name. + + + color: rgb(255, 255, 255); border: 1px solid gray; border-radius: 5px; - - - - - - - - 0 - 0 - - - - - 20 - 20 - - - - - 20 - 20 - - - - - - - icons_imgs/search_icon.png - - - true - - - - + + - + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 20 + 20 + + + + + + + icons_imgs/search_icon.png + + + true + + + + @@ -83,10 +138,22 @@ border-radius: 5px; 0 + + + - color: rgb(255, 255, 255); -border: 1px solid gray; -border-radius: 15px; + QListWidget { + color: rgb(255, 255, 255); + border: 1px solid gray; + border-radius: 10px; +} + + + + Qt::ScrollBarAsNeeded + + + Qt::ScrollBarAsNeeded @@ -96,6 +163,12 @@ border-radius: 15px; true + + + 1 + 0 + + Qt::LeftToRight @@ -152,9 +225,105 @@ QTabBar::tab:!selected { true + + + 0 + 0 + + + + + 0 + 0 + + Main + + + + 480 + 280 + 221 + 421 + + + + + + + true + + + + + + 50 + 120 + 371 + 381 + + + + + + 40 + 40 + 75 + 23 + + + + PushButton + + + + + + 140 + 40 + 75 + 23 + + + + PushButton + + + + + + 240 + 40 + 75 + 23 + + + + PushButton + + + + + + 110 + 90 + 118 + 23 + + + + + + + 15 + + + false + + + @@ -171,12 +340,24 @@ QTabBar::tab:!selected { 0 0 - 800 + 1000 21 - color: rgb(255, 255, 255); + QMenuBar { + color: rgb(255, 255, 255); +} + +QMenuBar::item:selected { + background:#999999; + color: #1d5eff +} + +QMenu::item:selected { + background-color: #999999; + color: #1d5eff +}