-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgui.py
191 lines (167 loc) · 8.92 KB
/
gui.py
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'design.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
import pyqtgraph as pg
from PyQt5.QtGui import QKeySequence
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(851, 572)
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
MainWindow.setFont(font)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout_6.setObjectName("verticalLayout_6")
self.verticalLayout_5 = QtWidgets.QVBoxLayout()
self.verticalLayout_5.setObjectName("verticalLayout_5")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.verticalLayout_3 = QtWidgets.QVBoxLayout()
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.input_label = QtWidgets.QLabel(self.centralwidget)
self.input_label.setObjectName("input_label")
self.verticalLayout_3.addWidget(self.input_label)
styles = {'color':'b', 'font-size':'5px'}
self.input_signal = pg.PlotWidget(self.centralwidget)
self.input_signal.setBackground('w')
self.input_signal.setStyleSheet("background-color: rgb(255, 255, 255);")
self.input_signal.setLabel('left', 'Amplitude', **styles)
self.input_signal.setLabel('bottom', 'time (sec)', **styles)
self.input_signal.showGrid(x=True, y=True)
self.input_signal.setXRange(0, 0.7)
self.verticalLayout_3.addWidget(self.input_signal)
self.output_label = QtWidgets.QLabel(self.centralwidget)
self.output_label.setObjectName("output_label")
self.verticalLayout_3.addWidget(self.output_label)
self.output_signal = pg.PlotWidget(self.centralwidget)
self.output_signal.setBackground('w')
self.output_signal.setStyleSheet("background-color: rgb(255, 255, 255);")
self.output_signal.setLabel('left', 'Amplitude', **styles)
self.output_signal.setLabel('bottom', 'time (sec)', **styles)
self.output_signal.showGrid(x=True, y=True)
self.output_signal.setXRange(0, 0.7)
self.verticalLayout_3.addWidget(self.output_signal)
self.horizontalLayout_3.addLayout(self.verticalLayout_3)
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setObjectName("label_2")
self.verticalLayout.addWidget(self.label_2)
# Interpret image data as row-major instead of col-major
pg.setConfigOptions(imageAxisOrder='row-major')
pg.mkQApp()
self.win = pg.GraphicsLayoutWidget()
# A plot area (ViewBox + axes) for displaying the image
self.SpectrogramPlotItem = self.win.addPlot()
# Add labels to the axis
self.SpectrogramPlotItem.setLabel('bottom', "Time", units='sec')
# If you include the units, Pyqtgraph automatically scales the axis and adjusts the SI prefix (in this case kHz)
# self.SpectrogramPlotItem.setLabel('left', "Frequency", units='Hz')
# Item for displaying image data
self.output_spectrogram = pg.ImageItem()
self.SpectrogramPlotItem.addItem(self.output_spectrogram)
# Add a histogram with which to control the gradient of the image
self.hist = pg.HistogramLUTItem()
# Link the histogram to the image
self.hist.setImageItem(self.output_spectrogram)
# If you don't add the histogram to the window, it stays invisible, but I find it useful.
self.win.addItem(self.hist)
# Show the window
self.win.show()
self.verticalLayout.addWidget(self.win)
self.verticalLayout_2.addLayout(self.verticalLayout)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setSpacing(15)
self.horizontalLayout.setObjectName("horizontalLayout")
self.sliders = [QtWidgets.QSlider(self.centralwidget) for i in range(10)]
for slider in self.sliders:
slider.setMinimum(0)
slider.setMaximum(100)
slider.setSliderPosition(20)
slider.setOrientation(QtCore.Qt.Vertical)
self.horizontalLayout.addWidget(slider)
self.verticalLayout_4 = QtWidgets.QVBoxLayout()
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.max_slider = QtWidgets.QSlider(self.centralwidget)
self.max_slider.setOrientation(QtCore.Qt.Horizontal)
self.max_slider.setObjectName("max_slider")
self.max_slider.setMinimum(0)
self.max_slider.setMaximum(1000)
self.max_slider.setSliderPosition(1000)
self.verticalLayout_4.addWidget(self.max_slider)
self.pallet = QtWidgets.QComboBox(self.centralwidget)
self.pallet.setObjectName("pallet")
self.verticalLayout_4.addWidget(self.pallet)
self.min_slider = QtWidgets.QSlider(self.centralwidget)
self.min_slider.setOrientation(QtCore.Qt.Horizontal)
self.min_slider.setObjectName("min_slider")
self.min_slider.setMinimum(0)
self.min_slider.setMaximum(1000)
self.min_slider.setSliderPosition(0)
self.verticalLayout_4.addWidget(self.min_slider)
self.horizontalLayout.addLayout(self.verticalLayout_4)
self.verticalLayout_2.addLayout(self.horizontalLayout)
self.horizontalLayout_3.addLayout(self.verticalLayout_2)
self.verticalLayout_5.addLayout(self.horizontalLayout_3)
self.scroll = QtWidgets.QSlider(self.centralwidget)
self.scroll.setOrientation(QtCore.Qt.Horizontal)
self.scroll.setObjectName("scroll")
self.verticalLayout_5.addWidget(self.scroll)
self.verticalLayout_6.addLayout(self.verticalLayout_5)
self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_5.addItem(spacerItem)
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.zoomOut = QtWidgets.QPushButton(self.centralwidget)
self.zoomOut.setObjectName("zoomOut")
self.horizontalLayout_4.addWidget(self.zoomOut)
self.zoomIn = QtWidgets.QPushButton(self.centralwidget)
self.zoomIn.setObjectName("zoomIn")
self.horizontalLayout_4.addWidget(self.zoomIn)
self.horizontalLayout_5.addLayout(self.horizontalLayout_4)
self.verticalLayout_6.addLayout(self.horizontalLayout_5)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 851, 21))
self.menubar.setObjectName("menubar")
self.file = QtWidgets.QMenu(self.menubar)
self.file.setObjectName("file")
MainWindow.setMenuBar(self.menubar)
self.open = QtWidgets.QAction(MainWindow)
self.open.setObjectName("open")
self.open.setShortcut(QKeySequence("Ctrl+Shift+N"))
self.save = QtWidgets.QAction(MainWindow)
self.save.setObjectName("save")
self.save.setShortcut(QKeySequence("Ctrl+Shift+R"))
self.file.addAction(self.open)
self.file.addAction(self.save)
self.menubar.addAction(self.file.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.input_label.setText(_translate("MainWindow", "Input signal"))
self.output_label.setText(_translate("MainWindow", "Output signal"))
self.label_2.setText(_translate("MainWindow", "output spectrogram"))
self.zoomOut.setText(_translate("MainWindow", "zoom out"))
self.zoomIn.setText(_translate("MainWindow", "zoom in"))
self.file.setTitle(_translate("MainWindow", "file"))
self.open.setText(_translate("MainWindow", "open"))
self.save.setText(_translate("MainWindow", "save"))