Add signals list, search bar, picture display
This commit is contained in:
BIN
icons_imgs/image_not_found.png
Normal file
BIN
icons_imgs/image_not_found.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
45
main.py
45
main.py
@@ -1,9 +1,12 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
from pandas import read_csv
|
||||||
from PyQt5.QtWidgets import (QMainWindow,
|
from PyQt5.QtWidgets import (QMainWindow,
|
||||||
QApplication,)
|
QApplication,
|
||||||
|
QMessageBox,)
|
||||||
from PyQt5.QtGui import QPixmap
|
from PyQt5.QtGui import QPixmap
|
||||||
from PyQt5 import uic
|
from PyQt5 import uic
|
||||||
|
from PyQt5.QtCore import QFileInfo
|
||||||
|
|
||||||
qt_creator_file = "main_window.ui"
|
qt_creator_file = "main_window.ui"
|
||||||
|
|
||||||
@@ -13,9 +16,47 @@ class MyApp(QMainWindow, Ui_MainWindow):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.setupUi(self)
|
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__':
|
if __name__ == '__main__':
|
||||||
my_app = QApplication(sys.argv)
|
my_app = QApplication(sys.argv)
|
||||||
w = MyApp()
|
w = MyApp()
|
||||||
w.show()
|
|
||||||
sys.exit(my_app.exec_())
|
sys.exit(my_app.exec_())
|
||||||
217
main_window.ui
217
main_window.ui
@@ -6,28 +6,85 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>1000</width>
|
||||||
<height>527</height>
|
<height>800</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">background-color: #464646</string>
|
<string notr="true">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
|
||||||
|
}
|
||||||
|
|
||||||
|
</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QSplitter" name="splitter">
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="">
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<property name="sizePolicy">
|
||||||
<item>
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<horstretch>0</horstretch>
|
||||||
<item>
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
<widget class="QLineEdit" name="search_bar">
|
<widget class="QLineEdit" name="search_bar">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string/>
|
<string/>
|
||||||
@@ -42,7 +99,7 @@ border-radius: 5px;</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="1">
|
||||||
<widget class="QLabel" name="search_label">
|
<widget class="QLabel" name="search_label">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
@@ -73,9 +130,7 @@ border-radius: 5px;</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
<item row="1" column="0" colspan="2">
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="result_list">
|
<widget class="QListWidget" name="result_list">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
@@ -83,10 +138,22 @@ border-radius: 5px;</string>
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">color: rgb(255, 255, 255);
|
<string notr="true">QListWidget {
|
||||||
border: 1px solid gray;
|
color: rgb(255, 255, 255);
|
||||||
border-radius: 15px;</string>
|
border: 1px solid gray;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
</string>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -96,6 +163,12 @@ border-radius: 15px;</string>
|
|||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>1</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="layoutDirection">
|
<property name="layoutDirection">
|
||||||
<enum>Qt::LeftToRight</enum>
|
<enum>Qt::LeftToRight</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -152,9 +225,105 @@ QTabBar::tab:!selected {
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Main</string>
|
<string>Main</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<widget class="QLabel" name="spectrogram">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>480</x>
|
||||||
|
<y>280</y>
|
||||||
|
<width>221</width>
|
||||||
|
<height>421</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="widget_2" native="true">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>50</x>
|
||||||
|
<y>120</y>
|
||||||
|
<width>371</width>
|
||||||
|
<height>381</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>40</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>75</width>
|
||||||
|
<height>23</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>PushButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="pushButton_2">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>140</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>75</width>
|
||||||
|
<height>23</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>PushButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="pushButton_3">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>240</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>75</width>
|
||||||
|
<height>23</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>PushButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QProgressBar" name="progressBar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>110</x>
|
||||||
|
<y>90</y>
|
||||||
|
<width>118</width>
|
||||||
|
<height>23</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>15</number>
|
||||||
|
</property>
|
||||||
|
<property name="textVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_2">
|
<widget class="QWidget" name="tab_2">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -171,12 +340,24 @@ QTabBar::tab:!selected {
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>1000</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">color: rgb(255, 255, 255);</string>
|
<string notr="true">QMenuBar {
|
||||||
|
color: rgb(255, 255, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenuBar::item:selected {
|
||||||
|
background:#999999;
|
||||||
|
color: #1d5eff
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenu::item:selected {
|
||||||
|
background-color: #999999;
|
||||||
|
color: #1d5eff
|
||||||
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
|
|||||||
Reference in New Issue
Block a user