def _construct_UI(self, **kwargs): """ Construct widget """ dict_ui = {'label_q':'Quant.', 'tip_q':'Select the kind of quantization.', 'cmb_q':['round', 'fix', 'floor'], 'cur_q':'round', 'label_ov':'Ovfl.', 'tip_ov':'Select overflow behaviour.', 'cmb_ov':['wrap', 'sat'], 'cur_ov':'wrap', 'enabled':True, 'visible':True } for key, val in kwargs.items(): dict_ui.update({key:val}) # dict_ui.update(map(kwargs)) # same as above? lblQuant = QLabel(dict_ui['label_q'], self) self.cmbQuant = QComboBox(self) self.cmbQuant.addItems(dict_ui['cmb_q']) qset_cmb_box(self.cmbQuant, dict_ui['cur_q']) self.cmbQuant.setToolTip(dict_ui['tip_q']) lblOvfl = QLabel(dict_ui['label_ov'], self) self.cmbOvfl = QComboBox(self) self.cmbOvfl.addItems(dict_ui['cmb_ov']) qset_cmb_box(self.cmbOvfl, dict_ui['cur_ov']) self.cmbOvfl.setToolTip(dict_ui['tip_ov']) # ComboBox size is adjusted automatically to fit the longest element self.cmbQuant.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.cmbOvfl.setSizeAdjustPolicy(QComboBox.AdjustToContents) layH = QHBoxLayout() layH.addWidget(lblOvfl) layH.addWidget(self.cmbOvfl) layH.addStretch() layH.addWidget(lblQuant) layH.addWidget(self.cmbQuant) layH.setContentsMargins(0,0,0,0) frmMain = QFrame(self) frmMain.setLayout(layH) layVMain = QVBoxLayout() # Widget main layout layVMain.addWidget(frmMain) layVMain.setContentsMargins(5,0,0,0)#*params['wdg_margins']) self.setLayout(layVMain) #---------------------------------------------------------------------- # INITIAL SETTINGS #---------------------------------------------------------------------- self.ovfl = qget_cmb_box(self.cmbOvfl, data=False) self.quant = qget_cmb_box(self.cmbQuant, data=False) frmMain.setEnabled(dict_ui['enabled']) frmMain.setVisible(dict_ui['visible']) #---------------------------------------------------------------------- # LOCAL SIGNALS & SLOTs #---------------------------------------------------------------------- self.cmbOvfl.currentIndexChanged.connect(self.save_ui) self.cmbQuant.currentIndexChanged.connect(self.save_ui)
def load_ui(self): """ Update UI from filter dict """ self.ovfl = fb.fil[0]['q_coeff']['ovfl'] self.quant = fb.fil[0]['q_coeff']['quant'] qset_cmb_box(self.cmbOvfl, self.ovfl) qset_cmb_box(self.cmbQuant, self.quant) self.c_dict = build_coeff_dict()
def fx_set_results(self, dict_sig): """ Get simulation results from `dict_sig` and transfer them to plotting routine. """ self.calc_response(dict_sig['fx_results']) qset_cmb_box(self.ui.cmb_sim_select, "Fixpoint", fireSignals=True) self.calc_fft() self.draw_impz()
def test_but_clear(self): """Test <Clear Table> Button""" qset_cmb_box(self.form.cmbFilterType, 'IIR', fireSignals=True) item_10 = self.form.tblCoeff.item(1, 0) # row, col self.assertEqual(item_10.text(), "1") # Push <Delete Table> Button with the left mouse button QtTest.QTest.mouseClick(self.form.butClear, Qt.LeftButton) # self.assertEqual(self.form.jiggers, 36.0) self.assertEqual(self.form.tblCoeff.item(1, 0).text(), "0") self.assertEqual(self.form.tblCoeff.rowCount(), 2) self.assertEqual(self.form.tblCoeff.columnCount(), 2)
def test_but_clear(self): """Test <Clear Table> Button""" qset_cmb_box(self.form.cmbFilterType, 'IIR', fireSignals=True) item_10 = self.form.tblCoeff.item(1,0) # row, col self.assertEqual(item_10.text(), "1") # Push <Delete Table> Button with the left mouse button QtTest.QTest.mouseClick(self.form.butClear, Qt.LeftButton) # self.assertEqual(self.form.jiggers, 36.0) self.assertEqual(self.form.tblCoeff.item(1,0).text(), "0") self.assertEqual(self.form.tblCoeff.rowCount(), 2) self.assertEqual(self.form.tblCoeff.columnCount(), 2)
def _filter_type(self, ftype=None): """ Get / set 'FIR' and 'IIR' filter from cmbFilterType combobox and set filter dict and table properties accordingly. When argument fil_type is not None, set the combobox accordingly. Reload from filter dict unless ftype is specified [does this make sense?!] """ if ftype in {'FIR', 'IIR'}: ret=qset_cmb_box(self.ui.cmbFilterType, ftype) if ret == -1: logger.warning("Unknown filter type {0}".format(ftype)) if self.ui.cmbFilterType.currentText() == 'IIR': fb.fil[0]['ft'] = 'IIR' self.col = 2 self.tblCoeff.setColumnCount(2) self.tblCoeff.setHorizontalHeaderLabels(["b", "a"]) else: fb.fil[0]['ft'] = 'FIR' self.col = 1 self.tblCoeff.setColumnCount(1) self.tblCoeff.setHorizontalHeaderLabels(["b"]) if not ftype: self._refresh_table()
def set_cmb_box(self, cmb_wdg, arg): """ Set combobox `name` to item `arg`. Throw an error if the item doesn't exist in the combobox list. """ if not cmb_wdg.isVisible(): self.fail("Widget is not visible.") elif not cmb_wdg.isEnabled(): self.fail("Widget is not enabled.") else: cmb_wdg.setCurrentIndex(-1) # insure that cmbbox always fires an index changed signal ret = qset_cmb_box(cmb_wdg, arg, fireSignals=True) self.assertIsNot(ret, -1) # assert that arg exists in combo box
def _filter_type(self, fil_type=None): """ Get / set 'FIR' and 'IIR' filter from cmbFilterType combobox and set filter dict and table properties accordingly. """ if self.cmbFilterType.currentText() == 'IIR': fb.fil[0]['ft'] = 'IIR' self.col = 2 qset_cmb_box(self.cmbFilterType, 'IIR') self.tblCoeff.setColumnCount(2) self.tblCoeff.setHorizontalHeaderLabels(["b", "a"]) else: fb.fil[0]['ft'] = 'FIR' self.col = 1 qset_cmb_box(self.cmbFilterType, 'FIR') self.tblCoeff.setColumnCount(1) self.tblCoeff.setHorizontalHeaderLabels(["b"]) self.tblCoeff.setColumnCount(self.col) self.load_dict()
def _load_q_settings(self): """ load the quantization settings from the filter dict and set the widgets accordingly. Update the fixpoint object. """ self.myQ.setQobj(fb.fil[0]['q_coeff']) q_coeff = self.myQ.q_obj self.ui.ledWI.setText(str(q_coeff['WI'])) self.ui.ledWF.setText(str(q_coeff['WF'])) qset_cmb_box(self.ui.cmbQuant, q_coeff['quant']) qset_cmb_box(self.ui.cmbQOvfl, q_coeff['ovfl']) qset_cmb_box(self.ui.cmbFormat, q_coeff['frmt']) self.ui.ledScale.setText(str(q_coeff['scale'])) self.ui.ledW.setText(str(self.myQ.W)) self.ui.lblLSB.setText("{0:.{1}g}".format(self.myQ.LSB, params['FMT_ba'])) self.ui.lblMSB.setText("{0:.{1}g}".format(self.myQ.MSB, params['FMT_ba'])) self.ui.lblMAX.setText("{0}".format(self.myQ.float2frmt(self.myQ.MAX/self.myQ.scale)))
def _load_q_settings(self): """ load the quantization settings from the filter dict and set the widgets accordingly. Update the fixpoint object. """ self.myQ.setQobj(fb.fil[0]['q_coeff']) q_coeff = self.myQ.q_obj self.ui.ledWI.setText(str(q_coeff['WI'])) self.ui.ledWF.setText(str(q_coeff['WF'])) qset_cmb_box(self.ui.cmbQuant, q_coeff['quant']) qset_cmb_box(self.ui.cmbQOvfl, q_coeff['ovfl']) qset_cmb_box(self.ui.cmbFormat, q_coeff['frmt']) self.ui.ledScale.setText(str(q_coeff['scale'])) self.ui.ledW.setText(str(self.myQ.W)) self.ui.lblLSB.setText("{0:.{1}g}".format(self.myQ.LSB, params['FMT_ba'])) self.ui.lblMSB.setText("{0:.{1}g}".format(self.myQ.MSB, params['FMT_ba'])) self.ui.lblMAX.setText("{0}".format(self.myQ.float2frmt(self.myQ.MAX, scaling='none')))
def _load_q_settings(self): """ load the quantization settings from the filter dict and set the widgets accordingly. Update the fixpoint object. """ q_coeff = fb.fil[0]['q_coeff'] self.ledWI.setText(str(q_coeff['WI'])) self.ledWF.setText(str(q_coeff['WF'])) qset_cmb_box(self.cmbQQuant, q_coeff['quant']) qset_cmb_box(self.cmbQOvfl, q_coeff['ovfl']) qset_cmb_box(self.cmbFormat, q_coeff['frmt']) self.chkRadixPoint.setChecked(q_coeff['point']) self.lblLSB.setText("{0:.{1}g}".format(self.myQ.LSB, params['FMT_ba'])) self.lblMSB.setText("{0:.{1}g}".format(self.myQ.MSB, params['FMT_ba'])) self.scale = safe_eval(self.ledScale.text(), self.myQ.scale) self.ledScale.setText(str(self.scale)) self.myQ.setQobj(fb.fil[0]['q_coeff'])
def qdict2ui(self): """ Set the UI from the quantization dict and update the fixpoint object. When neither WI == 0 nor WF == 0, set the quantization format to general fractional format qfrac. """ self.ui.ledWI.setText(qstr(fb.fil[0]['fxqc']['QCB']['WI'])) self.ui.ledWF.setText(qstr(fb.fil[0]['fxqc']['QCB']['WF'])) self.ui.ledW.setText(qstr(fb.fil[0]['fxqc']['QCB']['W'])) if fb.fil[0]['fxqc']['QCB']['WI'] != 0 and fb.fil[0]['fxqc']['QCB'][ 'WF'] != 0: qset_cmb_box(self.ui.cmbQFrmt, 'qfrac', data=True) self.ui.ledScale.setText(qstr(fb.fil[0]['fxqc']['QCB']['scale'])) qset_cmb_box(self.ui.cmbQuant, fb.fil[0]['fxqc']['QCB']['quant']) qset_cmb_box(self.ui.cmbQOvfl, fb.fil[0]['fxqc']['QCB']['ovfl']) self.myQ.setQobj(fb.fil[0]['fxqc']['QCB']) # update class attributes self._set_number_format( ) # quant format has been changed, update display self._update_MSB_LSB()
def _construct_UI(self): self.lblN_points = QLabel(to_html("N", frmt='bi') + " =", self) self.ledN_points = QLineEdit(self) self.ledN_points.setText(str(self.N_points)) self.ledN_points.setToolTip( "<span>Number of points to calculate and display. " "N = 0 tries to choose for you.</span>") self.lblN_start = QLabel(to_html("N_0", frmt='bi') + " =", self) self.ledN_start = QLineEdit(self) self.ledN_start.setText(str(self.N_start)) self.ledN_start.setToolTip("<span>First point to plot.</span>") layVlblN = QVBoxLayout() layVlblN.addWidget(self.lblN_start) layVlblN.addWidget(self.lblN_points) layVledN = QVBoxLayout() layVledN.addWidget(self.ledN_start) layVledN.addWidget(self.ledN_points) self.chkLog = QCheckBox("Log. y-axis", self) self.chkLog.setObjectName("chkLog") self.chkLog.setToolTip("<span>Logarithmic scale for y-axis.</span>") self.chkLog.setChecked(False) self.chkMarker = QCheckBox("Markers", self) self.chkMarker.setObjectName("chkMarker") self.chkMarker.setToolTip("<span>Show plot markers.</span>") self.chkMarker.setChecked(True) layVchkLogMark = QVBoxLayout() layVchkLogMark.addWidget(self.chkLog) layVchkLogMark.addWidget(self.chkMarker) self.lblLogBottom = QLabel("Bottom = ", self) self.ledLogBottom = QLineEdit(self) self.ledLogBottom.setText(str(self.bottom)) self.ledLogBottom.setToolTip( "<span>Minimum display value for log. scale.</span>") self.lbldB = QLabel("dB", self) self.lblPltTime = QLabel("Time: ", self) self.cmbPltTime = QComboBox(self) self.cmbPltTime.addItems(["None", "Stimulus", "Response", "Both"]) qset_cmb_box(self.cmbPltTime, self.plt_time) self.cmbPltTime.setToolTip( "<span>Choose which signals to show in the time domain: " "The stimulus, the filter response or both.</span>") self.lblPltFreq = QLabel("Freq.: ", self) self.cmbPltFreq = QComboBox(self) self.cmbPltFreq.addItems(["None", "Stimulus", "Response", "Both"]) qset_cmb_box(self.cmbPltFreq, self.plt_freq) self.cmbPltFreq.setToolTip( "<span>Choose which signals to show in the frequency domain: " "The stimulus, the filter response or both.</span>") layVlblPlt = QVBoxLayout() layVlblPlt.addWidget(self.lblPltTime) layVlblPlt.addWidget(self.lblPltFreq) layVcmbPlt = QVBoxLayout() layVcmbPlt.addWidget(self.cmbPltTime) layVcmbPlt.addWidget(self.cmbPltFreq) self.lblStimulus = QLabel("Stimulus: ", self) self.cmbStimulus = QComboBox(self) self.cmbStimulus.addItems( ["Pulse", "Step", "StepErr", "Cos", "Sine", "Rect", "Saw"]) self.cmbStimulus.setToolTip("Select stimulus type.") qset_cmb_box(self.cmbStimulus, self.stim) self.lblNoise = QLabel("Noise: ", self) self.cmbNoise = QComboBox(self) self.cmbNoise.addItems(["None", "Gauss", "Uniform"]) self.cmbNoise.setToolTip("Select added noise type.") qset_cmb_box(self.cmbNoise, self.noise) layVlblCmb = QVBoxLayout() layVlblCmb.addWidget(self.lblStimulus) layVlblCmb.addWidget(self.lblNoise) layVCmb = QVBoxLayout() layVCmb.addWidget(self.cmbStimulus) layVCmb.addWidget(self.cmbNoise) self.lblAmp1 = QLabel(to_html("A_1", frmt='bi') + " =", self) self.ledAmp1 = QLineEdit(self) self.ledAmp1.setText(str(self.A1)) self.ledAmp1.setToolTip("Stimulus amplitude.") self.ledAmp1.setObjectName("stimAmp1") self.lblAmp2 = QLabel(to_html("A_2", frmt='bi') + " =", self) self.ledAmp2 = QLineEdit(self) self.ledAmp2.setText(str(self.A2)) self.ledAmp2.setToolTip("Stimulus amplitude 2.") self.ledAmp2.setObjectName("stimAmp2") layVlblAmp = QVBoxLayout() layVlblAmp.addWidget(self.lblAmp1) layVlblAmp.addWidget(self.lblAmp2) layVledAmp = QVBoxLayout() layVledAmp.addWidget(self.ledAmp1) layVledAmp.addWidget(self.ledAmp2) self.lblFreq1 = QLabel(to_html("f_1", frmt='bi') + " =", self) self.ledFreq1 = QLineEdit(self) self.ledFreq1.setText(str(self.f1)) self.ledFreq1.setToolTip("Stimulus frequency 1.") self.ledFreq1.setObjectName("stimFreq1") self.lblFreqUnit1 = QLabel("f_S", self) self.lblFreq2 = QLabel(to_html("f_2", frmt='bi') + " =", self) self.ledFreq2 = QLineEdit(self) self.ledFreq2.setText(str(self.f2)) self.ledFreq2.setToolTip("Stimulus frequency 2.") self.ledFreq2.setObjectName("stimFreq2") self.lblFreqUnit2 = QLabel("f_S", self) layVlblfreq = QVBoxLayout() layVlblfreq.addWidget(self.lblFreq1) layVlblfreq.addWidget(self.lblFreq2) layVledfreq = QVBoxLayout() layVledfreq.addWidget(self.ledFreq1) layVledfreq.addWidget(self.ledFreq2) layVlblfreqU = QVBoxLayout() layVlblfreqU.addWidget(self.lblFreqUnit1) layVlblfreqU.addWidget(self.lblFreqUnit2) self.lblNoi = QLabel("not initialized", self) self.ledNoi = QLineEdit(self) self.ledNoi.setText(str(self.noi)) self.ledNoi.setToolTip("not initialized") self.ledNoi.setObjectName("stimNoi") self.lblDC = QLabel(to_html("DC =", frmt='bi'), self) self.ledDC = QLineEdit(self) self.ledDC.setText(str(self.DC)) self.ledDC.setToolTip("DC Level") self.ledDC.setObjectName("stimDC") layVlblNoiDC = QVBoxLayout() layVlblNoiDC.addWidget(self.lblNoi) layVlblNoiDC.addWidget(self.lblDC) layVledNoiDC = QVBoxLayout() layVledNoiDC.addWidget(self.ledNoi) layVledNoiDC.addWidget(self.ledDC) layHControls = QHBoxLayout() layHControls.addLayout(layVlblN) layHControls.addLayout(layVledN) layHControls.addStretch(2) layHControls.addLayout(layVchkLogMark) layHControls.addStretch(1) layHControls.addWidget(self.lblLogBottom) layHControls.addWidget(self.ledLogBottom) layHControls.addWidget(self.lbldB) layHControls.addStretch(2) layHControls.addLayout(layVlblPlt) layHControls.addLayout(layVcmbPlt) layHControls.addStretch(1) layHControls.addLayout(layVlblCmb) layHControls.addLayout(layVCmb) layHControls.addStretch(1) layHControls.addLayout(layVlblAmp) layHControls.addLayout(layVledAmp) layHControls.addLayout(layVlblfreq) layHControls.addLayout(layVledfreq) layHControls.addLayout(layVlblfreqU) layHControls.addStretch(1) layHControls.addLayout(layVlblNoiDC) layHControls.addLayout(layVledNoiDC) layHControls.addStretch(10) layHControlsF = QHBoxLayout() self.chkLogF = QCheckBox("Log. scale", self) self.chkLogF.setObjectName("chkLogF") self.chkLogF.setToolTip("<span>Logarithmic scale for y-axis.</span>") self.chkLogF.setChecked(True) self.lblLogBottomF = QLabel("Bottom = ", self) self.ledLogBottomF = QLineEdit(self) self.ledLogBottomF.setText(str(self.bottom_f)) self.ledLogBottomF.setToolTip( "<span>Minimum display value for log. scale.</span>") self.lbldBF = QLabel("dB", self) self.lblWindow = QLabel("Window: ", self) self.cmbWindow = QComboBox(self) self.cmbWindow.addItems([ "Rect", "Triangular", "Hann", "Hamming", "Kaiser", "Flattop", "Chebwin" ]) self.cmbWindow.setToolTip("Select window type.") qset_cmb_box(self.cmbWindow, self.window) self.lblWinPar1 = QLabel("Param1") self.ledWinPar1 = QLineEdit(self) self.ledWinPar1.setText("1") self.ledWinPar1.setObjectName("ledWinPar1") layHControlsF.addWidget(self.chkLogF) layHControlsF.addWidget(self.lblLogBottomF) layHControlsF.addWidget(self.ledLogBottomF) layHControlsF.addWidget(self.lbldBF) layHControls.addStretch(2) layHControlsF.addWidget(self.lblWindow) layHControlsF.addWidget(self.cmbWindow) layHControlsF.addWidget(self.lblWinPar1) layHControlsF.addWidget(self.ledWinPar1) layHControlsF.addStretch(10) self.wdgHControlsF = QWidget(self) self.wdgHControlsF.setLayout(layHControlsF) #---------------------------------------------------------------------- # GLOBAL SIGNALS & SLOTs #---------------------------------------------------------------------- self.sig_rx.connect(self.process_signals) #---------------------------------------------------------------------- # LOCAL SIGNALS & SLOTs #---------------------------------------------------------------------- self.ledN_start.editingFinished.connect(self.update_N) self.ledN_points.editingFinished.connect(self.update_N) self.chkLog.clicked.connect(self._log_mode) self.ledLogBottom.editingFinished.connect(self._log_mode) self.cmbPltTime.currentIndexChanged.connect(self._update_time_freq) self.cmbPltFreq.currentIndexChanged.connect(self._update_time_freq) self.chkMarker.clicked.connect(self._update_chk_boxes) self.cmbStimulus.currentIndexChanged.connect(self._enable_stim_widgets) self.cmbNoise.currentIndexChanged.connect(self._update_noi) self.ledNoi.editingFinished.connect(self._update_noi) self.ledAmp1.editingFinished.connect(self._update_amp1) self.ledAmp2.editingFinished.connect(self._update_amp2) self.ledDC.editingFinished.connect(self._update_DC) self.chkLogF.clicked.connect(self._log_mode) self.ledLogBottomF.editingFinished.connect(self._log_mode) # careful! currentIndexChanged passes the current index to _update_window self.cmbWindow.currentIndexChanged.connect(self._update_window) self.ledWinPar1.editingFinished.connect(self._update_window) # ######################## Main UI Layout ############################ # layout for frame (UI widget) layVMainF = QVBoxLayout() layVMainF.addLayout(layHControls) layVMainF.addWidget(self.wdgHControlsF) # This frame encompasses all UI elements self.frmControls = QFrame(self) self.frmControls.setLayout(layVMainF) layVMain = QVBoxLayout() layVMain.addWidget(self.frmControls) layVMain.setContentsMargins(*params['wdg_margins']) self.setLayout(layVMain)
def _refresh_table(self): """ (Re-)Create the displayed table from `self.ba` (list with 2 columns of float scalars). Data is displayed via `ItemDelegate.displayText()` in the number format set by `self.frmt`. The table dimensions are set according to the dimensions of `self.ba`: - self.ba[0] -> b coefficients - self.ba[1] -> a coefficients Called at the end of nearly every method. """ try: self.num_rows = max(len(self.ba[1]), len(self.ba[0])) except IndexError: self.num_rows = len(self.ba[0]) logger.debug("np.shape(ba) = {0}".format(np.shape(self.ba))) params['FMT_ba'] = int(self.ui.spnDigits.text()) # When format is 'float', disable all fixpoint options is_float = (qget_cmb_box(self.ui.cmbFormat, data=False).lower() == 'float') self.ui.spnDigits.setVisible(is_float) # number of digits can only be selected self.ui.lblDigits.setVisible(is_float) # for format = 'float' self.ui.cmbQFrmt.setVisible(not is_float) # hide unneeded widgets for format = 'float' self.ui.lbl_W.setVisible(not is_float) self.ui.ledW.setVisible(not is_float) if self.ui.butEnable.isChecked(): self.ui.frmQSettings.setVisible(not is_float) # hide all q-settings for float self.ui.butEnable.setIcon(QIcon(':/circle-x.svg')) self.tblCoeff.setVisible(True) self._store_q_settings() # store updated quantization / format settings # check whether filter is FIR and only needs one column if fb.fil[0]['ft'] == 'FIR': self.num_cols = 1 self.tblCoeff.setColumnCount(1) self.tblCoeff.setHorizontalHeaderLabels(["b"]) qset_cmb_box(self.ui.cmbFilterType, 'FIR') else: self.num_cols = 2 self.tblCoeff.setColumnCount(2) self.tblCoeff.setHorizontalHeaderLabels(["b", "a"]) qset_cmb_box(self.ui.cmbFilterType, 'IIR') self.ba[1][0] = 1.0 # restore fa[0] = 1 of denonimator polynome self.tblCoeff.setRowCount(self.num_rows) self.tblCoeff.setColumnCount(self.num_cols) # Create strings for index column (vertical header), starting with "0" idx_str = [str(n) for n in range(self.num_rows)] self.tblCoeff.setVerticalHeaderLabels(idx_str) self.tblCoeff.blockSignals(True) for col in range(self.num_cols): for row in range(self.num_rows): self._refresh_table_item(row, col) # make a[0] selectable but not editable if fb.fil[0]['ft'] == 'IIR': item = self.tblCoeff.item(0,1) item.setFlags(Qt.ItemIsSelectable| Qt.ItemIsEnabled) item.setFont(self.ui.bfont) self.tblCoeff.blockSignals(False) self.tblCoeff.resizeColumnsToContents() self.tblCoeff.resizeRowsToContents() self.tblCoeff.clearSelection() else: self.ui.frmQSettings.setVisible(False) self.ui.butEnable.setIcon(QIcon(':/circle-check.svg')) self.tblCoeff.setVisible(False)
def _refresh_table(self): """ (Re-)Create the displayed table from self.ba with the desired number format. Called at the end of nearly every method. """ self.num_rows = max(len(self.ba[1]), len(self.ba[0])) params['FMT_ba'] = int(self.spnRound.text()) # When format is 'float', disable all fixpoint options is_float = (qget_cmb_box(self.cmbFormat, data=False).lower() == 'float') self.spnRound.setVisible( is_float) # number of digits can only be selected self.lblRound.setVisible(is_float) # for format = 'float' self.ledScale.setEnabled(True) self.chkRadixPoint.setVisible(not is_float) if self.butEnable.isChecked(): self.frmQSettings.setVisible( not is_float) # hide all q-settings for float self.butEnable.setIcon(QIcon(':/circle-check.svg')) self.tblCoeff.setVisible(True) self._store_q_settings( ) # store updated quantization / format settings # check whether filter is FIR and only needs one column if fb.fil[0]['ft'] == 'FIR': self.num_cols = 1 self.tblCoeff.setColumnCount(1) self.tblCoeff.setHorizontalHeaderLabels(["b"]) qset_cmb_box(self.cmbFilterType, 'FIR') else: self.num_cols = 2 self.tblCoeff.setColumnCount(2) self.tblCoeff.setHorizontalHeaderLabels(["b", "a"]) qset_cmb_box(self.cmbFilterType, 'IIR') self.ba[1][ 0] = 1.0 # restore fa[0] = 1 of denonimator polynome self.tblCoeff.setRowCount(self.num_rows) self.tblCoeff.setColumnCount(self.num_cols) # Create strings for index column (vertical header), starting with "0" idx_str = [str(n) for n in range(self.num_rows)] self.tblCoeff.setVerticalHeaderLabels(idx_str) self.tblCoeff.blockSignals(True) for col in range(self.num_cols): for row in range(self.num_rows): # set table item from self.ba and strip '()' of complex numbers item = self.tblCoeff.item(row, col) if item: # does item exist? item.setText(str(self.ba[col][row]).strip('()')) else: # no, construct it: self.tblCoeff.setItem( row, col, QTableWidgetItem( str(self.ba[col][row]).strip('()'))) self.tblCoeff.item(row, col).setTextAlignment(Qt.AlignRight | Qt.AlignCenter) # make a[0] unselectable if fb.fil[0]['ft'] == 'IIR': item = self.tblCoeff.item(0, 1) item.setFlags(Qt.ItemIsSelectable) #| Qt.ItemIsEnabled ) item.setFont(self.bfont) self.tblCoeff.blockSignals(False) self.tblCoeff.resizeColumnsToContents() self.tblCoeff.resizeRowsToContents() self.tblCoeff.clearSelection() else: self.frmQSettings.setVisible(False) self.butEnable.setIcon(QIcon(':/circle-x.svg')) self.tblCoeff.setVisible(False)
def _construct_UI(self): # ----------- --------------------------------------------------- # Run control widgets # --------------------------------------------------------------- self.lbl_sim_select = QLabel("<b>Simulate</b>", self) self.cmb_sim_select = QComboBox(self) self.cmb_sim_select.addItems(["Float","Fixpoint"]) qset_cmb_box(self.cmb_sim_select, "Float") self.cmb_sim_select.setToolTip("<span>Simulate floating-point or fixpoint response." "</span>") self.lbl_N_points = QLabel(to_html("N", frmt='bi') + " =", self) self.led_N_points = QLineEdit(self) self.led_N_points.setText(str(self.N_points)) self.led_N_points.setToolTip("<span>Number of points to calculate and display. " "N = 0 tries to choose for you.</span>") self.lbl_N_start = QLabel(to_html("N_0", frmt='bi') + " =", self) self.led_N_start = QLineEdit(self) self.led_N_start.setText(str(self.N_start)) self.led_N_start.setToolTip("<span>First point to plot.</span>") self.but_run = QPushButton("RUN", self) self.but_run.setToolTip("Run fixpoint simulation") self.chk_fx_scale = QCheckBox("Integer scale", self) self.chk_fx_scale.setObjectName("chk_fx_scale") self.chk_fx_scale.setToolTip("<span>Display data with integer (fixpoint) scale.</span>") self.chk_fx_scale.setChecked(False) self.chk_stim_options = QCheckBox("Stimulus Options", self) self.chk_stim_options.setObjectName("chk_stim_options") self.chk_stim_options.setToolTip("<span>Show options for stimulus signal.</span>") self.chk_stim_options.setChecked(True) layH_ctrl_run = QHBoxLayout() layH_ctrl_run.addWidget(self.lbl_sim_select) layH_ctrl_run.addWidget(self.cmb_sim_select) layH_ctrl_run.addStretch(1) layH_ctrl_run.addWidget(self.lbl_N_start) layH_ctrl_run.addWidget(self.led_N_start) layH_ctrl_run.addStretch(1) layH_ctrl_run.addWidget(self.lbl_N_points) layH_ctrl_run.addWidget(self.led_N_points) layH_ctrl_run.addStretch(1) layH_ctrl_run.addWidget(self.but_run) layH_ctrl_run.addStretch(2) layH_ctrl_run.addWidget(self.chk_fx_scale) layH_ctrl_run.addStretch(2) layH_ctrl_run.addWidget(self.chk_stim_options) layH_ctrl_run.addStretch(10) #layH_ctrl_run.setContentsMargins(*params['wdg_margins']) self.wdg_ctrl_run = QWidget(self) self.wdg_ctrl_run.setLayout(layH_ctrl_run) # --- end of run control ---------------------------------------- # ----------- --------------------------------------------------- # Controls for time domain # --------------------------------------------------------------- lbl_plt_time_title = QLabel("<b>Time: Show</b>", self) self.lbl_plt_time_stim = QLabel("Stimulus", self) self.cmb_plt_time_stim = QComboBox(self) self.cmb_plt_time_stim.addItems(["None","Dots","Line","Stem", "Step"]) qset_cmb_box(self.cmb_plt_time_stim, self.plt_time_stim) self.cmb_plt_time_stim.setToolTip("<span>Choose stimulus plot style.</span>") self.chk_mrk_time_stim = QCheckBox("*", self) self.chk_mrk_time_stim.setChecked(False) self.chk_mrk_time_stim.setToolTip("Use plot markers") self.lbl_plt_time_resp = QLabel("Response", self) self.cmb_plt_time_resp = QComboBox(self) self.cmb_plt_time_resp.addItems(["None","Dots","Line","Stem", "Step"]) qset_cmb_box(self.cmb_plt_time_resp, self.plt_time_resp) self.cmb_plt_time_resp.setToolTip("<span>Choose response plot style.</span>") self.chk_mrk_time_resp = QCheckBox("*", self) self.chk_mrk_time_resp.setChecked(False) self.chk_mrk_time_resp.setToolTip("Use plot markers") self.chk_log_time = QCheckBox("dB", self) self.chk_log_time.setObjectName("chk_log_time") self.chk_log_time.setToolTip("<span>Logarithmic scale for y-axis.</span>") self.chk_log_time.setChecked(False) self.lbl_log_bottom_time = QLabel("Bottom = ", self) self.led_log_bottom_time = QLineEdit(self) self.led_log_bottom_time.setText(str(self.bottom_t)) self.led_log_bottom_time.setToolTip("<span>Minimum display value for log. scale.</span>") self.lbl_dB_time = QLabel("dB", self) self.chk_win_time = QCheckBox("FFT Window", self) self.chk_win_time.setObjectName("chk_win_time") self.chk_win_time.setToolTip("<span>Show FFT windowing function.</span>") self.chk_win_time.setChecked(False) self.chk_fx_range = QCheckBox("Min/max.", self) self.chk_fx_range.setObjectName("chk_fx_range") self.chk_fx_range.setToolTip("<span>Display limits of fixpoint range.</span>") self.chk_fx_range.setChecked(False) layH_ctrl_time = QHBoxLayout() layH_ctrl_time.addWidget(lbl_plt_time_title) layH_ctrl_time.addStretch(1) layH_ctrl_time.addWidget(self.cmb_plt_time_resp) layH_ctrl_time.addWidget(self.chk_mrk_time_resp) layH_ctrl_time.addStretch(1) layH_ctrl_time.addWidget(self.lbl_plt_time_stim) layH_ctrl_time.addWidget(self.cmb_plt_time_stim) layH_ctrl_time.addWidget(self.chk_mrk_time_stim) layH_ctrl_time.addStretch(2) layH_ctrl_time.addWidget(self.chk_log_time) layH_ctrl_time.addStretch(1) layH_ctrl_time.addWidget(self.lbl_log_bottom_time) layH_ctrl_time.addWidget(self.led_log_bottom_time) layH_ctrl_time.addWidget(self.lbl_dB_time) layH_ctrl_time.addStretch(1) layH_ctrl_time.addWidget(self.chk_win_time) layH_ctrl_time.addStretch(2) layH_ctrl_time.addWidget(self.chk_fx_range) layH_ctrl_time.addStretch(10) #layH_ctrl_time.setContentsMargins(*params['wdg_margins']) self.wdg_ctrl_time = QWidget(self) self.wdg_ctrl_time.setLayout(layH_ctrl_time) # ---- end time domain ------------------ # --------------------------------------------------------------- # Controls for frequency domain # --------------------------------------------------------------- lbl_plt_freq_title = QLabel("<b>Freq: Show</b>", self) self.lbl_plt_freq_stim = QLabel("Stimulus", self) self.cmb_plt_freq_stim = QComboBox(self) self.cmb_plt_freq_stim.addItems(["None","Dots","Line","Stem", "Step"]) qset_cmb_box(self.cmb_plt_freq_stim, self.plt_freq_stim) self.cmb_plt_freq_stim.setToolTip("<span>Choose stimulus plot style.</span>") self.chk_mrk_freq_stim = QCheckBox("*", self) self.chk_mrk_freq_stim.setChecked(False) self.chk_mrk_freq_stim.setToolTip("Use plot markers") self.lbl_plt_freq_resp = QLabel("Response", self) self.cmb_plt_freq_resp = QComboBox(self) self.cmb_plt_freq_resp.addItems(["None","Dots","Line","Stem", "Step"]) qset_cmb_box(self.cmb_plt_freq_resp, self.plt_freq_resp) self.cmb_plt_freq_resp.setToolTip("<span>Choose response plot style.</span>") self.chk_mrk_freq_resp = QCheckBox("*", self) self.chk_mrk_freq_resp.setChecked(False) self.chk_mrk_freq_resp.setToolTip("Use plot markers") self.chk_log_freq = QCheckBox("dB", self) self.chk_log_freq.setObjectName("chk_log_freq") self.chk_log_freq.setToolTip("<span>Logarithmic scale for y-axis.</span>") self.chk_log_freq.setChecked(True) self.lbl_log_bottom_freq = QLabel("Bottom = ", self) self.led_log_bottom_freq = QLineEdit(self) self.led_log_bottom_freq.setText(str(self.bottom_f)) self.led_log_bottom_freq.setToolTip("<span>Minimum display value for log. scale.</span>") self.lbl_dB_freq = QLabel("dB", self) self.lbl_win_fft = QLabel("Window: ", self) self.cmb_win_fft = QComboBox(self) self.cmb_win_fft.addItems(["Rect","Triangular","Hann","Hamming","Kaiser", "Flattop", "Chebwin"]) self.cmb_win_fft.setToolTip("Select window type.") qset_cmb_box(self.cmb_win_fft, self.window) self.lblWinPar1 = QLabel("Param1") self.ledWinPar1 = QLineEdit(self) self.ledWinPar1.setText("1") self.ledWinPar1.setObjectName("ledWinPar1") self.chk_win_freq = QCheckBox("Show", self) self.chk_win_freq.setObjectName("chk_win_freq") self.chk_win_freq.setToolTip("<span>Show FFT windowing function.</span>") self.chk_win_freq.setChecked(False) layH_ctrl_freq = QHBoxLayout() layH_ctrl_freq.addWidget(lbl_plt_freq_title) layH_ctrl_freq.addStretch(1) layH_ctrl_freq.addWidget(self.lbl_plt_freq_resp) layH_ctrl_freq.addWidget(self.cmb_plt_freq_resp) layH_ctrl_freq.addWidget(self.chk_mrk_freq_resp) layH_ctrl_freq.addStretch(1) layH_ctrl_freq.addWidget(self.lbl_plt_freq_stim) layH_ctrl_freq.addWidget(self.cmb_plt_freq_stim) layH_ctrl_freq.addWidget(self.chk_mrk_freq_stim) layH_ctrl_freq.addWidget(self.chk_log_freq) layH_ctrl_freq.addWidget(self.led_log_bottom_freq) layH_ctrl_freq.addWidget(self.lbl_dB_freq) layH_ctrl_freq.addStretch(2) layH_ctrl_freq.addWidget(self.lbl_win_fft) layH_ctrl_freq.addWidget(self.cmb_win_fft) layH_ctrl_freq.addWidget(self.lblWinPar1) layH_ctrl_freq.addWidget(self.ledWinPar1) layH_ctrl_freq.addWidget(self.chk_win_freq) layH_ctrl_freq.addStretch(10) #layH_ctrl_freq.setContentsMargins(*params['wdg_margins']) self.wdg_ctrl_freq = QWidget(self) self.wdg_ctrl_freq.setLayout(layH_ctrl_freq) # ---- end Frequency Domain ------------------ # --------------------------------------------------------------- # Controls for stimuli # --------------------------------------------------------------- lbl_title_stim = QLabel("<b>Stimulus:</b>", self) self.lblStimulus = QLabel("Signal: ", self) self.cmbStimulus = QComboBox(self) self.cmbStimulus.addItems(["None","Pulse","Step","StepErr","Cos","Sine","Rect","Saw"]) self.cmbStimulus.setToolTip("Select stimulus type.") qset_cmb_box(self.cmbStimulus, self.stim) self.lblNoise = QLabel("Noise: ", self) self.cmbNoise = QComboBox(self) self.cmbNoise.addItems(["None","Gauss","Uniform"]) self.cmbNoise.setToolTip("Select added noise type.") qset_cmb_box(self.cmbNoise, self.noise) layVlblCmb = QVBoxLayout() layVlblCmb.addWidget(self.lblStimulus) layVlblCmb.addWidget(self.lblNoise) layVCmb = QVBoxLayout() layVCmb.addWidget(self.cmbStimulus) layVCmb.addWidget(self.cmbNoise) self.lblAmp1 = QLabel(to_html("A_1", frmt='bi') + " =", self) self.ledAmp1 = QLineEdit(self) self.ledAmp1.setText(str(self.A1)) self.ledAmp1.setToolTip("Stimulus amplitude.") self.ledAmp1.setObjectName("stimAmp1") self.lblAmp2 = QLabel(to_html("A_2", frmt='bi') + " =", self) self.ledAmp2 = QLineEdit(self) self.ledAmp2.setText(str(self.A2)) self.ledAmp2.setToolTip("Stimulus amplitude 2.") self.ledAmp2.setObjectName("stimAmp2") layVlblAmp = QVBoxLayout() layVlblAmp.addWidget(self.lblAmp1) layVlblAmp.addWidget(self.lblAmp2) layVledAmp = QVBoxLayout() layVledAmp.addWidget(self.ledAmp1) layVledAmp.addWidget(self.ledAmp2) self.lblFreq1 = QLabel(to_html("f_1", frmt='bi') + " =", self) self.ledFreq1 = QLineEdit(self) self.ledFreq1.setText(str(self.f1)) self.ledFreq1.setToolTip("Stimulus frequency 1.") self.ledFreq1.setObjectName("stimFreq1") self.lblFreqUnit1 = QLabel("f_S", self) self.lblFreq2 = QLabel(to_html("f_2", frmt='bi') + " =", self) self.ledFreq2 = QLineEdit(self) self.ledFreq2.setText(str(self.f2)) self.ledFreq2.setToolTip("Stimulus frequency 2.") self.ledFreq2.setObjectName("stimFreq2") self.lblFreqUnit2 = QLabel("f_S", self) layVlblfreq = QVBoxLayout() layVlblfreq.addWidget(self.lblFreq1) layVlblfreq.addWidget(self.lblFreq2) layVledfreq = QVBoxLayout() layVledfreq.addWidget(self.ledFreq1) layVledfreq.addWidget(self.ledFreq2) layVlblfreqU = QVBoxLayout() layVlblfreqU.addWidget(self.lblFreqUnit1) layVlblfreqU.addWidget(self.lblFreqUnit2) self.lblNoi = QLabel("not initialized", self) self.ledNoi = QLineEdit(self) self.ledNoi.setText(str(self.noi)) self.ledNoi.setToolTip("not initialized") self.ledNoi.setObjectName("stimNoi") self.lblDC = QLabel(to_html("DC =", frmt='bi'), self) self.ledDC = QLineEdit(self) self.ledDC.setText(str(self.DC)) self.ledDC.setToolTip("DC Level") self.ledDC.setObjectName("stimDC") layVlblNoiDC = QVBoxLayout() layVlblNoiDC.addWidget(self.lblNoi) layVlblNoiDC.addWidget(self.lblDC) layVledNoiDC = QVBoxLayout() layVledNoiDC.addWidget(self.ledNoi) layVledNoiDC.addWidget(self.ledDC) layH_ctrl_stim = QHBoxLayout() layH_ctrl_stim.addWidget(lbl_title_stim) layH_ctrl_stim.addStretch(1) layH_ctrl_stim.addLayout(layVlblCmb) layH_ctrl_stim.addLayout(layVCmb) layH_ctrl_stim.addStretch(1) layH_ctrl_stim.addLayout(layVlblAmp) layH_ctrl_stim.addLayout(layVledAmp) layH_ctrl_stim.addLayout(layVlblfreq) layH_ctrl_stim.addLayout(layVledfreq) layH_ctrl_stim.addLayout(layVlblfreqU) layH_ctrl_stim.addStretch(1) layH_ctrl_stim.addLayout(layVlblNoiDC) layH_ctrl_stim.addLayout(layVledNoiDC) layH_ctrl_stim.addStretch(10) self.wdg_ctrl_stim = QWidget(self) self.wdg_ctrl_stim.setLayout(layH_ctrl_stim) # --------- end stimuli --------------------------------- #---------------------------------------------------------------------- # GLOBAL SIGNALS & SLOTs #---------------------------------------------------------------------- self.sig_rx.connect(self.process_sig_rx) #---------------------------------------------------------------------- # LOCAL SIGNALS & SLOTs #---------------------------------------------------------------------- # --- run control --- self.led_N_start.editingFinished.connect(self.update_N) self.led_N_points.editingFinished.connect(self.update_N) # --- frequency control --- #self.chkLogF.clicked.connect(self._log_mode_freq) #self.ledLogBottomF.editingFinished.connect(self._log_mode_freq) # careful! currentIndexChanged passes the current index to _update_win_fft self.cmb_win_fft.currentIndexChanged.connect(self._update_win_fft) self.ledWinPar1.editingFinished.connect(self._update_win_fft) # --- stimulus control --- self.cmbStimulus.currentIndexChanged.connect(self._enable_stim_widgets) self.cmbNoise.currentIndexChanged.connect(self._update_noi) self.ledNoi.editingFinished.connect(self._update_noi) self.ledAmp1.editingFinished.connect(self._update_amp1) self.ledAmp2.editingFinished.connect(self._update_amp2) self.ledDC.editingFinished.connect(self._update_DC)
def __init__(self, parent): super(FilterCoeffs_UI, self).__init__(parent) self.eps = 1.e-6 # initialize tolerance value """ Intitialize the widget, consisting of: - top chkbox row - coefficient table - two bottom rows with action buttons """ self.bfont = QFont() self.bfont.setBold(True) self.bifont = QFont() self.bifont.setBold(True) self.bifont.setItalic(True) # q_icon_size = QSize(20, 20) # optional, size is derived from butEnable ####################################################################### # frmMain # # This frame contains all the buttons ####################################################################### # --------------------------------------------- # layHDisplay # # UI Elements for controlling the display # --------------------------------------------- self.butEnable = QPushButton(self) self.butEnable.setIcon(QIcon(':/circle-x.svg')) q_icon_size = self.butEnable.iconSize() # <- uncomment this for manual sizing self.butEnable.setIconSize(q_icon_size) self.butEnable.setCheckable(True) self.butEnable.setChecked(True) self.butEnable.setToolTip("<span>Show / hide filter coefficients as an editable table." "For high order systems, table display might be slow.</span>") fix_formats = ['Dec', 'Hex', 'Bin', 'CSD'] self.cmbFormat = QComboBox(self) model = self.cmbFormat.model() item = QtGui.QStandardItem('Float') item.setData('child', Qt.AccessibleDescriptionRole) model.appendRow(item) item = QtGui.QStandardItem('Fixp.:') item.setData('parent', Qt.AccessibleDescriptionRole) item.setData(0, QtGui.QFont.Bold) item.setFlags(item.flags() & ~Qt.ItemIsEnabled)# | Qt.ItemIsSelectable)) model.appendRow(item) for idx in range(len(fix_formats)): item = QtGui.QStandardItem(fix_formats[idx]) # item.setForeground(QtGui.QColor('red')) model.appendRow(item) self.cmbFormat.insertSeparator(1) qset_cmb_box(self.cmbFormat, 'float') self.cmbFormat.setToolTip('Set the display format.') self.cmbFormat.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.spnDigits = QSpinBox(self) self.spnDigits.setRange(0,16) self.spnDigits.setValue(params['FMT_ba']) self.spnDigits.setToolTip("Number of digits to display.") self.lblDigits = QLabel("Digits", self) self.lblDigits.setFont(self.bifont) self.cmbQFrmt = QComboBox(self) q_formats = [('Integer', 'qint' ), ('Norm. Frac.', 'qnfrac'), ('Fractional', 'qfrac')] for q in q_formats: self.cmbQFrmt.addItem(*q) self.lbl_W = QLabel("W = ", self) self.lbl_W.setFont(self.bifont) self.ledW = QLineEdit(self) self.ledW.setToolTip("Specify total wordlength.") self.ledW.setText("16") self.ledW.setMaxLength(2) # maximum of 2 digits self.ledW.setFixedWidth(30) # width of lineedit in points(?) layHDisplay = QHBoxLayout() layHDisplay.setAlignment(Qt.AlignLeft) layHDisplay.addWidget(self.butEnable) layHDisplay.addWidget(self.cmbFormat) layHDisplay.addWidget(self.spnDigits) layHDisplay.addWidget(self.lblDigits) layHDisplay.addWidget(self.cmbQFrmt) layHDisplay.addWidget(self.lbl_W) layHDisplay.addWidget(self.ledW) layHDisplay.addStretch() # ----------------------------------------------------------------- # layHButtonsCoeffs1 # # UI Elements for loading / storing / manipulating cells and rows # ----------------------------------------------------------------- self.cmbFilterType = QComboBox(self) self.cmbFilterType.setObjectName("comboFilterType") self.cmbFilterType.setToolTip("<span>Select between IIR and FIR filter for manual entry." "Changing the type reloads the filter from the filter dict.</span>") self.cmbFilterType.addItems(["FIR","IIR"]) self.cmbFilterType.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.butAddCells = QPushButton(self) self.butAddCells.setIcon(QIcon(':/row_insert_above.svg')) self.butAddCells.setIconSize(q_icon_size) self.butAddCells.setToolTip("<SPAN>Select cells to insert a new cell above each selected cell. " "Use <SHIFT> or <CTRL> to select multiple cells. " "When nothing is selected, add a row at the end.</SPAN>") self.butDelCells = QPushButton(self) self.butDelCells.setIcon(QIcon(':/row_delete.svg')) self.butDelCells.setIconSize(q_icon_size) self.butDelCells.setToolTip("<SPAN>Delete selected cell(s) from the table. " "Use <SHIFT> or <CTRL> to select multiple cells. " "When nothing is selected, delete the last row.</SPAN>") self.butSave = QPushButton(self) self.butSave.setIcon(QIcon(':/upload.svg')) self.butSave.setIconSize(q_icon_size) self.butSave.setToolTip("<span>Save coefficients and update all plots. " "No modifications are saved before!</span>") self.butLoad = QPushButton(self) self.butLoad.setIcon(QIcon(':/download.svg')) self.butLoad.setIconSize(q_icon_size) self.butLoad.setToolTip("Reload coefficients.") self.butClear = QPushButton(self) self.butClear.setIcon(QIcon(':/trash.svg')) self.butClear.setIconSize(q_icon_size) self.butClear.setToolTip("Clear all entries.") self.butFromTable = QPushButton(self) self.butFromTable.setIcon(QIcon(':/to_clipboard.svg')) self.butFromTable.setIconSize(q_icon_size) self.butFromTable.setToolTip("<span>" "Copy table to clipboard / file, SELECTED items are copied as " "displayed. When nothing is selected, the whole table " "is copied with full precision in decimal format. </span>") self.butToTable = QPushButton(self) self.butToTable.setIcon(QIcon(':/from_clipboard.svg')) self.butToTable.setIconSize(q_icon_size) self.butToTable.setToolTip("<span>Copy clipboard / file to table.</span>") butSettingsClipboard = QPushButton(self) butSettingsClipboard.setIcon(QIcon(':/settings.svg')) butSettingsClipboard.setIconSize(q_icon_size) butSettingsClipboard.setToolTip("<span>Adjust settings for CSV format and whether " "to copy to/from clipboard or file.</span>") layHButtonsCoeffs1 = QHBoxLayout() layHButtonsCoeffs1.addWidget(self.cmbFilterType) layHButtonsCoeffs1.addWidget(self.butAddCells) layHButtonsCoeffs1.addWidget(self.butDelCells) layHButtonsCoeffs1.addWidget(self.butClear) layHButtonsCoeffs1.addWidget(self.butSave) layHButtonsCoeffs1.addWidget(self.butLoad) layHButtonsCoeffs1.addWidget(self.butFromTable) layHButtonsCoeffs1.addWidget(self.butToTable) layHButtonsCoeffs1.addWidget(butSettingsClipboard) layHButtonsCoeffs1.addStretch() #---------------------------------------------------------------------- # layHButtonsCoeffs2 # # Eps / set zero settings # --------------------------------------------------------------------- self.butSetZero = QPushButton("= 0", self) self.butSetZero.setToolTip("<span>Set selected coefficients = 0 with a magnitude < ε. " "When nothing is selected, test the whole table.</span>") self.butSetZero.setIconSize(q_icon_size) lblEps = QLabel(self) lblEps.setText("<b><i>for b, a</i> <</b>") self.ledEps = QLineEdit(self) self.ledEps.setToolTip("Specify tolerance value.") layHButtonsCoeffs2 = QHBoxLayout() layHButtonsCoeffs2.addWidget(self.butSetZero) layHButtonsCoeffs2.addWidget(lblEps) layHButtonsCoeffs2.addWidget(self.ledEps) layHButtonsCoeffs2.addStretch() ####################################################################### # frmQSettings # # This frame contains all quantization settings ####################################################################### #------------------------------------------------------------------- # layHW_Scale # # QFormat and scale settings # --------------------------------------------------------------------- lbl_Q = QLabel("Q =", self) lbl_Q.setFont(self.bifont) self.ledWI = QLineEdit(self) self.ledWI.setToolTip("Specify number of integer bits.") self.ledWI.setText("0") self.ledWI.setMaxLength(2) # maximum of 2 digits self.ledWI.setFixedWidth(30) # width of lineedit in points(?) self.lblDot = QLabel(".", self) # class attribute, visibility is toggled self.lblDot.setFont(self.bfont) self.ledWF = QLineEdit(self) self.ledWF.setToolTip("Specify number of fractional bits.") self.ledWF.setText("15") self.ledWF.setMaxLength(2) # maximum of 2 digits # self.ledWF.setFixedWidth(30) # width of lineedit in points(?) self.ledWF.setMaximumWidth(30) self.lblScale = QLabel("<b><i>Scale</i> =</b>", self) self.ledScale = QLineEdit(self) self.ledScale.setToolTip("Set the scale for converting float to fixpoint representation.") self.ledScale.setText(str(1)) layHWI_WF = QHBoxLayout() layHWI_WF.addWidget(lbl_Q) layHWI_WF.addWidget(self.ledWI) layHWI_WF.addWidget(self.lblDot) layHWI_WF.addWidget(self.ledWF) layHWI_WF.addStretch() layHScale = QHBoxLayout() layHScale.addWidget(self.lblScale) layHScale.addWidget(self.ledScale) layHScale.addStretch() layHW_Scale = QHBoxLayout() layHW_Scale.addLayout(layHWI_WF) layHW_Scale.addLayout(layHScale) #------------------------------------------------------------------- # layGQOpt # # Quantization / Overflow / MSB / LSB settings # --------------------------------------------------------------------- lblQOvfl = QLabel("Ovfl.:", self) lblQOvfl.setFont(self.bifont) lblQuant = QLabel("Quant.:", self) lblQuant.setFont(self.bifont) self.cmbQOvfl = QComboBox(self) qOvfl = ['wrap', 'sat'] self.cmbQOvfl.addItems(qOvfl) qset_cmb_box(self.cmbQOvfl, 'sat') self.cmbQOvfl.setToolTip("Select overflow behaviour.") # ComboBox size is adjusted automatically to fit the longest element self.cmbQOvfl.setSizeAdjustPolicy(QComboBox.AdjustToContents) layHQOvflOpt = QHBoxLayout() layHQOvflOpt.addWidget(lblQOvfl) layHQOvflOpt.addWidget(self.cmbQOvfl) layHQOvflOpt.addStretch() self.cmbQuant = QComboBox(self) qQuant = ['none', 'round', 'fix', 'floor'] self.cmbQuant.addItems(qQuant) qset_cmb_box(self.cmbQuant, 'round') self.cmbQuant.setToolTip("Select the kind of quantization.") self.cmbQuant.setSizeAdjustPolicy(QComboBox.AdjustToContents) layHQuantOpt = QHBoxLayout() layHQuantOpt.addWidget(lblQuant) layHQuantOpt.addWidget(self.cmbQuant) layHQuantOpt.addStretch() self.butQuant = QPushButton(self) self.butQuant.setToolTip("<span>Quantize selected coefficients / " "whole table with specified settings.</span>") self.butQuant.setIcon(QIcon(':/quantize.svg')) self.butQuant.setIconSize(q_icon_size) self.butQuant.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) lblMSBtxt = QLabel(self) lblMSBtxt.setText("<b><i>MSB</i><sub>10</sub> =</b>") self.lblMSB = QLabel(self) layHMSB = QHBoxLayout() layHMSB.addWidget(lblMSBtxt) layHMSB.addWidget(self.lblMSB) layHMSB.addStretch() lblLSBtxt = QLabel(self) lblLSBtxt.setText("<b><i>LSB</i><sub>10</sub> =</b>") self.lblLSB = QLabel(self) # layHLSB = QHBoxLayout() layHLSB.addWidget(lblLSBtxt) layHLSB.addWidget(self.lblLSB) layHLSB.addStretch() layGQOpt = QGridLayout() layGQOpt.addLayout(layHQOvflOpt,0,0) layGQOpt.addLayout(layHQuantOpt, 0,1) layGQOpt.addWidget(self.butQuant, 0, 2, Qt.AlignCenter) layGQOpt.addLayout(layHMSB,1,0) layGQOpt.addLayout(layHLSB,1,1) #------------------------------------------------------------------- # Display MAX # --------------------------------------------------------------------- lblMAXtxt = QLabel(self) lblMAXtxt.setText("<b><i>Max =</i></b>") self.lblMAX = QLabel(self) layHCoeffs_MAX = QHBoxLayout() layHCoeffs_MAX.addWidget(lblMAXtxt) layHCoeffs_MAX.addWidget(self.lblMAX) layHCoeffs_MAX.addStretch() ####################################################################### # Now put all the coefficient HBoxes into frmQSettings # --------------------------------------------------------------------- layVButtonsQ = QVBoxLayout() layVButtonsQ.addLayout(layHW_Scale) layVButtonsQ.addLayout(layGQOpt) layVButtonsQ.addLayout(layHCoeffs_MAX) layVButtonsQ.setContentsMargins(0,5,0,0) # This frame encompasses all Quantization Settings self.frmQSettings = QFrame(self) self.frmQSettings.setLayout(layVButtonsQ) # ######################## Main UI Layout ############################ # layout for frame (UI widget) layVMainF = QVBoxLayout() layVMainF.addLayout(layHDisplay) layVMainF.addLayout(layHButtonsCoeffs1) layVMainF.addLayout(layHButtonsCoeffs2) layVMainF.addWidget(self.frmQSettings) # This frame encompasses all UI elements frmMain = QFrame(self) frmMain.setLayout(layVMainF) layVMain = QVBoxLayout() layVMain.setAlignment(Qt.AlignTop) # this affects only the first widget (intended here) layVMain.addWidget(frmMain) layVMain.setContentsMargins(*params['wdg_margins']) self.setLayout(layVMain) ####################################################################### #--- set initial values from dict / signal slot connections------------ self.spnDigits.setValue(params['FMT_ba']) self.ledEps.setText(str(self.eps)) butSettingsClipboard.clicked.connect(self._copy_options)
def __init__(self, parent): """ Pass instance `parent` of parent class (FilterCoeffs) """ super(Input_PZ_UI, self).__init__(parent) # self.parent = parent # instance of the parent (not the base) class self.eps = 1.e-4 # # tolerance value for e.g. setting P/Z to zero """ Intitialize the widget, consisting of: - top chkbox row - coefficient table - two bottom rows with action buttons """ self.bfont = QFont() self.bfont.setBold(True) self.bifont = QFont() self.bifont.setBold(True) self.bifont.setItalic(True) # q_icon_size = QSize(20, 20) # optional, size is derived from butEnable # --------------------------------------------- # UI Elements for controlling the display # --------------------------------------------- self.butEnable = QPushButton(self) self.butEnable.setIcon(QIcon(':/circle-x.svg')) q_icon_size = self.butEnable.iconSize() # <- set this for manual icon sizing self.butEnable.setIconSize(q_icon_size) self.butEnable.setCheckable(True) self.butEnable.setChecked(True) self.butEnable.setToolTip("<span>Show / hide poles and zeros in an editable table." " For high order systems, the table display might be slow.</span>") self.cmbPZFrmt = QComboBox(self) pz_formats = [('Cartesian', 'cartesian'), ('Polar (rad)', 'polar_rad'), ('Polar (pi)', 'polar_pi'), ('Polar (°)', 'polar_deg')] # display text, data # π: u'3C0, °: u'B0, ∠: u'2220 for pz in pz_formats: self.cmbPZFrmt.addItem(*pz) self.cmbPZFrmt.setSizeAdjustPolicy(QComboBox.AdjustToContents) # self.cmbPZFrmt.setEnabled(False) self.cmbPZFrmt.setToolTip("<span>Set display format for poles and zeros to" " either cartesian (x + jy) or polar (r * ∠ Ω)." " Type 'o' for '°', '<' for '∠' and 'pi' for 'π'.</span>") self.spnDigits = QSpinBox(self) self.spnDigits.setRange(0,16) self.spnDigits.setToolTip("Number of digits to display.") self.lblDigits = QLabel("Digits", self) self.lblDigits.setFont(self.bifont) self.cmbCausal = QComboBox(self) causal_types = ['Causal', 'Acausal', 'Anticausal'] for cs in causal_types: self.cmbCausal.addItem(cs) qset_cmb_box(self.cmbCausal, 'Causal') self.cmbCausal.setToolTip('<span>Set the system type. Not implemented yet.</span>') self.cmbCausal.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.cmbCausal.setEnabled(False) layHDisplay = QHBoxLayout() layHDisplay.setAlignment(Qt.AlignLeft) layHDisplay.addWidget(self.butEnable) layHDisplay.addWidget(self.cmbPZFrmt) layHDisplay.addWidget(self.spnDigits) layHDisplay.addWidget(self.lblDigits) layHDisplay.addWidget(self.cmbCausal) layHDisplay.addStretch() # --------------------------------------------- # UI Elements for setting the gain # --------------------------------------------- self.lblNorm = QLabel(to_html("Normalize:", frmt='bi'), self) self.cmbNorm = QComboBox(self) self.cmbNorm.addItems(["None", "1", "Max"]) self.cmbNorm.setToolTip("<span>Set the gain <i>k</i> so that H(f)<sub>max</sub> is " "either 1 or the max. of the previous system.</span>") self.lblGain = QLabel(to_html("k =", frmt='bi'), self) self.ledGain = QLineEdit(self) self.ledGain.setToolTip("<span>Specify gain factor <i>k</i>" " (only possible for Normalize = 'None').</span>") self.ledGain.setText(str(1.)) self.ledGain.setObjectName("ledGain") layHGain = QHBoxLayout() layHGain.addWidget(self.lblNorm) layHGain.addWidget(self.cmbNorm) layHGain.addWidget(self.lblGain) layHGain.addWidget(self.ledGain) layHGain.addStretch() # --------------------------------------------- # UI Elements for loading / storing / manipulating cells and rows # --------------------------------------------- # self.cmbFilterType = QComboBox(self) # self.cmbFilterType.setObjectName("comboFilterType") # self.cmbFilterType.setToolTip("Select between IIR and FIR filte for manual entry.") # self.cmbFilterType.addItems(["FIR","IIR"]) # self.cmbFilterType.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.butAddCells = QPushButton(self) self.butAddCells.setIcon(QIcon(':/row_insert_above.svg')) self.butAddCells.setIconSize(q_icon_size) self.butAddCells.setToolTip("<SPAN>Select cells to insert a new cell above each selected cell. " "Use <SHIFT> or <CTRL> to select multiple cells. " "When nothing is selected, add a row at the end.</SPAN>") self.butDelCells = QPushButton(self) self.butDelCells.setIcon(QIcon(':/row_delete.svg')) self.butDelCells.setIconSize(q_icon_size) self.butDelCells.setToolTip("<SPAN>Delete selected cell(s) from the table. " "Use <SHIFT> or <CTRL> to select multiple cells. " "When nothing is selected, delete the last row.</SPAN>") self.butSave = QPushButton(self) self.butSave.setIcon(QIcon(':/upload.svg')) self.butSave.setIconSize(q_icon_size) self.butSave.setToolTip("<span>Copy P/Z table to filter dict and update all plots and widgets.</span>") self.butLoad = QPushButton(self) self.butLoad.setIcon(QIcon(':/download.svg')) self.butLoad.setIconSize(q_icon_size) self.butLoad.setToolTip("Reload P/Z table from filter dict.") self.butClear = QPushButton(self) self.butClear.setIcon(QIcon(':/trash.svg')) self.butClear.setIconSize(q_icon_size) self.butClear.setToolTip("Clear all table entries.") self.butFromTable = QPushButton(self) self.butFromTable.setIconSize(q_icon_size) self.butToTable = QPushButton(self) self.butToTable.setIconSize(q_icon_size) self._set_load_save_icons() butSettingsClipboard = QPushButton(self) butSettingsClipboard.setIcon(QIcon(':/settings.svg')) butSettingsClipboard.setIconSize(q_icon_size) butSettingsClipboard.setToolTip("<span>Select CSV format and whether " "to copy to/from clipboard or file.</span>") layHButtonsCoeffs1 = QHBoxLayout() # layHButtonsCoeffs1.addWidget(self.cmbFilterType) layHButtonsCoeffs1.addWidget(self.butAddCells) layHButtonsCoeffs1.addWidget(self.butDelCells) layHButtonsCoeffs1.addWidget(self.butClear) layHButtonsCoeffs1.addWidget(self.butSave) layHButtonsCoeffs1.addWidget(self.butLoad) layHButtonsCoeffs1.addWidget(self.butFromTable) layHButtonsCoeffs1.addWidget(self.butToTable) layHButtonsCoeffs1.addWidget(butSettingsClipboard) layHButtonsCoeffs1.addStretch() #------------------------------------------------------------------- # Eps / set zero settings # --------------------------------------------------------------------- self.butSetZero = QPushButton("= 0", self) self.butSetZero.setToolTip("<span>Set selected poles / zeros = 0 with a magnitude < ε. " "When nothing is selected, test the whole table.</span>") self.butSetZero.setIconSize(q_icon_size) lblEps = QLabel(self) lblEps.setText("<b><i>for ε</i> <</b>") self.ledEps = QLineEdit(self) self.ledEps.setToolTip("Specify tolerance value.") layHButtonsCoeffs2 = QHBoxLayout() layHButtonsCoeffs2.addWidget(self.butSetZero) layHButtonsCoeffs2.addWidget(lblEps) layHButtonsCoeffs2.addWidget(self.ledEps) layHButtonsCoeffs2.addStretch() # ######################## Main UI Layout ############################ # layout for frame (UI widget) layVMainF = QVBoxLayout() layVMainF.addLayout(layHDisplay) layVMainF.addLayout(layHGain) layVMainF.addLayout(layHButtonsCoeffs1) layVMainF.addLayout(layHButtonsCoeffs2) # This frame encompasses all UI elements frmMain = QFrame(self) frmMain.setLayout(layVMainF) layVMain = QVBoxLayout() layVMain.setAlignment(Qt.AlignTop) # this affects only the first widget (intended here) layVMain.addWidget(frmMain) layVMain.setContentsMargins(*params['wdg_margins']) self.setLayout(layVMain) #--- set initial values from dict ------------ self.spnDigits.setValue(params['FMT_pz']) self.ledEps.setText(str(self.eps)) #---------------------------------------------------------------------- # LOCAL SIGNALS & SLOTs #---------------------------------------------------------------------- butSettingsClipboard.clicked.connect(self._copy_options) self.sig_rx.connect(self._set_load_save_icons)
def __init__(self, parent): """ Pass instance `parent` of parent class (FilterCoeffs) """ super(Input_PZ_UI, self).__init__(parent) # self.parent = parent # instance of the parent (not the base) class self.eps = 1.e-4 # # tolerance value for e.g. setting P/Z to zero """ Intitialize the widget, consisting of: - top chkbox row - coefficient table - two bottom rows with action buttons """ self.bfont = QFont() self.bfont.setBold(True) self.bifont = QFont() self.bifont.setBold(True) self.bifont.setItalic(True) # q_icon_size = QSize(20, 20) # optional, size is derived from butEnable # --------------------------------------------- # UI Elements for controlling the display # --------------------------------------------- self.butEnable = QPushButton(self) self.butEnable.setIcon(QIcon(':/circle-x.svg')) q_icon_size = self.butEnable.iconSize( ) # <- set this for manual icon sizing self.butEnable.setIconSize(q_icon_size) self.butEnable.setCheckable(True) self.butEnable.setChecked(True) self.butEnable.setToolTip( "<span>Show / hide poles and zeros in an editable table." " For high order systems, the table display might be slow.</span>") self.cmbPZFrmt = QComboBox(self) pz_formats = [('Cartesian', 'cartesian'), ('Polar (rad)', 'polar_rad'), ('Polar (pi)', 'polar_pi'), ('Polar (°)', 'polar_deg')] # display text, data # π: u'3C0, °: u'B0, ∠: u'2220 for pz in pz_formats: self.cmbPZFrmt.addItem(*pz) self.cmbPZFrmt.setSizeAdjustPolicy(QComboBox.AdjustToContents) # self.cmbPZFrmt.setEnabled(False) self.cmbPZFrmt.setToolTip( "<span>Set display format for poles and zeros to" " either cartesian (x + jy) or polar (r * ∠ Ω)." " Type 'o' for '°', '<' for '∠' and 'pi' for 'π'.</span>" ) self.spnDigits = QSpinBox(self) self.spnDigits.setRange(0, 16) self.spnDigits.setToolTip("Number of digits to display.") self.lblDigits = QLabel("Digits", self) self.lblDigits.setFont(self.bifont) self.cmbCausal = QComboBox(self) causal_types = ['Causal', 'Acausal', 'Anticausal'] for cs in causal_types: self.cmbCausal.addItem(cs) qset_cmb_box(self.cmbCausal, 'Causal') self.cmbCausal.setToolTip( '<span>Set the system type. Not implemented yet.</span>') self.cmbCausal.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.cmbCausal.setEnabled(False) layHDisplay = QHBoxLayout() layHDisplay.setAlignment(Qt.AlignLeft) layHDisplay.addWidget(self.butEnable) layHDisplay.addWidget(self.cmbPZFrmt) layHDisplay.addWidget(self.spnDigits) layHDisplay.addWidget(self.lblDigits) layHDisplay.addWidget(self.cmbCausal) layHDisplay.addStretch() # --------------------------------------------- # UI Elements for setting the gain # --------------------------------------------- self.lblNorm = QLabel(to_html("Normalize:", frmt='bi'), self) self.cmbNorm = QComboBox(self) self.cmbNorm.addItems(["None", "1", "Max"]) self.cmbNorm.setToolTip( "<span>Set the gain <i>k</i> so that H(f)<sub>max</sub> is " "either 1 or the max. of the previous system.</span>") self.lblGain = QLabel(to_html("k =", frmt='bi'), self) self.ledGain = QLineEdit(self) self.ledGain.setToolTip( "<span>Specify gain factor <i>k</i>" " (only possible for Normalize = 'None').</span>") self.ledGain.setText(str(1.)) self.ledGain.setObjectName("ledGain") layHGain = QHBoxLayout() layHGain.addWidget(self.lblNorm) layHGain.addWidget(self.cmbNorm) layHGain.addWidget(self.lblGain) layHGain.addWidget(self.ledGain) layHGain.addStretch() # --------------------------------------------- # UI Elements for loading / storing / manipulating cells and rows # --------------------------------------------- # self.cmbFilterType = QComboBox(self) # self.cmbFilterType.setObjectName("comboFilterType") # self.cmbFilterType.setToolTip("Select between IIR and FIR filte for manual entry.") # self.cmbFilterType.addItems(["FIR","IIR"]) # self.cmbFilterType.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.butAddCells = QPushButton(self) self.butAddCells.setIcon(QIcon(':/row_insert_above.svg')) self.butAddCells.setIconSize(q_icon_size) self.butAddCells.setToolTip( "<SPAN>Select cells to insert a new cell above each selected cell. " "Use <SHIFT> or <CTRL> to select multiple cells. " "When nothing is selected, add a row at the end.</SPAN>") self.butDelCells = QPushButton(self) self.butDelCells.setIcon(QIcon(':/row_delete.svg')) self.butDelCells.setIconSize(q_icon_size) self.butDelCells.setToolTip( "<SPAN>Delete selected cell(s) from the table. " "Use <SHIFT> or <CTRL> to select multiple cells. " "When nothing is selected, delete the last row.</SPAN>") self.butSave = QPushButton(self) self.butSave.setIcon(QIcon(':/upload.svg')) self.butSave.setIconSize(q_icon_size) self.butSave.setToolTip( "<span>Copy P/Z table to filter dict and update all plots and widgets.</span>" ) self.butLoad = QPushButton(self) self.butLoad.setIcon(QIcon(':/download.svg')) self.butLoad.setIconSize(q_icon_size) self.butLoad.setToolTip("Reload P/Z table from filter dict.") self.butClear = QPushButton(self) self.butClear.setIcon(QIcon(':/trash.svg')) self.butClear.setIconSize(q_icon_size) self.butClear.setToolTip("Clear all table entries.") self.butFromTable = QPushButton(self) self.butFromTable.setIconSize(q_icon_size) self.butToTable = QPushButton(self) self.butToTable.setIconSize(q_icon_size) self._set_load_save_icons() butSettingsClipboard = QPushButton(self) butSettingsClipboard.setIcon(QIcon(':/settings.svg')) butSettingsClipboard.setIconSize(q_icon_size) butSettingsClipboard.setToolTip( "<span>Select CSV format and whether " "to copy to/from clipboard or file.</span>") layHButtonsCoeffs1 = QHBoxLayout() # layHButtonsCoeffs1.addWidget(self.cmbFilterType) layHButtonsCoeffs1.addWidget(self.butAddCells) layHButtonsCoeffs1.addWidget(self.butDelCells) layHButtonsCoeffs1.addWidget(self.butClear) layHButtonsCoeffs1.addWidget(self.butSave) layHButtonsCoeffs1.addWidget(self.butLoad) layHButtonsCoeffs1.addWidget(self.butFromTable) layHButtonsCoeffs1.addWidget(self.butToTable) layHButtonsCoeffs1.addWidget(butSettingsClipboard) layHButtonsCoeffs1.addStretch() #------------------------------------------------------------------- # Eps / set zero settings # --------------------------------------------------------------------- self.butSetZero = QPushButton("= 0", self) self.butSetZero.setToolTip( "<span>Set selected poles / zeros = 0 with a magnitude < ε. " "When nothing is selected, test the whole table.</span>") self.butSetZero.setIconSize(q_icon_size) lblEps = QLabel(self) lblEps.setText("<b><i>for ε</i> <</b>") self.ledEps = QLineEdit(self) self.ledEps.setToolTip("Specify tolerance value.") layHButtonsCoeffs2 = QHBoxLayout() layHButtonsCoeffs2.addWidget(self.butSetZero) layHButtonsCoeffs2.addWidget(lblEps) layHButtonsCoeffs2.addWidget(self.ledEps) layHButtonsCoeffs2.addStretch() # ######################## Main UI Layout ############################ # layout for frame (UI widget) layVMainF = QVBoxLayout() layVMainF.addLayout(layHDisplay) layVMainF.addLayout(layHGain) layVMainF.addLayout(layHButtonsCoeffs1) layVMainF.addLayout(layHButtonsCoeffs2) # This frame encompasses all UI elements frmMain = QFrame(self) frmMain.setLayout(layVMainF) layVMain = QVBoxLayout() layVMain.setAlignment( Qt.AlignTop) # this affects only the first widget (intended here) layVMain.addWidget(frmMain) layVMain.setContentsMargins(*params['wdg_margins']) self.setLayout(layVMain) #--- set initial values from dict ------------ self.spnDigits.setValue(params['FMT_pz']) self.ledEps.setText(str(self.eps)) #---------------------------------------------------------------------- # LOCAL SIGNALS & SLOTs #---------------------------------------------------------------------- butSettingsClipboard.clicked.connect(self._copy_options) self.sig_rx.connect(self._set_load_save_icons)
def _construct_UI(self): # ----------- --------------------------------------------------- # Run control widgets # --------------------------------------------------------------- self.lbl_sim_select = QLabel("<b>Simulate</b>", self) self.cmb_sim_select = QComboBox(self) self.cmb_sim_select.addItems(["Float", "Fixpoint"]) qset_cmb_box(self.cmb_sim_select, "Float") self.cmb_sim_select.setToolTip( "<span>Simulate floating-point or fixpoint response." "</span>") self.lbl_N_points = QLabel(to_html("N", frmt='bi') + " =", self) self.led_N_points = QLineEdit(self) self.led_N_points.setText(str(self.N_points)) self.led_N_points.setToolTip( "<span>Number of points to calculate and display. " "N = 0 tries to choose for you.</span>") self.lbl_N_start = QLabel(to_html("N_0", frmt='bi') + " =", self) self.led_N_start = QLineEdit(self) self.led_N_start.setText(str(self.N_start)) self.led_N_start.setToolTip("<span>First point to plot.</span>") self.but_run = QPushButton("RUN", self) self.but_run.setToolTip("Run fixpoint simulation") self.chk_fx_scale = QCheckBox("Integer scale", self) self.chk_fx_scale.setObjectName("chk_fx_scale") self.chk_fx_scale.setToolTip( "<span>Display data with integer (fixpoint) scale.</span>") self.chk_fx_scale.setChecked(False) self.chk_stim_options = QCheckBox("Stimulus Options", self) self.chk_stim_options.setObjectName("chk_stim_options") self.chk_stim_options.setToolTip( "<span>Show options for stimulus signal.</span>") self.chk_stim_options.setChecked(True) layH_ctrl_run = QHBoxLayout() layH_ctrl_run.addWidget(self.lbl_sim_select) layH_ctrl_run.addWidget(self.cmb_sim_select) layH_ctrl_run.addStretch(1) layH_ctrl_run.addWidget(self.lbl_N_start) layH_ctrl_run.addWidget(self.led_N_start) layH_ctrl_run.addStretch(1) layH_ctrl_run.addWidget(self.lbl_N_points) layH_ctrl_run.addWidget(self.led_N_points) layH_ctrl_run.addStretch(1) layH_ctrl_run.addWidget(self.but_run) layH_ctrl_run.addStretch(2) layH_ctrl_run.addWidget(self.chk_fx_scale) layH_ctrl_run.addStretch(2) layH_ctrl_run.addWidget(self.chk_stim_options) layH_ctrl_run.addStretch(10) #layH_ctrl_run.setContentsMargins(*params['wdg_margins']) self.wdg_ctrl_run = QWidget(self) self.wdg_ctrl_run.setLayout(layH_ctrl_run) # --- end of run control ---------------------------------------- # ----------- --------------------------------------------------- # Controls for time domain # --------------------------------------------------------------- lbl_plt_time_title = QLabel("<b>Time: Show</b>", self) self.lbl_plt_time_resp = QLabel("Response", self) self.cmb_plt_time_resp = QComboBox(self) self.cmb_plt_time_resp.addItems( ["None", "Dots", "Line", "Stem", "Step"]) qset_cmb_box(self.cmb_plt_time_resp, self.plt_time_resp) self.cmb_plt_time_resp.setToolTip( "<span>Choose response plot style.</span>") self.chk_mrk_time_resp = QCheckBox("*", self) self.chk_mrk_time_resp.setChecked(False) self.chk_mrk_time_resp.setToolTip("Use plot markers") self.lbl_plt_time_stim = QLabel("Stimulus", self) self.cmb_plt_time_stim = QComboBox(self) self.cmb_plt_time_stim.addItems( ["None", "Dots", "Line", "Stem", "Step"]) qset_cmb_box(self.cmb_plt_time_stim, self.plt_time_stim) self.cmb_plt_time_stim.setToolTip( "<span>Choose stimulus plot style.</span>") self.chk_mrk_time_stim = QCheckBox("*", self) self.chk_mrk_time_stim.setChecked(False) self.chk_mrk_time_stim.setToolTip("Use plot markers") self.chk_log_time = QCheckBox("dB", self) self.chk_log_time.setObjectName("chk_log_time") self.chk_log_time.setToolTip( "<span>Logarithmic scale for y-axis.</span>") self.chk_log_time.setChecked(False) self.lbl_log_bottom_time = QLabel("Bottom = ", self) self.led_log_bottom_time = QLineEdit(self) self.led_log_bottom_time.setText(str(self.bottom_t)) self.led_log_bottom_time.setToolTip( "<span>Minimum display value for log. scale.</span>") self.lbl_dB_time = QLabel("dB", self) self.chk_win_time = QCheckBox("FFT Window", self) self.chk_win_time.setObjectName("chk_win_time") self.chk_win_time.setToolTip( "<span>Show FFT windowing function.</span>") self.chk_win_time.setChecked(False) self.chk_fx_range = QCheckBox("Min/max.", self) self.chk_fx_range.setObjectName("chk_fx_range") self.chk_fx_range.setToolTip( "<span>Display limits of fixpoint range.</span>") self.chk_fx_range.setChecked(False) layH_ctrl_time = QHBoxLayout() layH_ctrl_time.addWidget(lbl_plt_time_title) layH_ctrl_time.addStretch(1) layH_ctrl_time.addWidget(self.lbl_plt_time_resp) layH_ctrl_time.addWidget(self.cmb_plt_time_resp) layH_ctrl_time.addWidget(self.chk_mrk_time_resp) layH_ctrl_time.addStretch(1) layH_ctrl_time.addWidget(self.lbl_plt_time_stim) layH_ctrl_time.addWidget(self.cmb_plt_time_stim) layH_ctrl_time.addWidget(self.chk_mrk_time_stim) layH_ctrl_time.addStretch(2) layH_ctrl_time.addWidget(self.chk_log_time) layH_ctrl_time.addStretch(1) layH_ctrl_time.addWidget(self.lbl_log_bottom_time) layH_ctrl_time.addWidget(self.led_log_bottom_time) layH_ctrl_time.addWidget(self.lbl_dB_time) layH_ctrl_time.addStretch(1) layH_ctrl_time.addWidget(self.chk_win_time) layH_ctrl_time.addStretch(2) layH_ctrl_time.addWidget(self.chk_fx_range) layH_ctrl_time.addStretch(10) #layH_ctrl_time.setContentsMargins(*params['wdg_margins']) self.wdg_ctrl_time = QWidget(self) self.wdg_ctrl_time.setLayout(layH_ctrl_time) # ---- end time domain ------------------ # --------------------------------------------------------------- # Controls for frequency domain # --------------------------------------------------------------- lbl_plt_freq_title = QLabel("<b>Freq: Show</b>", self) self.lbl_plt_freq_stim = QLabel("Stimulus", self) self.cmb_plt_freq_stim = QComboBox(self) self.cmb_plt_freq_stim.addItems( ["None", "Dots", "Line", "Stem", "Step"]) qset_cmb_box(self.cmb_plt_freq_stim, self.plt_freq_stim) self.cmb_plt_freq_stim.setToolTip( "<span>Choose stimulus plot style.</span>") self.chk_mrk_freq_stim = QCheckBox("*", self) self.chk_mrk_freq_stim.setChecked(False) self.chk_mrk_freq_stim.setToolTip("Use plot markers") self.lbl_plt_freq_resp = QLabel("Response", self) self.cmb_plt_freq_resp = QComboBox(self) self.cmb_plt_freq_resp.addItems( ["None", "Dots", "Line", "Stem", "Step"]) qset_cmb_box(self.cmb_plt_freq_resp, self.plt_freq_resp) self.cmb_plt_freq_resp.setToolTip( "<span>Choose response plot style.</span>") self.chk_mrk_freq_resp = QCheckBox("*", self) self.chk_mrk_freq_resp.setChecked(False) self.chk_mrk_freq_resp.setToolTip("Use plot markers") self.chk_log_freq = QCheckBox("dB", self) self.chk_log_freq.setObjectName("chk_log_freq") self.chk_log_freq.setToolTip( "<span>Logarithmic scale for y-axis.</span>") self.chk_log_freq.setChecked(True) self.lbl_log_bottom_freq = QLabel("Bottom = ", self) self.led_log_bottom_freq = QLineEdit(self) self.led_log_bottom_freq.setText(str(self.bottom_f)) self.led_log_bottom_freq.setToolTip( "<span>Minimum display value for log. scale.</span>") self.lbl_dB_freq = QLabel("dB", self) self.lbl_win_fft = QLabel("Window: ", self) self.cmb_win_fft = QComboBox(self) self.cmb_win_fft.addItems([ "Rect", "Triangular", "Hann", "Hamming", "Kaiser", "Flattop", "Chebwin" ]) self.cmb_win_fft.setToolTip("Select window type.") qset_cmb_box(self.cmb_win_fft, self.window) self.lblWinPar1 = QLabel("Param1") self.ledWinPar1 = QLineEdit(self) self.ledWinPar1.setText("1") self.ledWinPar1.setObjectName("ledWinPar1") self.chk_win_freq = QCheckBox("Show", self) self.chk_win_freq.setObjectName("chk_win_freq") self.chk_win_freq.setToolTip( "<span>Show FFT windowing function.</span>") self.chk_win_freq.setChecked(False) layH_ctrl_freq = QHBoxLayout() layH_ctrl_freq.addWidget(lbl_plt_freq_title) layH_ctrl_freq.addStretch(1) layH_ctrl_freq.addWidget(self.lbl_plt_freq_resp) layH_ctrl_freq.addWidget(self.cmb_plt_freq_resp) layH_ctrl_freq.addWidget(self.chk_mrk_freq_resp) layH_ctrl_freq.addStretch(1) layH_ctrl_freq.addWidget(self.lbl_plt_freq_stim) layH_ctrl_freq.addWidget(self.cmb_plt_freq_stim) layH_ctrl_freq.addWidget(self.chk_mrk_freq_stim) layH_ctrl_freq.addWidget(self.chk_log_freq) layH_ctrl_freq.addWidget(self.lbl_log_bottom_freq) layH_ctrl_freq.addWidget(self.led_log_bottom_freq) layH_ctrl_freq.addWidget(self.lbl_dB_freq) layH_ctrl_freq.addStretch(2) layH_ctrl_freq.addWidget(self.lbl_win_fft) layH_ctrl_freq.addWidget(self.cmb_win_fft) layH_ctrl_freq.addWidget(self.lblWinPar1) layH_ctrl_freq.addWidget(self.ledWinPar1) layH_ctrl_freq.addWidget(self.chk_win_freq) layH_ctrl_freq.addStretch(10) #layH_ctrl_freq.setContentsMargins(*params['wdg_margins']) self.wdg_ctrl_freq = QWidget(self) self.wdg_ctrl_freq.setLayout(layH_ctrl_freq) # ---- end Frequency Domain ------------------ # --------------------------------------------------------------- # Controls for stimuli # --------------------------------------------------------------- lbl_title_stim = QLabel("<b>Stimulus:</b>", self) self.lblStimulus = QLabel("Signal: ", self) self.cmbStimulus = QComboBox(self) self.cmbStimulus.addItems( ["None", "Pulse", "Step", "StepErr", "Cos", "Sine", "Rect", "Saw"]) self.cmbStimulus.setToolTip("Select stimulus type.") qset_cmb_box(self.cmbStimulus, self.stim) self.lblNoise = QLabel("Noise: ", self) self.cmbNoise = QComboBox(self) self.cmbNoise.addItems(["None", "Gauss", "Uniform"]) self.cmbNoise.setToolTip("Select added noise type.") qset_cmb_box(self.cmbNoise, self.noise) layVlblCmb = QVBoxLayout() layVlblCmb.addWidget(self.lblStimulus) layVlblCmb.addWidget(self.lblNoise) layVCmb = QVBoxLayout() layVCmb.addWidget(self.cmbStimulus) layVCmb.addWidget(self.cmbNoise) self.lblAmp1 = QLabel(to_html("A_1", frmt='bi') + " =", self) self.ledAmp1 = QLineEdit(self) self.ledAmp1.setText(str(self.A1)) self.ledAmp1.setToolTip("Stimulus amplitude.") self.ledAmp1.setObjectName("stimAmp1") self.lblAmp2 = QLabel(to_html("A_2", frmt='bi') + " =", self) self.ledAmp2 = QLineEdit(self) self.ledAmp2.setText(str(self.A2)) self.ledAmp2.setToolTip("Stimulus amplitude 2.") self.ledAmp2.setObjectName("stimAmp2") layVlblAmp = QVBoxLayout() layVlblAmp.addWidget(self.lblAmp1) layVlblAmp.addWidget(self.lblAmp2) layVledAmp = QVBoxLayout() layVledAmp.addWidget(self.ledAmp1) layVledAmp.addWidget(self.ledAmp2) self.lblFreq1 = QLabel(to_html("f_1", frmt='bi') + " =", self) self.ledFreq1 = QLineEdit(self) self.ledFreq1.setText(str(self.f1)) self.ledFreq1.setToolTip("Stimulus frequency 1.") self.ledFreq1.setObjectName("stimFreq1") self.lblFreqUnit1 = QLabel("f_S", self) self.lblFreq2 = QLabel(to_html("f_2", frmt='bi') + " =", self) self.ledFreq2 = QLineEdit(self) self.ledFreq2.setText(str(self.f2)) self.ledFreq2.setToolTip("Stimulus frequency 2.") self.ledFreq2.setObjectName("stimFreq2") self.lblFreqUnit2 = QLabel("f_S", self) layVlblfreq = QVBoxLayout() layVlblfreq.addWidget(self.lblFreq1) layVlblfreq.addWidget(self.lblFreq2) layVledfreq = QVBoxLayout() layVledfreq.addWidget(self.ledFreq1) layVledfreq.addWidget(self.ledFreq2) layVlblfreqU = QVBoxLayout() layVlblfreqU.addWidget(self.lblFreqUnit1) layVlblfreqU.addWidget(self.lblFreqUnit2) self.lblNoi = QLabel("not initialized", self) self.ledNoi = QLineEdit(self) self.ledNoi.setText(str(self.noi)) self.ledNoi.setToolTip("not initialized") self.ledNoi.setObjectName("stimNoi") self.lblDC = QLabel(to_html("DC =", frmt='bi'), self) self.ledDC = QLineEdit(self) self.ledDC.setText(str(self.DC)) self.ledDC.setToolTip("DC Level") self.ledDC.setObjectName("stimDC") layVlblNoiDC = QVBoxLayout() layVlblNoiDC.addWidget(self.lblNoi) layVlblNoiDC.addWidget(self.lblDC) layVledNoiDC = QVBoxLayout() layVledNoiDC.addWidget(self.ledNoi) layVledNoiDC.addWidget(self.ledDC) layH_ctrl_stim = QHBoxLayout() layH_ctrl_stim.addWidget(lbl_title_stim) layH_ctrl_stim.addStretch(1) layH_ctrl_stim.addLayout(layVlblCmb) layH_ctrl_stim.addLayout(layVCmb) layH_ctrl_stim.addStretch(1) layH_ctrl_stim.addLayout(layVlblAmp) layH_ctrl_stim.addLayout(layVledAmp) layH_ctrl_stim.addLayout(layVlblfreq) layH_ctrl_stim.addLayout(layVledfreq) layH_ctrl_stim.addLayout(layVlblfreqU) layH_ctrl_stim.addStretch(1) layH_ctrl_stim.addLayout(layVlblNoiDC) layH_ctrl_stim.addLayout(layVledNoiDC) layH_ctrl_stim.addStretch(10) self.wdg_ctrl_stim = QWidget(self) self.wdg_ctrl_stim.setLayout(layH_ctrl_stim) # --------- end stimuli --------------------------------- #---------------------------------------------------------------------- # GLOBAL SIGNALS & SLOTs #---------------------------------------------------------------------- self.sig_rx.connect(self.process_sig_rx) #---------------------------------------------------------------------- # LOCAL SIGNALS & SLOTs #---------------------------------------------------------------------- # --- run control --- self.led_N_start.editingFinished.connect(self.update_N) self.led_N_points.editingFinished.connect(self.update_N) # --- frequency control --- #self.chkLogF.clicked.connect(self._log_mode_freq) #self.ledLogBottomF.editingFinished.connect(self._log_mode_freq) # careful! currentIndexChanged passes the current index to _update_win_fft self.cmb_win_fft.currentIndexChanged.connect(self._update_win_fft) self.ledWinPar1.editingFinished.connect(self._update_win_fft) # --- stimulus control --- self.cmbStimulus.currentIndexChanged.connect(self._enable_stim_widgets) self.cmbNoise.currentIndexChanged.connect(self._update_noi) self.ledNoi.editingFinished.connect(self._update_noi) self.ledAmp1.editingFinished.connect(self._update_amp1) self.ledAmp2.editingFinished.connect(self._update_amp2) self.ledDC.editingFinished.connect(self._update_DC)
def _construct_UI(self): # ----------- --------------------------------------------------- # Run control widgets # --------------------------------------------------------------- self.chk_auto_run = QCheckBox("Auto", self) self.chk_auto_run.setObjectName("chk_auto_run") self.chk_auto_run.setToolTip( "<span>Update response automatically when " "parameters have been changed.</span>") self.chk_auto_run.setChecked(True) self.but_run = QPushButton(self) self.but_run.setText("RUN") self.but_run.setToolTip("Run simulation") self.but_run.setEnabled(not self.chk_auto_run.isChecked()) self.cmb_sim_select = QComboBox(self) self.cmb_sim_select.addItems(["Float", "Fixpoint"]) qset_cmb_box(self.cmb_sim_select, "Float") self.cmb_sim_select.setToolTip( "<span>Simulate floating-point or fixpoint response." "</span>") self.lbl_N_points = QLabel(to_html("N", frmt='bi') + " =", self) self.led_N_points = QLineEdit(self) self.led_N_points.setText(str(self.N)) self.led_N_points.setToolTip( "<span>Number of displayed data points. " "<i>N</i> = 0 tries to choose for you.</span>") self.lbl_N_start = QLabel(to_html("N_0", frmt='bi') + " =", self) self.led_N_start = QLineEdit(self) self.led_N_start.setText(str(self.N_start)) self.led_N_start.setToolTip("<span>First point to plot.</span>") self.chk_fx_scale = QCheckBox("Int. scale", self) self.chk_fx_scale.setObjectName("chk_fx_scale") self.chk_fx_scale.setToolTip( "<span>Display data with integer (fixpoint) scale.</span>") self.chk_fx_scale.setChecked(False) self.chk_stim_options = QCheckBox("Stim. Options", self) self.chk_stim_options.setObjectName("chk_stim_options") self.chk_stim_options.setToolTip("<span>Show stimulus options.</span>") self.chk_stim_options.setChecked(True) self.but_fft_win = QPushButton(self) self.but_fft_win.setText("WIN FFT") self.but_fft_win.setToolTip( "Show time and frequency response of FFT Window") self.but_fft_win.setCheckable(True) self.but_fft_win.setChecked(False) layH_ctrl_run = QHBoxLayout() layH_ctrl_run.addWidget(self.but_run) #layH_ctrl_run.addWidget(self.lbl_sim_select) layH_ctrl_run.addWidget(self.cmb_sim_select) layH_ctrl_run.addWidget(self.chk_auto_run) layH_ctrl_run.addStretch(1) layH_ctrl_run.addWidget(self.lbl_N_start) layH_ctrl_run.addWidget(self.led_N_start) layH_ctrl_run.addStretch(1) layH_ctrl_run.addWidget(self.lbl_N_points) layH_ctrl_run.addWidget(self.led_N_points) layH_ctrl_run.addStretch(2) layH_ctrl_run.addWidget(self.chk_fx_scale) layH_ctrl_run.addStretch(2) layH_ctrl_run.addWidget(self.chk_stim_options) layH_ctrl_run.addStretch(2) layH_ctrl_run.addWidget(self.but_fft_win) layH_ctrl_run.addStretch(10) #layH_ctrl_run.setContentsMargins(*params['wdg_margins']) self.wdg_ctrl_run = QWidget(self) self.wdg_ctrl_run.setLayout(layH_ctrl_run) # --- end of run control ---------------------------------------- # ----------- --------------------------------------------------- # Controls for time domain # --------------------------------------------------------------- plot_styles_list = [ "None", "Dots", "Line", "Line*", "Stem", "Stem*", "Step", "Step*" ] lbl_plt_time_title = QLabel("<b>View:</b>", self) lbl_plt_time_resp = QLabel("Response", self) self.cmb_plt_time_resp = QComboBox(self) self.cmb_plt_time_resp.addItems(plot_styles_list) qset_cmb_box(self.cmb_plt_time_resp, self.plt_time_resp) self.cmb_plt_time_resp.setToolTip( "<span>Plot style for response.</span>") self.lbl_plt_time_stim = QLabel("Stimulus", self) self.cmb_plt_time_stim = QComboBox(self) self.cmb_plt_time_stim.addItems(plot_styles_list) qset_cmb_box(self.cmb_plt_time_stim, self.plt_time_stim) self.cmb_plt_time_stim.setToolTip( "<span>Plot style for stimulus.</span>") self.lbl_plt_time_stmq = QLabel("Stim.<q>", self) self.cmb_plt_time_stmq = QComboBox(self) self.cmb_plt_time_stmq.addItems(plot_styles_list) qset_cmb_box(self.cmb_plt_time_stmq, self.plt_time_stmq) self.cmb_plt_time_stmq.setToolTip( "<span>Plot style for <em>quantized</em> stimulus.</span>") self.chk_log_time = QCheckBox("dB", self) self.chk_log_time.setObjectName("chk_log_time") self.chk_log_time.setToolTip( "<span>Logarithmic scale for y-axis.</span>") self.chk_log_time.setChecked(False) self.led_log_bottom_time = QLineEdit(self) self.led_log_bottom_time.setText(str(self.bottom_t)) self.led_log_bottom_time.setToolTip( "<span>Minimum display value for log. scale.</span>") self.chk_win_time = QCheckBox("FFT Window", self) self.chk_win_time.setObjectName("chk_win_time") self.chk_win_time.setToolTip( "<span>Show FFT windowing function.</span>") self.chk_win_time.setChecked(False) self.chk_fx_limits = QCheckBox("Min/max.", self) self.chk_fx_limits.setObjectName("chk_fx_limits") self.chk_fx_limits.setToolTip( "<span>Display limits of fixpoint range.</span>") self.chk_fx_limits.setChecked(False) layH_ctrl_time = QHBoxLayout() layH_ctrl_time.addWidget(lbl_plt_time_title) layH_ctrl_time.addStretch(1) layH_ctrl_time.addWidget(lbl_plt_time_resp) layH_ctrl_time.addWidget(self.cmb_plt_time_resp) layH_ctrl_time.addStretch(1) layH_ctrl_time.addWidget(self.lbl_plt_time_stim) layH_ctrl_time.addWidget(self.cmb_plt_time_stim) layH_ctrl_time.addStretch(1) layH_ctrl_time.addWidget(self.lbl_plt_time_stmq) layH_ctrl_time.addWidget(self.cmb_plt_time_stmq) layH_ctrl_time.addStretch(2) layH_ctrl_time.addWidget(self.chk_log_time) layH_ctrl_time.addWidget(self.led_log_bottom_time) layH_ctrl_time.addStretch(1) layH_ctrl_time.addWidget(self.chk_win_time) layH_ctrl_time.addStretch(2) layH_ctrl_time.addWidget(self.chk_fx_limits) layH_ctrl_time.addStretch(10) #layH_ctrl_time.setContentsMargins(*params['wdg_margins']) self.wdg_ctrl_time = QWidget(self) self.wdg_ctrl_time.setLayout(layH_ctrl_time) # ---- end time domain ------------------ # --------------------------------------------------------------- # Controls for frequency domain # --------------------------------------------------------------- lbl_plt_freq_title = QLabel("<b>View:</b>", self) lbl_plt_freq_resp = QLabel("Response", self) self.cmb_plt_freq_resp = QComboBox(self) self.cmb_plt_freq_resp.addItems(plot_styles_list) qset_cmb_box(self.cmb_plt_freq_resp, self.plt_freq_resp) self.cmb_plt_freq_resp.setToolTip( "<span>Plot style for response.</span>") self.lbl_plt_freq_stim = QLabel("Stimulus", self) self.cmb_plt_freq_stim = QComboBox(self) self.cmb_plt_freq_stim.addItems(plot_styles_list) qset_cmb_box(self.cmb_plt_freq_stim, self.plt_freq_stim) self.cmb_plt_freq_stim.setToolTip( "<span>Plot style for stimulus.</span>") self.lbl_plt_freq_stmq = QLabel("Stim.<q>", self) self.cmb_plt_freq_stmq = QComboBox(self) self.cmb_plt_freq_stmq.addItems(plot_styles_list) qset_cmb_box(self.cmb_plt_freq_stmq, self.plt_freq_stmq) self.cmb_plt_freq_stmq.setToolTip( "<span>Plot style for <em>quantized</em> stimulus.</span>") self.chk_log_freq = QCheckBox("dB : Min.", self) self.chk_log_freq.setObjectName("chk_log_freq") self.chk_log_freq.setToolTip( "<span>Logarithmic scale for y-axis.</span>") self.chk_log_freq.setChecked(True) self.led_log_bottom_freq = QLineEdit(self) self.led_log_bottom_freq.setText(str(self.bottom_f)) self.led_log_bottom_freq.setToolTip( "<span>Minimum display value for log. scale.</span>") self.lbl_win_fft = QLabel("Window: ", self) self.cmb_win_fft = QComboBox(self) self.cmb_win_fft.addItems(get_window_names()) #self.cmb_win_fft.addItems(["Rect","Triangular","Hann","Hamming","Kaiser", "Flattop", "Chebwin"]) self.cmb_win_fft.setToolTip("FFT window type.") qset_cmb_box(self.cmb_win_fft, self.window) self.lblWinPar1 = QLabel("Param1") self.ledWinPar1 = QLineEdit(self) self.ledWinPar1.setText("1") self.ledWinPar1.setObjectName("ledWinPar1") self.lblWinPar2 = QLabel("Param2") self.ledWinPar2 = QLineEdit(self) self.ledWinPar2.setText("2") self.ledWinPar2.setObjectName("ledWinPar2") layH_ctrl_freq = QHBoxLayout() layH_ctrl_freq.addWidget(lbl_plt_freq_title) layH_ctrl_freq.addStretch(1) layH_ctrl_freq.addWidget(lbl_plt_freq_resp) layH_ctrl_freq.addWidget(self.cmb_plt_freq_resp) layH_ctrl_freq.addStretch(1) layH_ctrl_freq.addWidget(self.lbl_plt_freq_stim) layH_ctrl_freq.addWidget(self.cmb_plt_freq_stim) layH_ctrl_freq.addStretch(1) layH_ctrl_freq.addWidget(self.lbl_plt_freq_stmq) layH_ctrl_freq.addWidget(self.cmb_plt_freq_stmq) layH_ctrl_freq.addStretch(2) layH_ctrl_freq.addWidget(self.chk_log_freq) layH_ctrl_freq.addWidget(self.led_log_bottom_freq) layH_ctrl_freq.addStretch(2) layH_ctrl_freq.addWidget(self.lbl_win_fft) layH_ctrl_freq.addWidget(self.cmb_win_fft) layH_ctrl_freq.addWidget(self.lblWinPar1) layH_ctrl_freq.addWidget(self.ledWinPar1) layH_ctrl_freq.addWidget(self.lblWinPar2) layH_ctrl_freq.addWidget(self.ledWinPar2) layH_ctrl_freq.addStretch(10) #layH_ctrl_freq.setContentsMargins(*params['wdg_margins']) self.wdg_ctrl_freq = QWidget(self) self.wdg_ctrl_freq.setLayout(layH_ctrl_freq) # ---- end Frequency Domain ------------------ # --------------------------------------------------------------- # Controls for stimuli # --------------------------------------------------------------- lbl_title_stim = QLabel("<b>Stimulus:</b>", self) self.lblStimulus = QLabel("Signal: ", self) self.cmbStimulus = QComboBox(self) self.cmbStimulus.addItems([ "None", "Pulse", "Step", "StepErr", "Cos", "Sine", "Triang", "Saw", "Rect", "Comb" ]) self.cmbStimulus.setToolTip("Stimulus type.") qset_cmb_box(self.cmbStimulus, self.stim) self.chk_stim_bl = QCheckBox("BL", self) self.chk_stim_bl.setToolTip( "<span>The signal is bandlimited to the Nyquist frequency " "to avoid aliasing. However, it is much slower to generate " "than the regular version.</span>") self.chk_stim_bl.setChecked(True) self.chk_stim_bl.setObjectName("stim_bl") self.lblNoise = QLabel("Noise: ", self) self.cmbNoise = QComboBox(self) self.cmbNoise.addItems(["None", "Gauss", "Uniform", "PRBS"]) self.cmbNoise.setToolTip("Type of additive noise.") qset_cmb_box(self.cmbNoise, self.noise) layVlblCmb = QVBoxLayout() layVlblCmb.addWidget(self.lblStimulus) layVlblCmb.addWidget(self.lblNoise) layVCmb = QVBoxLayout() layHCmbStim = QHBoxLayout() layHCmbStim.addWidget(self.cmbStimulus) layHCmbStim.addWidget(self.chk_stim_bl) #layVCmb.addWidget(self.cmbStimulus) layVCmb.addLayout(layHCmbStim) layVCmb.addWidget(self.cmbNoise) #---------------------------------------------- self.lblAmp1 = QLabel(to_html("A_1", frmt='bi') + " =", self) self.ledAmp1 = QLineEdit(self) self.ledAmp1.setText(str(self.A1)) self.ledAmp1.setToolTip("Stimulus amplitude") self.ledAmp1.setObjectName("stimAmp1") self.lblAmp2 = QLabel(to_html("A_2", frmt='bi') + " =", self) self.ledAmp2 = QLineEdit(self) self.ledAmp2.setText(str(self.A2)) self.ledAmp2.setToolTip("Stimulus amplitude 2") self.ledAmp2.setObjectName("stimAmp2") layVlblAmp = QVBoxLayout() layVlblAmp.addWidget(self.lblAmp1) layVlblAmp.addWidget(self.lblAmp2) layVledAmp = QVBoxLayout() layVledAmp.addWidget(self.ledAmp1) layVledAmp.addWidget(self.ledAmp2) #---------------------------------------------- self.lblPhi1 = QLabel(to_html("φ_1", frmt='bi') + " =", self) self.ledPhi1 = QLineEdit(self) self.ledPhi1.setText(str(self.phi1)) self.ledPhi1.setToolTip("Stimulus phase") self.ledPhi1.setObjectName("stimPhi1") self.lblPhU1 = QLabel(to_html("°", frmt='b'), self) self.lblPhi2 = QLabel(to_html("φ_2", frmt='bi') + " =", self) self.ledPhi2 = QLineEdit(self) self.ledPhi2.setText(str(self.phi2)) self.ledPhi2.setToolTip("Stimulus phase 2") self.ledPhi2.setObjectName("stimPhi2") self.lblPhU2 = QLabel(to_html("°", frmt='b'), self) layVlblPhi = QVBoxLayout() layVlblPhi.addWidget(self.lblPhi1) layVlblPhi.addWidget(self.lblPhi2) layVledPhi = QVBoxLayout() layVledPhi.addWidget(self.ledPhi1) layVledPhi.addWidget(self.ledPhi2) layVlblPhU = QVBoxLayout() layVlblPhU.addWidget(self.lblPhU1) layVlblPhU.addWidget(self.lblPhU2) #---------------------------------------------- self.lblFreq1 = QLabel(to_html("f_1", frmt='bi') + " =", self) self.ledFreq1 = QLineEdit(self) self.ledFreq1.setText(str(self.f1)) self.ledFreq1.setToolTip("Stimulus frequency 1") self.ledFreq1.setObjectName("stimFreq1") self.lblFreqUnit1 = QLabel("f_S", self) self.lblFreq2 = QLabel(to_html("f_2", frmt='bi') + " =", self) self.ledFreq2 = QLineEdit(self) self.ledFreq2.setText(str(self.f2)) self.ledFreq2.setToolTip("Stimulus frequency 2") self.ledFreq2.setObjectName("stimFreq2") self.lblFreqUnit2 = QLabel("f_S", self) layVlblfreq = QVBoxLayout() layVlblfreq.addWidget(self.lblFreq1) layVlblfreq.addWidget(self.lblFreq2) layVledfreq = QVBoxLayout() layVledfreq.addWidget(self.ledFreq1) layVledfreq.addWidget(self.ledFreq2) layVlblfreqU = QVBoxLayout() layVlblfreqU.addWidget(self.lblFreqUnit1) layVlblfreqU.addWidget(self.lblFreqUnit2) #---------------------------------------------- self.lblNoi = QLabel("not initialized", self) self.ledNoi = QLineEdit(self) self.ledNoi.setText(str(self.noi)) self.ledNoi.setToolTip("not initialized") self.ledNoi.setObjectName("stimNoi") self.lblDC = QLabel(to_html("DC =", frmt='bi'), self) self.ledDC = QLineEdit(self) self.ledDC.setText(str(self.DC)) self.ledDC.setToolTip("DC Level") self.ledDC.setObjectName("stimDC") layVlblNoiDC = QVBoxLayout() layVlblNoiDC.addWidget(self.lblNoi) layVlblNoiDC.addWidget(self.lblDC) layVledNoiDC = QVBoxLayout() layVledNoiDC.addWidget(self.ledNoi) layVledNoiDC.addWidget(self.ledDC) #---------------------------------------------- layH_ctrl_stim = QHBoxLayout() layH_ctrl_stim.addWidget(lbl_title_stim) layH_ctrl_stim.addStretch(1) layH_ctrl_stim.addLayout(layVlblCmb) layH_ctrl_stim.addLayout(layVCmb) layH_ctrl_stim.addStretch(1) layH_ctrl_stim.addLayout(layVlblAmp) layH_ctrl_stim.addLayout(layVledAmp) layH_ctrl_stim.addLayout(layVlblPhi) layH_ctrl_stim.addLayout(layVledPhi) layH_ctrl_stim.addLayout(layVlblPhU) layH_ctrl_stim.addStretch(1) layH_ctrl_stim.addLayout(layVlblfreq) layH_ctrl_stim.addLayout(layVledfreq) layH_ctrl_stim.addLayout(layVlblfreqU) layH_ctrl_stim.addStretch(1) layH_ctrl_stim.addLayout(layVlblNoiDC) layH_ctrl_stim.addLayout(layVledNoiDC) layH_ctrl_stim.addStretch(10) self.wdg_ctrl_stim = QWidget(self) self.wdg_ctrl_stim.setLayout(layH_ctrl_stim) # --------- end stimuli --------------------------------- # frequency widgets require special handling as they are scaled with f_s self.ledFreq1.installEventFilter(self) self.ledFreq2.installEventFilter(self) #---------------------------------------------------------------------- # LOCAL SIGNALS & SLOTs #---------------------------------------------------------------------- # --- run control --- self.led_N_start.editingFinished.connect(self.update_N) self.led_N_points.editingFinished.connect(self.update_N) # --- frequency control --- # careful! currentIndexChanged passes the current index to _update_win_fft self.cmb_win_fft.currentIndexChanged.connect(self._update_win_fft) self.ledWinPar1.editingFinished.connect(self._update_param1) self.ledWinPar2.editingFinished.connect(self._update_param2) # --- stimulus control --- self.chk_stim_options.clicked.connect(self._show_stim_options) self.chk_stim_bl.clicked.connect(self._enable_stim_widgets) self.cmbStimulus.currentIndexChanged.connect(self._enable_stim_widgets) self.cmbNoise.currentIndexChanged.connect(self._update_noi) self.ledNoi.editingFinished.connect(self._update_noi) self.ledAmp1.editingFinished.connect(self._update_amp1) self.ledAmp2.editingFinished.connect(self._update_amp2) self.ledPhi1.editingFinished.connect(self._update_phi1) self.ledPhi2.editingFinished.connect(self._update_phi2) self.ledDC.editingFinished.connect(self._update_DC)
def __init__(self, parent): super(Input_Coeffs_UI, self).__init__(parent) self.eps = 1.e-6 # initialize tolerance value """ Intitialize the widget, consisting of: - top chkbox row - coefficient table - two bottom rows with action buttons """ self.bfont = QFont() self.bfont.setBold(True) self.bifont = QFont() self.bifont.setBold(True) self.bifont.setItalic(True) # q_icon_size = QSize(20, 20) # optional, size is derived from butEnable ####################################################################### # frmMain # # This frame contains all the buttons ####################################################################### # --------------------------------------------- # layHDisplay # # UI Elements for controlling the display # --------------------------------------------- self.butEnable = QPushButton(self) self.butEnable.setIcon(QIcon(':/circle-x.svg')) q_icon_size = self.butEnable.iconSize() # <- uncomment this for manual sizing self.butEnable.setIconSize(q_icon_size) self.butEnable.setCheckable(True) self.butEnable.setChecked(True) self.butEnable.setToolTip("<span>Show / hide filter coefficients in an editable table." " For high order systems, table display might be slow.</span>") fix_formats = ['Dec', 'Hex', 'Bin', 'CSD'] self.cmbFormat = QComboBox(self) model = self.cmbFormat.model() item = QtGui.QStandardItem('Float') item.setData('child', Qt.AccessibleDescriptionRole) model.appendRow(item) item = QtGui.QStandardItem('Fixp.:') item.setData('parent', Qt.AccessibleDescriptionRole) item.setData(0, QtGui.QFont.Bold) item.setFlags(item.flags() & ~Qt.ItemIsEnabled)# | Qt.ItemIsSelectable)) model.appendRow(item) for idx in range(len(fix_formats)): item = QtGui.QStandardItem(fix_formats[idx]) # item.setForeground(QtGui.QColor('red')) model.appendRow(item) self.cmbFormat.insertSeparator(1) qset_cmb_box(self.cmbFormat, 'float') self.cmbFormat.setToolTip('Set the display format.') self.cmbFormat.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.spnDigits = QSpinBox(self) self.spnDigits.setRange(0,16) self.spnDigits.setValue(params['FMT_ba']) self.spnDigits.setToolTip("Number of digits to display.") self.lblDigits = QLabel("Digits", self) self.lblDigits.setFont(self.bifont) self.cmbQFrmt = QComboBox(self) q_formats = [('Integer', 'qint' ), ('Norm. Frac.', 'qnfrac'), ('Fractional', 'qfrac')] for q in q_formats: self.cmbQFrmt.addItem(*q) self.lbl_W = QLabel("W = ", self) self.lbl_W.setFont(self.bifont) self.ledW = QLineEdit(self) self.ledW.setToolTip("Specify total wordlength.") self.ledW.setText("16") self.ledW.setMaxLength(2) # maximum of 2 digits self.ledW.setFixedWidth(30) # width of lineedit in points(?) layHDisplay = QHBoxLayout() layHDisplay.setAlignment(Qt.AlignLeft) layHDisplay.addWidget(self.butEnable) layHDisplay.addWidget(self.cmbFormat) layHDisplay.addWidget(self.spnDigits) layHDisplay.addWidget(self.lblDigits) layHDisplay.addWidget(self.cmbQFrmt) layHDisplay.addWidget(self.lbl_W) layHDisplay.addWidget(self.ledW) layHDisplay.addStretch() # ----------------------------------------------------------------- # layHButtonsCoeffs1 # # UI Elements for loading / storing / manipulating cells and rows # ----------------------------------------------------------------- self.cmbFilterType = QComboBox(self) self.cmbFilterType.setObjectName("comboFilterType") self.cmbFilterType.setToolTip("<span>Select between IIR and FIR filter for manual entry." "Changing the type reloads the filter from the filter dict.</span>") self.cmbFilterType.addItems(["FIR","IIR"]) self.cmbFilterType.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.butAddCells = QPushButton(self) self.butAddCells.setIcon(QIcon(':/row_insert_above.svg')) self.butAddCells.setIconSize(q_icon_size) self.butAddCells.setToolTip("<SPAN>Select cells to insert a new cell above each selected cell. " "Use <SHIFT> or <CTRL> to select multiple cells. " "When nothing is selected, add a row at the end.</SPAN>") self.butDelCells = QPushButton(self) self.butDelCells.setIcon(QIcon(':/row_delete.svg')) self.butDelCells.setIconSize(q_icon_size) self.butDelCells.setToolTip("<SPAN>Delete selected cell(s) from the table. " "Use <SHIFT> or <CTRL> to select multiple cells. " "When nothing is selected, delete the last row.</SPAN>") self.butSave = QPushButton(self) self.butSave.setIcon(QIcon(':/upload.svg')) self.butSave.setIconSize(q_icon_size) self.butSave.setToolTip("<span>Copy coefficient table to filter dict and update all plots and widgets.</span>") self.butLoad = QPushButton(self) self.butLoad.setIcon(QIcon(':/download.svg')) self.butLoad.setIconSize(q_icon_size) self.butLoad.setToolTip("Reload coefficient table from filter dict.") self.butClear = QPushButton(self) self.butClear.setIcon(QIcon(':/trash.svg')) self.butClear.setIconSize(q_icon_size) self.butClear.setToolTip("Clear all table entries.") self.butFromTable = QPushButton(self) self.butFromTable.setIconSize(q_icon_size) self.butToTable = QPushButton(self) self.butToTable.setIconSize(q_icon_size) self._set_load_save_icons() butSettingsClipboard = QPushButton(self) butSettingsClipboard.setIcon(QIcon(':/settings.svg')) butSettingsClipboard.setIconSize(q_icon_size) butSettingsClipboard.setToolTip("<span>Select CSV format and whether " "to copy to/from clipboard or file.</span>") layHButtonsCoeffs1 = QHBoxLayout() layHButtonsCoeffs1.addWidget(self.cmbFilterType) layHButtonsCoeffs1.addWidget(self.butAddCells) layHButtonsCoeffs1.addWidget(self.butDelCells) layHButtonsCoeffs1.addWidget(self.butClear) layHButtonsCoeffs1.addWidget(self.butSave) layHButtonsCoeffs1.addWidget(self.butLoad) layHButtonsCoeffs1.addWidget(self.butFromTable) layHButtonsCoeffs1.addWidget(self.butToTable) layHButtonsCoeffs1.addWidget(butSettingsClipboard) layHButtonsCoeffs1.addStretch() #---------------------------------------------------------------------- # layHButtonsCoeffs2 # # Eps / set zero settings # --------------------------------------------------------------------- self.butSetZero = QPushButton("= 0", self) self.butSetZero.setToolTip("<span>Set selected coefficients = 0 with a magnitude < ε. " "When nothing is selected, test the whole table.</span>") self.butSetZero.setIconSize(q_icon_size) lblEps = QLabel(self) lblEps.setText("<b><i>for b, a</i> <</b>") self.ledEps = QLineEdit(self) self.ledEps.setToolTip("Specify tolerance value.") layHButtonsCoeffs2 = QHBoxLayout() layHButtonsCoeffs2.addWidget(self.butSetZero) layHButtonsCoeffs2.addWidget(lblEps) layHButtonsCoeffs2.addWidget(self.ledEps) layHButtonsCoeffs2.addStretch() ####################################################################### # frmQSettings # # This frame contains all quantization settings ####################################################################### #------------------------------------------------------------------- # layHW_Scale # # QFormat and scale settings # --------------------------------------------------------------------- lbl_Q = QLabel("Q =", self) lbl_Q.setFont(self.bifont) self.ledWI = QLineEdit(self) self.ledWI.setToolTip("Specify number of integer bits.") self.ledWI.setText("0") self.ledWI.setMaxLength(2) # maximum of 2 digits self.ledWI.setFixedWidth(30) # width of lineedit in points(?) self.lblDot = QLabel(".", self) # class attribute, visibility is toggled self.lblDot.setFont(self.bfont) self.ledWF = QLineEdit(self) self.ledWF.setToolTip("Specify number of fractional bits.") self.ledWF.setText("15") self.ledWF.setMaxLength(2) # maximum of 2 digits # self.ledWF.setFixedWidth(30) # width of lineedit in points(?) self.ledWF.setMaximumWidth(30) self.lblScale = QLabel("<b><i>Scale</i> =</b>", self) self.ledScale = QLineEdit(self) self.ledScale.setToolTip("Set the scale for converting float to fixpoint representation.") self.ledScale.setText(str(1)) layHWI_WF = QHBoxLayout() layHWI_WF.addWidget(lbl_Q) layHWI_WF.addWidget(self.ledWI) layHWI_WF.addWidget(self.lblDot) layHWI_WF.addWidget(self.ledWF) layHWI_WF.addStretch() layHScale = QHBoxLayout() layHScale.addWidget(self.lblScale) layHScale.addWidget(self.ledScale) layHScale.addStretch() layHW_Scale = QHBoxLayout() layHW_Scale.addLayout(layHWI_WF) layHW_Scale.addLayout(layHScale) #------------------------------------------------------------------- # layGQOpt # # Quantization / Overflow / MSB / LSB settings # --------------------------------------------------------------------- lblQOvfl = QLabel("Ovfl.:", self) lblQOvfl.setFont(self.bifont) lblQuant = QLabel("Quant.:", self) lblQuant.setFont(self.bifont) self.cmbQOvfl = QComboBox(self) qOvfl = ['wrap', 'sat'] self.cmbQOvfl.addItems(qOvfl) qset_cmb_box(self.cmbQOvfl, 'sat') self.cmbQOvfl.setToolTip("Select overflow behaviour.") # ComboBox size is adjusted automatically to fit the longest element self.cmbQOvfl.setSizeAdjustPolicy(QComboBox.AdjustToContents) layHQOvflOpt = QHBoxLayout() layHQOvflOpt.addWidget(lblQOvfl) layHQOvflOpt.addWidget(self.cmbQOvfl) layHQOvflOpt.addStretch() self.cmbQuant = QComboBox(self) qQuant = ['none', 'round', 'fix', 'floor'] self.cmbQuant.addItems(qQuant) qset_cmb_box(self.cmbQuant, 'round') self.cmbQuant.setToolTip("Select the kind of quantization.") self.cmbQuant.setSizeAdjustPolicy(QComboBox.AdjustToContents) layHQuantOpt = QHBoxLayout() layHQuantOpt.addWidget(lblQuant) layHQuantOpt.addWidget(self.cmbQuant) layHQuantOpt.addStretch() self.butQuant = QPushButton(self) self.butQuant.setToolTip("<span>Quantize selected coefficients / " "whole table with specified settings.</span>") self.butQuant.setIcon(QIcon(':/quantize.svg')) self.butQuant.setIconSize(q_icon_size) self.butQuant.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) lblMSBtxt = QLabel(self) lblMSBtxt.setText("<b><i>MSB</i><sub>10</sub> =</b>") self.lblMSB = QLabel(self) layHMSB = QHBoxLayout() layHMSB.addWidget(lblMSBtxt) layHMSB.addWidget(self.lblMSB) layHMSB.addStretch() lblLSBtxt = QLabel(self) lblLSBtxt.setText("<b><i>LSB</i><sub>10</sub> =</b>") self.lblLSB = QLabel(self) # layHLSB = QHBoxLayout() layHLSB.addWidget(lblLSBtxt) layHLSB.addWidget(self.lblLSB) layHLSB.addStretch() layGQOpt = QGridLayout() layGQOpt.addLayout(layHQOvflOpt,0,0) layGQOpt.addLayout(layHQuantOpt, 0,1) layGQOpt.addWidget(self.butQuant, 0, 2, Qt.AlignCenter) layGQOpt.addLayout(layHMSB,1,0) layGQOpt.addLayout(layHLSB,1,1) #------------------------------------------------------------------- # Display MAX # --------------------------------------------------------------------- lblMAXtxt = QLabel(self) lblMAXtxt.setText("<b><i>Max =</i></b>") self.lblMAX = QLabel(self) layHCoeffs_MAX = QHBoxLayout() layHCoeffs_MAX.addWidget(lblMAXtxt) layHCoeffs_MAX.addWidget(self.lblMAX) layHCoeffs_MAX.addStretch() ####################################################################### # Now put all the coefficient HBoxes into frmQSettings # --------------------------------------------------------------------- layVButtonsQ = QVBoxLayout() layVButtonsQ.addLayout(layHW_Scale) layVButtonsQ.addLayout(layGQOpt) layVButtonsQ.addLayout(layHCoeffs_MAX) layVButtonsQ.setContentsMargins(0,5,0,0) # This frame encompasses all Quantization Settings self.frmQSettings = QFrame(self) self.frmQSettings.setLayout(layVButtonsQ) # ######################## Main UI Layout ############################ # layout for frame (UI widget) layVMainF = QVBoxLayout() layVMainF.addLayout(layHDisplay) layVMainF.addLayout(layHButtonsCoeffs1) layVMainF.addLayout(layHButtonsCoeffs2) layVMainF.addWidget(self.frmQSettings) # This frame encompasses all UI elements frmMain = QFrame(self) frmMain.setLayout(layVMainF) layVMain = QVBoxLayout() layVMain.setAlignment(Qt.AlignTop) # this affects only the first widget (intended here) layVMain.addWidget(frmMain) layVMain.setContentsMargins(*params['wdg_margins']) self.setLayout(layVMain) ####################################################################### #--- set initial values from dict ------------ self.spnDigits.setValue(params['FMT_ba']) self.ledEps.setText(str(self.eps)) #---------------------------------------------------------------------- # LOCAL SIGNALS & SLOTs #---------------------------------------------------------------------- butSettingsClipboard.clicked.connect(self._copy_options) self.sig_rx.connect(self._set_load_save_icons)