def __init__(self): super().__init__() self.setWindowTitle('Sniff with scapy') self.lw_packet = Qt.QListWidget() self.cb_log = Qt.QCheckBox('Write log') self.cb_log.setChecked(True) self.pb_clear = Qt.QPushButton('Clear') self.pb_clear.clicked.connect(self.lw_packet.clear) self.cb_autoscroll = Qt.QCheckBox('Autoscroll') layout = Qt.QHBoxLayout() layout.addWidget(self.cb_log) layout.addWidget(self.cb_autoscroll) layout.addStretch() layout.addWidget(self.pb_clear) main_layout = Qt.QVBoxLayout() main_layout.addLayout(layout) main_layout.addWidget(self.lw_packet) central_widget = Qt.QWidget() central_widget.setLayout(main_layout) self.setCentralWidget(central_widget) self.thread = SniffThread() self.thread.about_new_data.connect(self._append_new_item) self.thread.start()
def __init__(self, plugin): DefaultConfigWidget.__init__(self, plugin) c = plugin_prefs[STORE_NAME] other_group_box = QGroupBox('Other options', self) self.l.addWidget(other_group_box, self.l.rowCount(), 0, 1, 2) other_group_box_layout = QGridLayout() other_group_box.setLayout(other_group_box_layout) # Guess Series guess_series_label = QLabel( 'Guess Series and Series Index from Title:', self) guess_series_label.setToolTip('DNB only rarely provides data about a book\'s series.\n' 'This plugin can try to extract series and series_index from the book title.\n') other_group_box_layout.addWidget(guess_series_label, 0, 0, 1, 1) self.guess_series_checkbox = QtGui.QCheckBox(self) self.guess_series_checkbox.setChecked( c.get(KEY_GUESS_SERIES, DEFAULT_STORE_VALUES[KEY_GUESS_SERIES])) other_group_box_layout.addWidget( self.guess_series_checkbox, 0, 1, 1, 1) # Append Edition to Title append_edition_to_title_label = QLabel( 'Append Edition to Title:', self) append_edition_to_title_label.setToolTip('For some books DNB has information about the edition.\n' 'This plugin can fetch this information and append it to the book\'s title,\n' 'e.g. "Mord am Tegernsee : Ein Bayern-Krimi : 2. Aufl.".\n' 'Of course this only works reliable if you search for a book with a known unique identifier such as dnb-idn or ISBN.') other_group_box_layout.addWidget( append_edition_to_title_label, 1, 0, 1, 1) self.append_edition_to_title_checkbox = QtGui.QCheckBox(self) self.append_edition_to_title_checkbox.setChecked(c.get( KEY_APPEND_EDITION_TO_TITLE, DEFAULT_STORE_VALUES[KEY_APPEND_EDITION_TO_TITLE])) other_group_box_layout.addWidget( self.append_edition_to_title_checkbox, 1, 1, 1, 1) # Fetch Subjects fetch_subjects_label = QLabel('Fetch Subjects:', self) fetch_subjects_label.setToolTip('DNB provides several types of subjects:\n' ' - Standardized subjects according to the GND\n' ' - Subjects delivered by the publisher\n' 'You can choose which ones to fetch.') other_group_box_layout.addWidget(fetch_subjects_label, 2, 0, 1, 1) self.fetch_subjects_radios_group = QtGui.QButtonGroup(other_group_box) titles = ['only GND subjects', 'GND subjects if available, otherwise non-GND subjects', 'GND and non-GND subjects', 'non-GND subjects if available, otherwise GND subjects', 'only non-GND subjects', 'none'] self.fetch_subjects_radios = [ QtGui.QRadioButton(title) for title in titles] for i, radio in enumerate(self.fetch_subjects_radios): if i == c.get(KEY_FETCH_SUBJECTS, DEFAULT_STORE_VALUES[KEY_FETCH_SUBJECTS]): radio.setChecked(True) self.fetch_subjects_radios_group.addButton(radio, i) other_group_box_layout.addWidget(radio, 2 + i, 1, 1, 1)
def setupUi(self, Form): # noqa: N802, N803 """Set up the plugin widget UI.""" super(PluginWidget, self).setupUi(Form) try: from PyQt5 import Qt as QtGui from PyQt5 import QtCore except ImportError: from PyQt4 import QtCore from PyQt4 import QtGui rows = self.gridLayout.rowCount() - 1 spacer = self.gridLayout.itemAtPosition(rows, 0) self.gridLayout.removeItem(spacer) self.opt_kepub_hyphenate = QtGui.QCheckBox(Form) self.opt_kepub_hyphenate.setObjectName( "opt_kepub_hyphenate") # noqa: F821 self.opt_kepub_hyphenate.setText(_("Hyphenate Files")) # noqa: F821 self.gridLayout.addWidget(self.opt_kepub_hyphenate, rows, 0, 1, 1) self.opt_kepub_disable_hyphenation = QtGui.QCheckBox(Form) self.opt_kepub_disable_hyphenation.setObjectName( "opt_kepub_disable_hyphenation" # noqa: F821 ) self.opt_kepub_disable_hyphenation.setText( _("Disable hyphenation") # noqa: F821 ) self.gridLayout.addWidget(self.opt_kepub_disable_hyphenation, rows, 1, 1, 1) rows = rows + 1 self.opt_kepub_clean_markup = QtGui.QCheckBox(Form) self.opt_kepub_clean_markup.setObjectName( "opt_kepub_clean_markup" # noqa: F821 ) self.opt_kepub_clean_markup.setText( _("Clean up ePub markup")) # noqa: F821 self.gridLayout.addWidget(self.opt_kepub_clean_markup, rows, 0, 1, 1) rows = rows + 1 # Next options here self.gridLayout.addItem(spacer, rows, 0, 1, 1) # Copy from calibre.gui2.convert.epub_output_ui.Ui_Form to make the # new additions work QtCore.QMetaObject.connectSlotsByName(Form)
def __init__(self, widget, name, layout, row): toggle = Qt.QCheckBox(name) layout.addWidget(toggle, row, 0) toggle_update = widget.subscribe(name + '.enabled', callback=toggle.setChecked) toggle.toggled.connect(toggle_update) self.toggle = toggle slider = Qt.QSlider(Qt.Qt.Horizontal) layout.addWidget(slider, row, 1) slider.setRange(0, 255) slider.setSingleStep(1) slider.setPageStep(5) slider.setValue(0) slider.setMinimumWidth(255) slider.setMaximumWidth(255) spinbox = Qt.QSpinBox() layout.addWidget(spinbox, row, 2) spinbox.setRange(0, 255) spinbox.setSingleStep(1) spinbox.setValue(0) spinbox.setSizePolicy(Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Fixed) self.spinbox = spinbox self.update_spx = widget.subscribe(name + '.intensity', callback=slider.setValue) # note that giving slider.setValue as the callback will work fine. That will cause a slider.valueChanged # signal, which due to the slider_changed() function will cause the spinbox to be updated too. # It also calls update_spx(), which seems like an odd thing to fire off in response to getting # an update *from* the spectra x. But update_spx is smart enough to not actually do anything in # response to trying to update a value to the value it already is... slider.valueChanged.connect(self.slider_changed) spinbox.valueChanged.connect(slider.setValue)
def add_groupbox_goodreads_plugin_integration(self): gb = self.gb_integration = self.add_groupbox('Goodreads Plugin Integration') # A setting to enable/disable the integration entirely. self.goodreads_enabled = qt.QCheckBox() self.goodreads_enabled.setChecked(plugin_prefs.get(KEY_INTEGRATION_ENABLED)) gb.l.addRow('Enabled', self.goodreads_enabled, description = docmd2html(''' Whether to enable the integration with the Goodreads plugin (if present). If this is enabled, this plugin will attempt to grab any new goodreads ids found by the Goodreads plugin, and will then lookup tags for these. This allows getting tags for books in the first metadata download. If this is not enabled, this plugin will only get tags for books that already have a goodreads id when the metadata download starts, based on this goodreads id. This means that a second metadata download will be required if the goodreads id is added or changed in a download. ''')) # A setting to determine how long to wait for the base Goodreads plugin to get results. self.goodreads_timeout = qt.QSpinBox() self.goodreads_timeout.setMinimum(0.1) self.goodreads_timeout.setValue(plugin_prefs.get(KEY_INTEGRATION_TIMEOUT)) gb.l.addRow('Timeout', self.goodreads_timeout, description = docmd2html(''' The amount of time (in seconds) to wait for the base Goodreads plugin to provide us with goodreads id(s). If the Goodreads plugin is still running after this time, we will continue with any ids it has provided us with already. If we've not received any ids from it, we will continue as if integration were not enabled. '''))
def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(518, 353) self.verticalLayout = QtGui.QVBoxLayout(Form) self.verticalLayout.setSizeConstraint( QtGui.QLayout.SetDefaultConstraint) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.label = QtGui.QLabel(Form) self.label.setWordWrap(True) self.label.setObjectName(_fromUtf8("label")) self.verticalLayout.addWidget(self.label) self.hboxlayout = QtGui.QHBoxLayout() self.hboxlayout.setObjectName(_fromUtf8("hboxlayout")) self.opt_wordconv_exe_path = QtGui.QLineEdit(Form) self.opt_wordconv_exe_path.setObjectName( _fromUtf8("opt_wordconv_exe_path")) self.hboxlayout.addWidget(self.opt_wordconv_exe_path) self.fileChoose = QtGui.QPushButton(Form) self.fileChoose.setObjectName(_fromUtf8("fileChoose")) self.fileChoose.clicked.connect(self.fileSearch) self.hboxlayout.addWidget(self.fileChoose) self.verticalLayout.addLayout(self.hboxlayout) self.opt_docx_no_cover = QtGui.QCheckBox(Form) self.opt_docx_no_cover.setObjectName(_fromUtf8("opt_docx_no_cover")) self.verticalLayout.addWidget(self.opt_docx_no_cover) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def setup_ui(self) -> None: layout = Qt.QHBoxLayout(self) layout.setObjectName('MiscToolbar.setup_ui.layout') layout.setContentsMargins(0, 0, 0, 0) self.reload_script_button = Qt.QPushButton(self) self.reload_script_button.setText('Reload Script') layout.addWidget(self.reload_script_button) self.save_button = Qt.QPushButton(self) self.save_button.setText('Save') layout.addWidget(self.save_button) self.autosave_checkbox = Qt.QCheckBox(self) self.autosave_checkbox.setText('Autosave') layout.addWidget(self.autosave_checkbox) self.keep_on_top_checkbox = Qt.QCheckBox(self) self.keep_on_top_checkbox.setText('Keep on Top') self.keep_on_top_checkbox.setEnabled(False) layout.addWidget(self.keep_on_top_checkbox) self.copy_frame_button = Qt.QPushButton(self) self.copy_frame_button.setText('Copy Frame') layout.addWidget(self.copy_frame_button) self.save_frame_as_button = Qt.QPushButton(self) self.save_frame_as_button.setText('Save Frame as') layout.addWidget(self.save_frame_as_button) save_template_label = Qt.QLabel(self) save_template_label.setObjectName( 'MiscToolbar.setup_ui.save_template_label') save_template_label.setText('Save file name template:') layout.addWidget(save_template_label) self.save_template_lineedit = Qt.QLineEdit(self) self.save_template_lineedit.setToolTip( r'Use {script_name} and {frame} as placeholders.') layout.addWidget(self.save_template_lineedit) layout.addStretch() layout.addStretch() self.show_debug_checkbox = Qt.QCheckBox(self) self.show_debug_checkbox.setText('Show Debug Toolbar') layout.addWidget(self.show_debug_checkbox)
def setup_ui(self) -> None: layout = Qt.QHBoxLayout(self) layout.setObjectName('MiscToolbar.setup_ui.layout') layout.setContentsMargins(0, 0, 0, 0) self.reload_script_button = Qt.QPushButton(self) self.reload_script_button.setText('Reload Script') layout.addWidget(self.reload_script_button) self.save_button = Qt.QPushButton(self) self.save_button.setText('Save') layout.addWidget(self.save_button) self.keep_on_top_checkbox = Qt.QCheckBox(self) self.keep_on_top_checkbox.setText('Keep on Top') self.keep_on_top_checkbox.setEnabled(False) layout.addWidget(self.keep_on_top_checkbox) self.copy_frame_button = Qt.QPushButton(self) self.copy_frame_button.setText('Copy Frame') layout.addWidget(self.copy_frame_button) self.save_frame_as_button = Qt.QPushButton(self) self.save_frame_as_button.setText('Save Frame as') layout.addWidget(self.save_frame_as_button) save_template_label = Qt.QLabel(self) save_template_label.setObjectName( 'MiscToolbar.setup_ui.save_template_label') save_template_label.setText('Save file name template:') layout.addWidget(save_template_label) self.save_template_lineedit = Qt.QLineEdit(self) self.save_template_lineedit.setToolTip( r'Available placeholders: {format}, {fps_den}, {fps_num}, {frame},' r' {height}, {index}, {matrix}, {primaries}, {range},' r' {script_name}, {total_frames}, {transfer}, {width}.' r' Frame props can be accessed as well using their names.') layout.addWidget(self.save_template_lineedit) layout.addStretch() layout.addStretch() self.show_debug_checkbox = Qt.QCheckBox(self) self.show_debug_checkbox.setText('Show Debug Toolbar') layout.addWidget(self.show_debug_checkbox)
def setup_ui(self) -> None: self.setVisible(False) layout = Qt.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) self.seek_n_frames_b_button = Qt.QPushButton(self) self.seek_n_frames_b_button.setText('⏮') self.seek_n_frames_b_button.setToolTip('Seek N Frames Backwards') layout.addWidget(self.seek_n_frames_b_button) self.seek_to_prev_button = Qt.QPushButton(self) self.seek_to_prev_button.setText('⏪') self.seek_to_prev_button.setToolTip('Seek 1 Frame Backwards') layout.addWidget(self.seek_to_prev_button) self.play_pause_button = Qt.QPushButton(self) self.play_pause_button.setText('⏯') self.play_pause_button.setToolTip('Play/Pause') self.play_pause_button.setCheckable(True) layout.addWidget(self.play_pause_button) self.seek_to_next_button = Qt.QPushButton(self) self.seek_to_next_button.setText('⏩') self.seek_to_next_button.setToolTip('Seek 1 Frame Forward') layout.addWidget(self.seek_to_next_button) self.seek_n_frames_f_button = Qt.QPushButton(self) self.seek_n_frames_f_button.setText('⏭') self.seek_n_frames_f_button.setToolTip('Seek N Frames Forward') layout.addWidget(self.seek_n_frames_f_button) self.seek_frame_spinbox = Qt.QSpinBox(self) self.seek_frame_spinbox.setMinimum(1) self.seek_frame_spinbox.setToolTip('Seek N Frames Step') layout.addWidget(self.seek_frame_spinbox) self.seek_time_spinbox = Qt.QTimeEdit(self) self.seek_time_spinbox.setDisplayFormat('H:mm:ss.zzz') self.seek_time_spinbox.setButtonSymbols(Qt.QTimeEdit.NoButtons) layout.addWidget(self.seek_time_spinbox) self.fps_spinbox = Qt.QDoubleSpinBox(self) self.fps_spinbox.setRange(1.0, 9999.0) self.fps_spinbox.setDecimals(3) self.fps_spinbox.setSuffix(' fps') layout.addWidget(self.fps_spinbox) self.fps_unlimited_checkbox = Qt.QCheckBox(self) self.fps_unlimited_checkbox.setText('Unlimited FPS') layout.addWidget(self.fps_unlimited_checkbox) layout.addStretch() # switch button for main toolbar self.toggle_button.setText('Playback')
def setupUi(self, Form): super(PluginWidget, self).setupUi(Form) try: from PyQt5 import Qt as QtGui from PyQt5 import QtCore except ImportError: from PyQt4 import QtCore from PyQt4 import QtGui rows = self.gridLayout.rowCount() - 1 spacer = self.gridLayout.itemAtPosition(rows, 0) self.gridLayout.removeItem(spacer) self.opt_kepub_hyphenate = QtGui.QCheckBox(Form) self.opt_kepub_hyphenate.setObjectName(unicode("opt_kepub_hyphenate")) self.opt_kepub_hyphenate.setText(_("Hyphenate Files")) self.gridLayout.addWidget(self.opt_kepub_hyphenate, rows, 0, 1, 1) self.opt_kepub_clean_markup = QtGui.QCheckBox(Form) self.opt_kepub_clean_markup.setObjectName( unicode("opt_kepub_clean_markup")) self.opt_kepub_clean_markup.setText(_("Clean up ePub markup")) self.gridLayout.addWidget(self.opt_kepub_clean_markup, rows, 1, 1, 1) rows = rows + 1 self.opt_kepub_replace_lang = QtGui.QCheckBox(Form) self.opt_kepub_replace_lang.setObjectName( unicode("opt_kepub_replace_lang")) self.opt_kepub_replace_lang.setText(_("Replace Content Language Code")) self.gridLayout.addWidget(self.opt_kepub_replace_lang, rows, 0, 1, 1) # Next option here rows = rows + 1 # Next options here self.gridLayout.addItem(spacer, rows, 0, 1, 1) # Copy from calibre.gui2.convert.epub_output_ui.Ui_Form to make the new additions work QtCore.QMetaObject.connectSlotsByName(Form)
def setup_ui(self) -> None: self.setVisible(False) layout = Qt.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) self.reload_script_button = Qt.QPushButton(self) self.reload_script_button.setText('Reload Script') layout.addWidget(self.reload_script_button) self.save_button = Qt.QPushButton(self) self.save_button.setText('Save') layout.addWidget(self.save_button) self.autosave_checkbox = Qt.QCheckBox(self) self.autosave_checkbox.setText('Autosave') layout.addWidget(self.autosave_checkbox) self.keep_on_top_checkbox = Qt.QCheckBox(self) self.keep_on_top_checkbox.setText('Keep on Top') self.keep_on_top_checkbox.setEnabled(False) layout.addWidget(self.keep_on_top_checkbox) save_template_label = Qt.QLabel(self) save_template_label.setText('Save file name template:') layout.addWidget(save_template_label) self.save_template_lineedit = Qt.QLineEdit(self) self.save_template_lineedit.setToolTip( r'Use {script_name} and {frame} as placeholders.') layout.addWidget(self.save_template_lineedit) layout.addStretch() layout.addStretch() self.show_debug_checkbox = Qt.QCheckBox(self) self.show_debug_checkbox.setText('Show Debug Toolbar') layout.addWidget(self.show_debug_checkbox) # switch button for main layout self.toggle_button.setText('Misc')
def _addSwitchItem(self, parent, title, setting): """ Add check box item. Arguments: parent (QWidget): Parent widget. title (str): Text label. setting (str): Preference item's identifier. """ editor = Q.QCheckBox(title, parent) _setObjName(editor, "check", setting) row = self._layout(parent).rowCount() self._layout(parent).addWidget(editor, row, 0, 1, 2) self.widgets[setting] = editor
def _display(cls, icon, parent, title, text, buttons, defaultButton, **kwargs): """ Show message with specified icon box. """ mbdisabled = False resbtn = Q.QMessageBox.NoButton notshow = kwargs['noshow'] if 'noshow' in kwargs else None prefmgr = kwargs['prefmgr'] if 'noshow' in kwargs else None if notshow is not None and prefmgr is not None: value = prefmgr.bool_value("msgbox_" + notshow, True) if not value: mbdisabled = True if mbdisabled: resbtn = defaultButton btntry = 1 while (resbtn == Q.QMessageBox.NoButton and btntry <= Q.QMessageBox.RestoreDefaults): if buttons & btntry == btntry: resbtn = btntry btntry = btntry << 1 else: msgbox = MessageBox(icon, title, text, buttons, parent) msgbox.setDefaultButton(defaultButton) if notshow is not None and prefmgr is not None: msg = translate("MessageBox", "Don't show this message anymore.") msgbox.setCheckBox(Q.QCheckBox(msg, msgbox)) propMap = {} for p in xrange(msgbox.metaObject().propertyCount()): propMap[msgbox.metaObject().property(p).name()] = 0 for prop in kwargs: if prop in propMap: msgbox.setProperty(prop, kwargs[prop]) ovrcursor = Q.QApplication.overrideCursor() is not None if ovrcursor: Q.QApplication.setOverrideCursor(Q.Qt.ArrowCursor) resbtn = msgbox.exec_() if ovrcursor: Q.QApplication.restoreOverrideCursor() if prefmgr is not None and msgbox.checkBox() is not None and \ msgbox.checkBox().isChecked(): prefmgr.setValue("msgbox_" + notshow, False) return resbtn
def setup_ui(self) -> None: self.setVisible(True) layout = Qt.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) self.outputs_combobox = ComboBox[Output](self) self.outputs_combobox.setEditable(True) self.outputs_combobox.setInsertPolicy(Qt.QComboBox.InsertAtCurrent) self.outputs_combobox.setDuplicatesEnabled(True) self.outputs_combobox.setSizeAdjustPolicy( Qt.QComboBox.AdjustToContents) layout.addWidget(self.outputs_combobox) self.frame_control = FrameEdit[Frame](self) self.frame_control.setKeyboardTracking(False) layout.addWidget(self.frame_control) self.copy_frame_button = Qt.QToolButton(self) self.copy_frame_button.setText('⎘') layout.addWidget(self.copy_frame_button) self.time_control = TimeEdit[Time](self) self.time_control.setKeyboardTracking(False) layout.addWidget(self.time_control) self.copy_timestamp_button = Qt.QToolButton(self) self.copy_timestamp_button.setText('⎘') layout.addWidget(self.copy_timestamp_button) self.sync_outputs_checkbox = Qt.QCheckBox(self) self.sync_outputs_checkbox.setText('Sync Outputs') layout.addWidget(self.sync_outputs_checkbox) self.zoom_combobox = ComboBox[float](self) self.zoom_combobox.setMinimumContentsLength(4) layout.addWidget(self.zoom_combobox) self.save_as_button = Qt.QPushButton(self) self.save_as_button.setText('Save Frame as') layout.addWidget(self.save_as_button) self.switch_timeline_mode_button = Qt.QPushButton(self) self.switch_timeline_mode_button.setText('Switch Timeline Mode') layout.addWidget(self.switch_timeline_mode_button) layout.addStretch() self.toggle_button.setVisible(False)
def make_bool_widget(self, prop): widget = Qt.QCheckBox() update = self.subscribe(self.PROPERTY_ROOT + prop, callback=widget.setChecked) if update is None: raise TypeError('{} is not a writable property!'.format(prop)) def changed(value): try: update(value) except rpc_client.RPCError as e: if e.args[0].find('NOTWRITABLE') != -1: error = "Given the camera state, {} can't be changed.".format(prop) else: error = 'Could not set {} ({}).'.format(prop, e.args[0]) Qt.QMessageBox.warning(self, 'Invalid Value', error) widget.toggled.connect(changed) return widget
def make_bool_widget(self, rppath, pt): widget = Qt.QCheckBox() ppath = self.PROPERTY_ROOT + rppath update = self.subscribe(ppath, callback=widget.setChecked) if update is None: raise TypeError('{} is not a writable property!'.format(ppath)) def gui_changed(value): try: update(value) except rpc_client.RPCError as e: error = 'Could not set {} ({}).'.format(ppath, e.args[0]) Qt.QMessageBox.warning(self, 'Invalid Value', error) widget.toggled.connect(gui_changed) return widget
def __init__(self, parent, mode): super(ColorMapSettingsView, self).__init__(parent) self.max_value = 100.0 self.min_value = 0.0 self.currentData = mode # Initiation of button / lineedit / label widgets self.button_update_lookup_table = Qt.QPushButton('Activate color map') self.button_update_lookup_table.clicked.connect( self.adaptColormapMinMax) self.label_min_value = Qt.QLabel(self) self.label_min_value.setText('Min value (yellow):') self.label_min_value.setFixedWidth(125) self.label_max_value = Qt.QLabel(self) self.label_max_value.setText('Max value (red):') self.label_max_value.setFixedWidth(125) self.lineedit_min_value = Qt.QLineEdit(self) self.lineedit_min_value.setText(str(self.min_value)) self.lineedit_max_value = Qt.QLineEdit(self) self.lineedit_max_value.setText(str(self.max_value)) self.checkbox_scalar_bar = Qt.QCheckBox("Show scalar bar", self) self.checkbox_scalar_bar.setChecked(False) self.checkbox_scalar_bar.stateChanged.connect( self.functionCheckboxScalarBar) # Boxlayout self.frame = Qt.QFrame() self.vl = Qt.QVBoxLayout() self.frame.setLayout(self.vl) self.setCentralWidget(self.frame) self.hl_min_value = Qt.QHBoxLayout() self.hl_min_value.addWidget(self.label_min_value) self.hl_min_value.addWidget(self.lineedit_min_value) self.hl_max_value = Qt.QHBoxLayout() self.hl_max_value.addWidget(self.label_max_value) self.hl_max_value.addWidget(self.lineedit_max_value) self.vl.addLayout(self.hl_min_value) self.vl.addLayout(self.hl_max_value) self.vl.addWidget(self.checkbox_scalar_bar) self.vl.addWidget(self.button_update_lookup_table)
def make_bool_widget(self, property): widget = Qt.QCheckBox() update = self.subscribe(property, callback=widget.setChecked) if update is None: widget.setEnabled(False) else: def gui_changed(value): try: update(value) except rpc_client.RPCError as e: error = 'Could not set {} ({}).'.format( property, e.args[0]) Qt.QMessageBox.warning(self, 'Invalid Value', error) widget.toggled.connect(gui_changed) return widget
def init_widget(self): self.widget = Qt.QGroupBox(self.name) layout = Qt.QHBoxLayout() self.widget.setLayout(layout) self.label = Qt.QLabel() layout.addWidget(self.label) self.draw = _add_button(layout, 'Draw Spline', self._handle_spline_drawing) self.draw.setEnabled(True) Qt.QShortcut(Qt.Qt.Key_D, self.widget, self._handle_spline_drawing, context=Qt.Qt.ApplicationShortcut) self.show_spline = Qt.QCheckBox('Show Splines') self.show_spline.setChecked(True) self.show_spline.toggled.connect(self.toggle_show_spline) layout.addWidget(self.show_spline)
def setupUi(self, Form): super(PluginWidget, self).setupUi(Form) rows = self.gridLayout.rowCount() - 1 spacer = self.gridLayout.itemAtPosition(rows, 0) self.gridLayout.removeItem(spacer) self.opt_strip_kobo_spans = QtGui.QCheckBox(Form) self.opt_strip_kobo_spans.setObjectName( unicode("opt_strip_kobo_spans")) self.opt_strip_kobo_spans.setText(_("Strip Kobo spans")) self.gridLayout.addWidget(self.opt_strip_kobo_spans, rows, 0, 1, 1) rows = rows + 1 # Next options here self.gridLayout.addItem(spacer, rows, 0, 1, 1) # Copy from calibre.gui2.convert.epub_output_ui.Ui_Form to make the new additions work QtCore.QMetaObject.connectSlotsByName(Form)
def __init__(self, ris_widget, parent=None): self.painter_item = layer_stack_painter_item.LayerStackPainterItem( ris_widget.image_scene.layer_stack_item) super().__init__(parent) self.setWindowTitle('Layer Painter') widget_layout = Qt.QVBoxLayout() self.left_click_box = Qt.QCheckBox('Left click draws (alt-left pans)') widget_layout.addWidget(self.left_click_box) self.left_click_box.stateChanged.connect(self._on_left_click_changed) self.setLayout(widget_layout) self.brush_size = BrushSizeEdit(widget_layout, 'Brush size') self.brush_val = ImageValEdit(widget_layout, 'Right-click') self.alt_brush_val = ImageValEdit(widget_layout, 'Shift-right-click') widget_layout.addStretch() self.painter_item.target_image_changed.connect( self._on_target_image_changed) self.brush_size.value_changed.connect(self._on_brush_changed) self.brush_size.value_changed.connect(self._on_alt_brush_changed) self.brush_val.value_changed.connect(self._on_brush_changed) self.alt_brush_val.value_changed.connect(self._on_alt_brush_changed) self._on_target_image_changed()
def __init__(self, work: Work): super().__init__() self.indicator_gif = qt.QMovie('busy-indicator.gif') self.indicator_gif.jumpToFrame(0) self.indicator_label = qt.QLabel() self.indicator_label.setMovie(self.indicator_gif) self.indicator_label.setAlignment(qt.Qt.AlignCenter) self.progress_label = qt.QLabel() self.progress_label.setAlignment(qt.Qt.AlignCenter) self.message_label = qt.QLabel() self.message_label.setAlignment(qt.Qt.AlignCenter) self.pause_button = qt.QPushButton() self.pause_button.setText('Pause') self.pause_button.clicked.connect(self.toggle_pause) self.close_checkbox = qt.QCheckBox() self.close_checkbox.setText('Close after completion') self.close_checkbox.setChecked(True) layout = qt.QVBoxLayout() # layout.setAlignment(qt.qt.AlignCenter) layout.addWidget(self.indicator_label) layout.addWidget(self.progress_label) layout.addWidget(self.message_label) layout.addWidget(self.close_checkbox) layout.addWidget(self.pause_button) self.setLayout(layout) self.work_thread = WorkThread(work) self.work_thread.update_message.connect(self.update_message) self.work_thread.update_progress.connect(self.update_progress) self.work_thread.started.connect(self.started) self.work_thread.finished.connect(self.finished) self.fade = None
def initUI(self): # Add a first QwtPlot to the UI: #self.qplt_mag = Qwt.QwtPlot() self.qplt_mag = pg.PlotWidget() self.qplt_mag.setTitle('Magnitude response') #self.qplt_mag.setCanvasBackground(Qt.Qt.white) #self.qplt_mag.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLog10ScaleEngine()) self.qplt_mag.getPlotItem().setLogMode(x=True) #print('DisplayTransferFunctionWindow: initUI(): first plot widget created') # plot_grid = Qwt.QwtPlotGrid() # plot_grid.setMajPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) # plot_grid.attach(self.qplt_mag) self.qplt_mag.showGrid(x=True, y=True) self.colors_order = [ [0, 114, 189], [217, 83, 25], [237, 177, 32], [126, 47, 142], [119, 172, 48], [77, 190, 238], [162, 20, 47], ] # Add a second QwtPlot to the UI: self.qplt_phase = pg.PlotWidget() self.qplt_phase.setTitle('Phase response') #self.qplt_phase.setCanvasBackground(Qt.Qt.white) #self.qplt_phase.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLog10ScaleEngine()) self.qplt_phase.getPlotItem().setLogMode(x=True) #print('DisplayTransferFunctionWindow: initUI(): 2nd plot widget created') # plot_grid = Qwt.QwtPlotGrid() # plot_grid.setMajPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) # plot_grid.attach(self.qplt_phase) self.qplt_phase.showGrid(x=True, y=True) # create the lists to hold the curve objects as they get added to the plots: self.curve_mag_list = [] self.curve_phase_list = [] ###################################################################### # Controls to adjust the model ###################################################################### # Units select units_label = Qt.QLabel('Units:') self.qcombo_units = Qt.QComboBox() self.qcombo_units.addItems([ 'dB', 'Linear', 'real part', 'imag part', 'Ohms, 50*Vin/Vout', 'Ohms, shunt DUT, 50 ohms probe', 'Ohms, Shunt DUT, high-Z probe + Series source impedance' ]) self.qcombo_units.setCurrentIndex(0) # self.qcombo_units.changeEvent.connect(self.updateGraph) self.qcombo_units.currentIndexChanged.connect(self.updateGraph) self.qlabel_SeriesImpedance = Qt.QLabel('Series Impedance [Ohms]:') self.qedit_SeriesImpedance = Qt.QLineEdit('100e3') self.qedit_SeriesImpedance.editingFinished.connect(self.updateGraph) self.qchk_display_model = Qt.QCheckBox('Display model') self.qchk_display_model.setChecked(False) self.qchk_DDCFilter = Qt.QCheckBox('DDC sinc filter') self.qchk_DDCFilter.clicked.connect(self.updateGraph) self.qradio_signp = Qt.QRadioButton('+ Sign') self.qradio_signp.setChecked(True) self.qradio_signn = Qt.QRadioButton('- Sign') button_group = Qt.QButtonGroup() button_group.addButton(self.qradio_signp) button_group.addButton(self.qradio_signn) self.qradio_signp.clicked.connect(self.updateGraph) self.qradio_signn.clicked.connect(self.updateGraph) # set the default DC gain to the value of the transfer function at the lowest frequency: self.qlabel_k = Qt.QLabel('DC Gain [dB]') self.qedit_k = Qt.QLineEdit(str(0)) self.qedit_k.setMaximumWidth(60) self.qedit_k.textChanged.connect(self.updateGraph) self.qlabel_f1 = Qt.QLabel('1st order poles') self.qedit_f1 = Qt.QLineEdit('20e3,600e3') self.qedit_f1.setMaximumWidth(120) self.qedit_f1.textChanged.connect(self.updateGraph) self.qlabel_f0 = Qt.QLabel('2nd order poles') self.qedit_f0 = Qt.QLineEdit('1.5e6') self.qedit_f0.setMaximumWidth(120) self.qedit_f0.textChanged.connect(self.updateGraph) self.qlabel_zeta = Qt.QLabel('zeta') self.qedit_zeta = Qt.QLineEdit('0.1') self.qedit_zeta.setMaximumWidth(120) self.qedit_zeta.textChanged.connect(self.updateGraph) self.qlabel_T = Qt.QLabel('Pure delay') self.qedit_T = Qt.QLineEdit('570e-9') self.qedit_T.setMaximumWidth(60) self.qedit_T.textChanged.connect(self.updateGraph) self.qchk_controller = Qt.QCheckBox('Closed-loop prediction') self.qchk_controller.clicked.connect(self.updateGraph) self.qlabel_pgain = Qt.QLabel('P gain [dB]') self.qedit_pgain = Qt.QLineEdit('-100') self.qedit_pgain.setMaximumWidth(60) self.qedit_pgain.textChanged.connect(self.updateGraph) self.qlabel_icorner = Qt.QLabel('I corner [Hz]') self.qedit_icorner = Qt.QLineEdit('0') self.qedit_icorner.setMaximumWidth(60) self.qedit_icorner.textChanged.connect(self.updateGraph) self.qedit_comment = Qt.QTextEdit('') # self.qedit_comment.setMaximumWidth(80) #self.qedit_comment.textChanged.connect(self.updateGraph) # Put all the widgets into a grid layout grid = Qt.QGridLayout() grid.addWidget(units_label, 0, 0) grid.addWidget(self.qcombo_units, 0, 1) grid.addWidget(self.qlabel_SeriesImpedance, 1, 0) grid.addWidget(self.qedit_SeriesImpedance, 1, 1) # grid.addWidget(self.qchk_display_model , 2, 1) # grid.addWidget(self.qradio_signp , 3, 0) # grid.addWidget(self.qradio_signn , 3, 1) # grid.addWidget(self.qlabel_k , 4, 0) # grid.addWidget(self.qedit_k , 4, 1) # grid.addWidget(self.qlabel_f1 , 5, 0) # grid.addWidget(self.qedit_f1 , 5, 1) # grid.addWidget(self.qlabel_f0 , 6, 0) # grid.addWidget(self.qedit_f0 , 6, 1) # grid.addWidget(self.qlabel_zeta , 7, 0) # grid.addWidget(self.qedit_zeta , 7, 1) # grid.addWidget(self.qlabel_T , 8, 0) # grid.addWidget(self.qedit_T , 8, 1) # grid.addWidget(self.qchk_controller , 9, 0, 1, 2) # grid.addWidget(self.qlabel_pgain , 10, 0) # grid.addWidget(self.qedit_pgain , 10, 1) # grid.addWidget(self.qlabel_icorner , 12, 0) # grid.addWidget(self.qedit_icorner , 12, 1) # grid.addWidget(self.qchk_DDCFilter , 13, 0, 1, 2) grid.addWidget(self.qedit_comment, 14, 0, 1, 2) grid.setRowStretch(15, 0) # grid.addWidget(Qt.QLabel(''), 12, 0, 1, 2) # grid.setRowStretch(14, 1) vbox = Qt.QVBoxLayout() vbox.addWidget(self.qplt_mag) vbox.addWidget(self.qplt_phase) hbox = Qt.QHBoxLayout() hbox.addLayout(grid) hbox.addLayout(vbox, 1) # hbox.setStretch(2, 1) self.setLayout(hbox) # Adjust the size and position of the window self.resize(1200, 500) self.center() self.setWindowTitle('Transfer function #%d' % self.window_number) self.show()
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.MiconstellationObject = MiconstellationObject = digital.constellation_calcdist( digital.constellation_qpsk().points(), (0, 1, 2, 3), 4, 1).base() self.Constelacion = Constelacion = MiconstellationObject.points() self.M = M = len(Constelacion) self.samp_rate_usrp_rx = samp_rate_usrp_rx = 100e6 self.Rb = Rb = 100 self.Bps = Bps = int(math.log(M, 2)) self.samp_rate_to_usrp = samp_rate_to_usrp = int(samp_rate_usrp_rx / 512) self.samp_rate_audio = samp_rate_audio = 11000 self.ntaps = ntaps = 128 self.Sps = Sps = 160 self.Rs = Rs = Rb / Bps self.Rolloff = Rolloff = 0.5 self.NbpS = NbpS = 8 self.samp_rate_0 = samp_rate_0 = int(Rs * Sps) self.samp_rate = samp_rate = Rb * Sps self.run_stop = run_stop = True self.mapinverse = mapinverse = coding.inverse_map(Constelacion) self.mapdirect = mapdirect = coding.direct_map(Constelacion) self.h_rrc = h_rrc = wform.rrcos(Sps, ntaps, Rolloff) self.Vp = Vp = 1. self.Tupdate = Tupdate = 1. / Rb self.Sps_0 = Sps_0 = int(math.floor(samp_rate_to_usrp / Rs)) self.Rb_0 = Rb_0 = NbpS * samp_rate_audio self.P = P = 0. self.NnivelesQ = NnivelesQ = int(math.pow(2, NbpS)) self.Kf = Kf = 200 self.F = F = 0. self.BW = BW = (Rs / 2) * (1 + Rolloff) self.Ar = Ar = 0. self.A = A = 1. ################################################## # Blocks ################################################## self._P_range = Range(-2. * math.pi, 2. * math.pi, (4. * math.pi) / 360., 0., 200) self._P_win = RangeWidget(self._P_range, self.set_P, 'Fase', "counter_slider", float) self.top_grid_layout.addWidget(self._P_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Ar_range = Range(0, 4., (4.) / 50., 0., 200) self._Ar_win = RangeWidget(self._Ar_range, self.set_Ar, 'Ruido', "counter_slider", float) self.top_grid_layout.addWidget(self._Ar_win, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._A_range = Range(-1.5, 1.5, (1.5) / 100., 1., 200) self._A_win = RangeWidget(self._A_range, self.set_A, 'A', "counter_slider", float) self.top_grid_layout.addWidget(self._A_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) _run_stop_check_box = Qt.QCheckBox('Inicial/Parar') self._run_stop_choices = {True: True, False: False} self._run_stop_choices_inv = dict( (v, k) for k, v in self._run_stop_choices.items()) self._run_stop_callback = lambda i: Qt.QMetaObject.invokeMethod( _run_stop_check_box, "setChecked", Qt.Q_ARG("bool", self._run_stop_choices_inv[i])) self._run_stop_callback(self.run_stop) _run_stop_check_box.stateChanged.connect( lambda i: self.set_run_stop(self._run_stop_choices[bool(i)])) self.top_grid_layout.addWidget(_run_stop_check_box, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_1 = qtgui.time_sink_f( 1024, #size samp_rate_audio, #samp_rate 'Nuevo', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_0_1.set_y_axis(-128, 128) self.qtgui_time_sink_x_0_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_1.enable_tags(True) self.qtgui_time_sink_x_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_1.enable_autoscale(False) self.qtgui_time_sink_x_0_0_1.enable_grid(False) self.qtgui_time_sink_x_0_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_0_1.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_1_win) self.qtgui_time_sink_x_0_0_0_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "compararacion entre mensaje y EC", #name 3 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0_0_0_0.set_y_axis(-1.5, 1.5) self.qtgui_time_sink_x_0_0_0_0_0.set_y_label('Amplitud', 'volts') self.qtgui_time_sink_x_0_0_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_stem_plot(False) labels = [ 'Mensaje', 'FSK parte real', 'FSK parte Imaginaria', '', '', '', '', '', '', '' ] widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_0_win, 4, 1, 1, 2) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "Nivel de Amplitud", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-1.5, 1.5) self.qtgui_time_sink_x_0_0_0_0.set_y_label('Amplitud', 'volts') self.qtgui_time_sink_x_0_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0_0.enable_stem_plot(False) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_win, 3, 0, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "Nivel de Fase", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0_0.set_y_axis(-2 * math.pi, 2 * math.pi) self.qtgui_time_sink_x_0_0_0.set_y_label('Fase', 'radianes') self.qtgui_time_sink_x_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win, 3, 1, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "Nivel de frecuencia", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0.set_y_axis(-2.5, 2.5) self.qtgui_time_sink_x_0_0.set_y_label('Frecuencia', 'Hz') self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 3, 2, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 8, #size '', #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(Tupdate) self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_x_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [4, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.epy_block_0 = epy_block_0.blk() self.e_VCO_fase_fc_0 = e_VCO_fase_fc_0.blk() self.digital_map_bb_0 = digital.map_bb(mapdirect) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(M) self.digital_chunks_to_symbols_xx = digital.chunks_to_symbols_bc( MiconstellationObject.points(), 1) self.d_freq_cf_assign_freq_cf_0 = d_freq_cf.assign_freq_cf() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( Bps, gr.GR_LSB_FIRST) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0_0_1_0_0 = blocks.multiply_const_ff( Kf * 2 * math.pi / samp_rate) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.b_quantizer_fb_0 = b_quantizer_fb( NivelesQ=NnivelesQ, Vmax=Vp, ) self.b_bipolar_to_unipolar_ff_0 = b_bipolar_to_unipolar_ff() self.b_binary_bipolar_source_f_0 = b_binary_bipolar_source_f( Am=1., Spb=Sps, ) self.b_PSD_c_0 = b_PSD_c( Ensayos=1000000, Fc=0, N=1024, Ymax=1e-5, samp_rate_audio=samp_rate, ) self.top_grid_layout.addWidget(self.b_PSD_c_0, 5, 1, 1, 2) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self.analog_noise_source_x_1 = analog.noise_source_c( analog.GR_GAUSSIAN, Ar, 0) self.analog_const_source_x_0_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, P) self.analog_const_source_x_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, A) self._F_range = Range(-2.4, 2.4, (2 * 2.4) / 1000., 0., 200) self._F_win = RangeWidget(self._F_range, self.set_F, 'Frecuencia', "counter_slider", float) self.top_grid_layout.addWidget(self._F_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0_0, 0), (self.e_VCO_fase_fc_0, 1)) self.connect((self.analog_const_source_x_0_0, 0), (self.qtgui_time_sink_x_0_0_0_0, 0)) self.connect((self.analog_const_source_x_0_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_const_source_x_0_0_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.analog_noise_source_x_1, 0), (self.blocks_add_xx_1, 1)) self.connect((self.b_binary_bipolar_source_f_0, 0), (self.b_bipolar_to_unipolar_ff_0, 0)) self.connect((self.b_bipolar_to_unipolar_ff_0, 0), (self.b_quantizer_fb_0, 0)) self.connect((self.b_bipolar_to_unipolar_ff_0, 0), (self.epy_block_0, 0)) self.connect((self.b_bipolar_to_unipolar_ff_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.b_bipolar_to_unipolar_ff_0, 0), (self.qtgui_time_sink_x_0_0_0_0_0, 0)) self.connect((self.b_quantizer_fb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.e_VCO_fase_fc_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0_0_0_0_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0_0_0_0_0, 2)) self.connect((self.blocks_multiply_const_vxx_0_0_0_1_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.d_freq_cf_assign_freq_cf_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.d_freq_cf_assign_freq_cf_0, 0), (self.qtgui_time_sink_x_0_0_1, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.b_PSD_c_0, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.d_freq_cf_assign_freq_cf_0, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_chunks_to_symbols_xx, 0)) self.connect((self.e_VCO_fase_fc_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.epy_block_0, 0), (self.blocks_multiply_const_vxx_0_0_0_1_0_0, 0))
def __init__(self, app): super().__init__() settings = app.client.get_data() back_button = Qt.QPushButton(Qt.QIcon(common.LEFT), '', self) back_button.setObjectName('Flat') back_button.setCursor(Qt.Qt.PointingHandCursor) back_button.setIconSize(Qt.QSize(35, 35)) back_button.setFixedSize(Qt.QSize(55, 55)) back_button.clicked.connect(app.display_login_page) settings_title = Qt.QLabel('Настройки', self) settings_title.setFont(Qt.QFont('Arial', 30)) server_title = Qt.QLabel('Соединение с сервером', self) server_title.setFont(Qt.QFont('Arial', 25)) server_ip_title = Qt.QLabel('IP-адрес сервера:', self) server_ip_title.setFont(Qt.QFont('Arial', 20)) server_ip_input = Qt.QLineEdit(settings['server'], self) server_ip_input.setFont(Qt.QFont('Arial', 20)) server_ip_input.setMinimumWidth(350) server_check_button = Qt.QPushButton('Проверить соединение', self) server_check_button.setObjectName('Button') server_check_button.setFont(Qt.QFont('Arial', 20)) server_check_button.clicked.connect( lambda: app.check_ip(server_ip_input.text())) server_ip_input.returnPressed.connect(server_check_button.click) self.server_status_label = Qt.QLabel(self) self.server_status_label.setFont(Qt.QFont('Arial', 20)) self.server_status_label.setWordWrap(True) self.server_status_label.setMinimumWidth(270) autosave_title = Qt.QLabel('Автозаполнение форм', self) autosave_title.setFont(Qt.QFont('Arial', 25)) autosave_password_checkbox = Qt.QCheckBox('Сохранять пароль', self) autosave_password_checkbox.setFont(Qt.QFont('Arial', 20)) if settings['autofill']: autosave_password_checkbox.setChecked(True) save_button = Qt.QPushButton('Сохранить', self) save_button.setObjectName('Button') save_button.setFont(Qt.QFont('Arial', 20)) save_button.clicked.connect(lambda: app.save_settings( { 'server': server_ip_input.text(), 'autofill': autosave_password_checkbox.isChecked() })) upper_layout = Qt.QHBoxLayout() upper_layout.addWidget(back_button) upper_layout.addStretch(1) upper_layout.addWidget(settings_title) upper_layout.addStretch(1) server_ip_layout = Qt.QHBoxLayout() server_ip_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) server_ip_layout.addWidget(server_ip_title) server_ip_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) server_ip_layout.addWidget(server_ip_input) server_ip_layout.addStretch(1) server_check_layout = Qt.QHBoxLayout() server_check_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) server_check_layout.addWidget(server_check_button) server_check_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) server_check_layout.addWidget(self.server_status_label) server_check_layout.addStretch(1) server_layout = Qt.QVBoxLayout() server_layout.addLayout(server_ip_layout) server_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) server_layout.addLayout(server_check_layout) autosave_password_layout = Qt.QHBoxLayout() autosave_password_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) autosave_password_layout.addWidget(autosave_password_checkbox) autosave_password_layout.addStretch(1) autosave_layout = Qt.QVBoxLayout() autosave_layout.addLayout(autosave_password_layout) save_layout = Qt.QHBoxLayout() save_layout.addWidget(save_button) save_layout.addStretch(1) layout = Qt.QVBoxLayout() layout.addLayout(upper_layout) layout.addSpacerItem(Qt.QSpacerItem(0, 40)) layout.addWidget(server_title) layout.addSpacerItem(Qt.QSpacerItem(0, 20)) layout.addLayout(server_layout) layout.addSpacerItem(Qt.QSpacerItem(0, 30)) layout.addWidget(autosave_title) layout.addSpacerItem(Qt.QSpacerItem(0, 20)) layout.addLayout(autosave_layout) layout.addSpacerItem(Qt.QSpacerItem(0, 40)) layout.addStretch(1) layout.addLayout(save_layout) self.setLayout(layout)
def setup_ui(self) -> None: layout = Qt.QHBoxLayout(self) layout.setObjectName('PlaybackToolbar.setup_ui.layout') layout.setContentsMargins(0, 0, 0, 0) self.seek_to_start_button = Qt.QToolButton(self) self.seek_to_start_button.setText('⏮') self.seek_to_start_button.setToolTip('Seek to First Frame') layout.addWidget(self.seek_to_start_button) self.seek_n_frames_b_button = Qt.QToolButton(self) self.seek_n_frames_b_button.setText('⏪') self.seek_n_frames_b_button.setToolTip('Seek N Frames Backwards') layout.addWidget(self.seek_n_frames_b_button) self.seek_to_prev_button = Qt.QToolButton(self) self.seek_to_prev_button.setText('◂') self.seek_to_prev_button.setToolTip('Seek 1 Frame Backwards') layout.addWidget(self.seek_to_prev_button) self.play_pause_button = Qt.QToolButton(self) self.play_pause_button.setText('⏯') self.play_pause_button.setToolTip('Play/Pause') self.play_pause_button.setCheckable(True) layout.addWidget(self.play_pause_button) self.seek_to_next_button = Qt.QToolButton(self) self.seek_to_next_button.setText('▸') self.seek_to_next_button.setToolTip('Seek 1 Frame Forward') layout.addWidget(self.seek_to_next_button) self.seek_n_frames_f_button = Qt.QToolButton(self) self.seek_n_frames_f_button.setText('⏩') self.seek_n_frames_f_button.setToolTip('Seek N Frames Forward') layout.addWidget(self.seek_n_frames_f_button) self.seek_to_end_button = Qt.QToolButton(self) self.seek_to_end_button.setText('⏭') self.seek_to_end_button.setToolTip('Seek to Last Frame') layout.addWidget(self.seek_to_end_button) self.seek_frame_control = FrameEdit[FrameInterval](self) self.seek_frame_control.setMinimum(FrameInterval(1)) self.seek_frame_control.setToolTip('Seek N Frames Step') self.seek_frame_control.setValue(FrameInterval(self.main.SEEK_STEP)) layout.addWidget(self.seek_frame_control) self.seek_time_control = TimeEdit[TimeInterval](self) layout.addWidget(self.seek_time_control) self.fps_spinbox = Qt.QDoubleSpinBox(self) self.fps_spinbox.setRange(0.001, 9999.0) self.fps_spinbox.setDecimals(3) self.fps_spinbox.setSuffix(' fps') layout.addWidget(self.fps_spinbox) self.fps_reset_button = Qt.QPushButton(self) self.fps_reset_button.setText('Reset FPS') layout.addWidget(self.fps_reset_button) self.fps_unlimited_checkbox = Qt.QCheckBox(self) self.fps_unlimited_checkbox.setText('Unlimited FPS') layout.addWidget(self.fps_unlimited_checkbox) layout.addStretch()
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.Rb = Rb = 32000 self.vueltas_simbolo = vueltas_simbolo = 2 self.Tb = Tb = 1 / Rb self.Sps = Sps = 2 self.Bps = Bps = 1 self.samp_rate = samp_rate = Rb * Sps self.run_stop = run_stop = True self.ntaps = ntaps = 2 self.f1 = f1 = vueltas_simbolo / Tb self.bt = bt = 0.350 self.Tupdate = Tupdate = 1. / Rb self.Rs = Rs = Rb / Bps self.P = P = 0. self.F = F = 0. self.Ar = Ar = 0. self.A = A = 1. ################################################## # Blocks ################################################## self._P_range = Range(-2. * math.pi, 2. * math.pi, (4. * math.pi) / 360., 0., 200) self._P_win = RangeWidget(self._P_range, self.set_P, 'Fase', "counter_slider", float) self.top_grid_layout.addWidget(self._P_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Ar_range = Range(0, 4., (4.) / 50., 0., 200) self._Ar_win = RangeWidget(self._Ar_range, self.set_Ar, 'Ruido', "counter_slider", float) self.top_grid_layout.addWidget(self._Ar_win, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) _run_stop_check_box = Qt.QCheckBox('Inicial/Parar') self._run_stop_choices = {True: True, False: False} self._run_stop_choices_inv = dict( (v, k) for k, v in self._run_stop_choices.items()) self._run_stop_callback = lambda i: Qt.QMetaObject.invokeMethod( _run_stop_check_box, "setChecked", Qt.Q_ARG("bool", self._run_stop_choices_inv[i])) self._run_stop_callback(self.run_stop) _run_stop_check_box.stateChanged.connect( lambda i: self.set_run_stop(self._run_stop_choices[bool(i)])) self.top_grid_layout.addWidget(_run_stop_check_box, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "compararacion entre mensaje y EC", #name 3 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0_0_0_0.set_y_axis(-1.5, 1.5) self.qtgui_time_sink_x_0_0_0_0_0.set_y_label('Amplitud', 'volts') self.qtgui_time_sink_x_0_0_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_stem_plot(False) labels = ['Mensaje', '', '', '', '', '', '', '', '', ''] widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_0_win, 4, 1, 1, 2) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 5, 0, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 8, #size '', #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(Tupdate) self.qtgui_const_sink_x_0.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_0.set_x_axis(-1.5, 1.5) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [4, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc( Sps, firdes.gaussian(1.0, Rs, bt, ntaps)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.epy_block_0 = epy_block_0.blk() self.e_VCO_fase_fc_0 = e_VCO_fase_fc_0.blk() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(f1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_1 = blocks.complex_to_float(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.b_binary_bipolar_source_f_0 = b_binary_bipolar_source_f( Am=1., Spb=Sps, ) self.b_PSD_c_0_0 = b_PSD_c( Ensayos=1000000, Fc=0, N=1024, Ymax=6e-6, samp_rate_audio=samp_rate, ) self.top_grid_layout.addWidget(self.b_PSD_c_0_0, 5, 2, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.b_PSD_c_0 = b_PSD_c( Ensayos=1000000, Fc=f1, N=1024, Ymax=6e-6, samp_rate_audio=samp_rate, ) self.top_grid_layout.addWidget(self.b_PSD_c_0, 5, 1, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.analog_noise_source_x_1 = analog.noise_source_c( analog.GR_GAUSSIAN, Ar, 0) self.analog_const_source_x_0_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, P) self.analog_const_source_x_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 1) self._F_range = Range(-2.4, 2.4, (2 * 2.4) / 1000., 0., 200) self._F_win = RangeWidget(self._F_range, self.set_F, 'Frecuencia', "counter_slider", float) self.top_grid_layout.addWidget(self._F_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._A_range = Range(-1.5, 1.5, (1.5) / 100., 1., 200) self._A_win = RangeWidget(self._A_range, self.set_A, 'A', "counter_slider", float) self.top_grid_layout.addWidget(self._A_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0_0, 0), (self.e_VCO_fase_fc_0, 1)) self.connect((self.analog_const_source_x_0_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_noise_source_x_1, 0), (self.blocks_add_xx_1, 1)) self.connect((self.b_binary_bipolar_source_f_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.e_VCO_fase_fc_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0_0_0_0_0, 2)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0_0_0_0_0, 1)) self.connect((self.blocks_complex_to_float_1, 0), (self.epy_block_0, 0)) self.connect((self.blocks_complex_to_float_1, 0), (self.qtgui_time_sink_x_0_0_0_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.b_PSD_c_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.b_PSD_c_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.e_VCO_fase_fc_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.epy_block_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_complex_to_float_1, 0))
def initUI(self): # print('initUI()') # First create the plot: self.qplot_tf = pg.PlotWidget() # self.qplot_tf.enableAxis(Qwt.QwtPlot.xBottom, False) # self.qplot_tf.enableAxis(Qwt.QwtPlot.yLeft, False) self.qplot_tf.setMinimumHeight(100) self.qplot_tf.setMinimumWidth(100) #self.qplot_tf.setCanvasBackground(Qt.Qt.white) #self.qplot_tf.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLog10ScaleEngine()) self.qplot_tf.getPlotItem().setLogMode(x=True) #self.qplot_tf.setTitle('Loop filter #%d' % self.filter_number) #qPolicy = Qt.QSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding) #qPolicy = Qt.QSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding) qPolicy = Qt.QSizePolicy(Qt.QSizePolicy.Ignored, Qt.QSizePolicy.Ignored) self.qplot_tf.setSizePolicy(qPolicy) self.curve_0dB = self.qplot_tf.getPlotItem().plot() #FEATURE #self.curve_0dB.attach(self.qplot_tf) #pen = Qt.QPen(Qt.Qt.DashLine) #pen.setColor(Qt.Qt.black) #pen.setBrush(QtGui.QBrush(QtCore.Qt.NoBrush)) pen = pg.mkPen(color='k', dash=[4, 2]) self.curve_0dB.setPen(pen) self.curve_kp = self.qplot_tf.getPlotItem().plot(pen='k') #self.curve_kp.attach(self.qplot_tf) #self.curve_kp.setPen(Qt.QPen(Qt.Qt.black)) self.curve_fi = self.qplot_tf.getPlotItem().plot(pen='k') #self.curve_fi.attach(self.qplot_tf) #self.curve_fi.setPen(Qt.QPen(Qt.Qt.black)) self.curve_fii = self.qplot_tf.getPlotItem().plot(pen='k') #self.curve_fii.attach(self.qplot_tf) #self.curve_fii.setPen(Qt.QPen(Qt.Qt.black)) self.curve_fd = self.qplot_tf.getPlotItem().plot(pen='k') # self.curve_fd = self.qplot_tf.getPlotItem().plot() #self.curve_fd.attach(self.qplot_tf) # self.curve_fd.setPen(Qt.QPen(Qt.Qt.black)) self.curve_fdf = self.qplot_tf.getPlotItem().plot(pen='k') #self.curve_fdf.attach(self.qplot_tf) # pen2 = Qt.QPen(Qt.Qt.DashLine) # pen2.setColor(Qt.Qt.black) #self.curve_fdf.setPen(pen2) self.curve_composite = self.qplot_tf.getPlotItem().plot() #self.curve_composite.attach(self.qplot_tf) self.curve_composite.setPen(pg.mkPen('r')) # self.curve_actual = self.qplot_tf.getPlotItem().plot(fillLevel=-140, fillBrush='b') self.curve_actual = self.qplot_tf.getPlotItem().plot() #self.curve_actual.attach(self.qplot_tf) #self.curve_actual.setPen(Qt.QPen(Qt.Qt.blue, 2)) self.curve_actual.setPen(pg.mkPen('b', width=2)) # self.curve_0dB.setPen(self.qplot_tf) self.qlabel_spacerh = Qt.QLabel('') self.qlabel_spacerh.setMinimumWidth(30) self.qlabel_spacerh2 = Qt.QLabel('') self.qlabel_spacerh2.setMinimumWidth(7) self.qlabel_spacerv = Qt.QLabel('') self.qlabel_spacerv.setMinimumHeight(25) self.qchk_lock = Qt.QCheckBox('Lock On') self.qchk_lock.clicked.connect(self.textboxChanged) self.qchk_lock.setEnabled(self.bDisplayLockChkBox) self.qchk_kp = Qt.QCheckBox('Kp On') self.qchk_kp.clicked.connect(self.textboxChanged) self.qchk_kd = Qt.QCheckBox('Kd On') self.qchk_kd.clicked.connect(self.textboxChanged) # Labels and controls to show the settings: self.qlabel_kp = Qt.QLabel('Kp:') self.qlabel_fi = Qt.QLabel('fi:') self.qlabel_fii = Qt.QLabel('fii:') self.qlabel_fd = Qt.QLabel('fd:') self.qlabel_fdf = Qt.QLabel('fdf:') self.qedit_kp = user_friendly_QLineEdit('-60') self.qedit_fi = user_friendly_QLineEdit('1e3') self.qedit_fii = user_friendly_QLineEdit('1e1') self.qedit_fd = user_friendly_QLineEdit('1e6') self.qedit_fdf = user_friendly_QLineEdit('1e6') self.qedit_kp.setMaximumWidth(100) self.qedit_fi.setMaximumWidth(100) self.qedit_fii.setMaximumWidth(100) self.qedit_fd.setMaximumWidth(100) self.qedit_fdf.setMaximumWidth(100) self.qedit_kp.returnPressed.connect(self.textboxChanged) self.qedit_fi.returnPressed.connect(self.textboxChanged) self.qedit_fii.returnPressed.connect(self.textboxChanged) self.qedit_fd.returnPressed.connect(self.textboxChanged) self.qedit_fdf.returnPressed.connect(self.textboxChanged) self.qchk_bKpCrossing = Qt.QCheckBox('fi refer to kp crossover') self.qchk_bKpCrossing.setChecked(False) self.qchk_bKpCrossing.clicked.connect(self.bKpCrossingPress) self.qchk_lockSlider = Qt.QCheckBox('Lock D sliders') self.qchk_lockSlider.setChecked(False) self.qchk_lockSlider.clicked.connect(self.lockSlider) self.slider_locked = False self.slider_ratio = 10 self.slider_inhibit = False # The sliders: self.qslider_kp = Qt.QSlider() self.qslider_fi = Qt.QSlider() self.qslider_fii = Qt.QSlider() self.qslider_fd = Qt.QSlider() self.qslider_fdf = Qt.QSlider() self.qslider_kp.setOrientation(Qt.Qt.Vertical) self.qslider_fi.setOrientation(Qt.Qt.Horizontal) self.qslider_fii.setOrientation(Qt.Qt.Horizontal) self.qslider_fd.setOrientation(Qt.Qt.Horizontal) self.qslider_fdf.setOrientation(Qt.Qt.Horizontal) # Set bounds: (kp, fi, fii, fd, fdf, fmin, fmax, gain_min, gain_max, bLock) = self.getSettings() # The fi and fii sliders will contain the value in 100*log10(f) units (similar to dBHz, but with a different scaling - this is because we can only use integer units) self.qslider_fi.setMinimum(100 * np.log10(fmin)) self.qslider_fii.setMinimum(100 * np.log10(fmin)) self.qslider_fd.setMinimum(100 * np.log10(fmin)) self.qslider_fdf.setMinimum(100 * np.log10(fmin)) self.qslider_fi.setMaximum(100 * np.log10(fmax)) self.qslider_fii.setMaximum(100 * np.log10(fmax)) self.qslider_fd.setMaximum(100 * np.log10(fmax)) self.qslider_fdf.setMaximum(100 * np.log10(fmax)) self.qslider_kp.setMinimum(10 * gain_min) self.qslider_kp.setMaximum(10 * gain_max) self.qslider_fi.setValue((100 * np.log10(fi))) self.qslider_fii.setValue((100 * np.log10(fii))) self.qslider_fd.setValue((100 * np.log10(fd))) self.qslider_fdf.setValue((100 * np.log10(fdf))) self.qslider_kp.setValue((10 * kp)) # print('10*gain_min = %f, 10*gain_min = %f, 10*kp = %f' % (10*gain_min, 10*gain_min, 10*kp)) self.qslider_kp.valueChanged.connect(self.kpSliderEvent) self.qslider_fi.valueChanged.connect(self.fiSliderEvent) self.qslider_fii.valueChanged.connect(self.fiiSliderEvent) self.qslider_fd.valueChanged.connect(self.fdSliderEvent) self.qslider_fdf.valueChanged.connect(self.fdfSliderEvent) # Every control for the proportional gain goes into an hbox: vbox = Qt.QVBoxLayout() vbox.addStretch(1) vbox.addWidget(self.qchk_kp) vbox.addWidget(self.qchk_kd) # Put everything in a grid layout: grid = Qt.QGridLayout() grid.addLayout(vbox, 0, 0, 2, 2) grid.addWidget(self.qslider_kp, 0, 2, 3, 1) grid.addWidget(self.qplot_tf, 0, 3, 9, 1) grid.setColumnStretch(3, 1) grid.setRowStretch(8, 1) grid.addWidget(self.qlabel_kp, 2, 0) grid.addWidget(self.qlabel_fi, 3, 0) grid.addWidget(self.qlabel_fii, 4, 0) grid.addWidget(self.qlabel_fd, 5, 0) grid.addWidget(self.qlabel_fdf, 6, 0) grid.addWidget(self.qedit_kp, 2, 1, 1, 1) grid.addWidget(self.qedit_fi, 3, 1, 1, 1) grid.addWidget(self.qedit_fii, 4, 1, 1, 1) grid.addWidget(self.qedit_fd, 5, 1, 1, 1) grid.addWidget(self.qedit_fdf, 6, 1, 1, 1) grid.addWidget(self.qchk_bKpCrossing, 7, 0, 1, 3) grid.addWidget(self.qslider_fi, 3, 2, 1, 1) grid.addWidget(self.qslider_fii, 4, 2, 1, 1) grid.addWidget(self.qslider_fd, 5, 2, 1, 1) grid.addWidget(self.qslider_fdf, 6, 2, 1, 1) #grid.addWidget(self.qlabel_spacerh2, 4, 5, 1, 1) self.setLayout(grid)
def initUI(self): # Create the widgets which control the system identification module: # Input select transfer_input_label = Qt.QLabel('Input:') self.qcombo_transfer_input = Qt.QComboBox() self.qcombo_transfer_input.addItems( ['ADC 0', 'ADC 1', 'DDC 0', 'DDC 1']) self.qcombo_transfer_input.setCurrentIndex(2) # transfer_input_label.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) # self.qcombo_transfer_input.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) # Output select transfer_output_label = Qt.QLabel('Output:') self.qcombo_transfer_output = Qt.QComboBox() self.qcombo_transfer_output.addItems(['DAC 0', 'DAC 1', 'DAC 2']) self.qcombo_transfer_output.setCurrentIndex(0) # transfer_output_label.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) # self.qcombo_transfer_output.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) # settling_time_label = Qt.QLabel('System settling time [s]:') self.qedit_settling_time = Qt.QLineEdit('1e-3') self.qedit_settling_time.setMaximumWidth(60) self.qedit_settling_time.editingFinished.connect( self.updateIntegrationTime) # settling_time_label.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) # self.qedit_settling_time.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) freq_start_label = Qt.QLabel('Freq start [Hz]:') self.qedit_freq_start = Qt.QLineEdit('10e3') self.qedit_freq_start.setMaximumWidth(60) self.qedit_freq_start.editingFinished.connect( self.updateIntegrationTime) # freq_start_label.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) # self.qedit_freq_start.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) freq_end_label = Qt.QLabel('Freq end [Hz]:') self.qedit_freq_end = Qt.QLineEdit('2e6') self.qedit_freq_end.setMaximumWidth(60) # self.qedit_freq_end.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) freq_number_label = Qt.QLabel('Number of freq [max 3276]:') self.qedit_freq_number = Qt.QLineEdit('160') self.qedit_freq_number.setMaximumWidth(60) # self.qedit_freq_number.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) amplitude_label = Qt.QLabel('Modulation amplitude [0-1]:') self.qedit_output_amplitude = Qt.QLineEdit('0.01') self.qedit_output_amplitude.setMaximumWidth(60) # self.qedit_output_amplitude.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) self.qlbl_integration_time = Qt.QLabel( 'Integration time per freq [s]: ') self.updateIntegrationTime() # Button which triggers the system identification self.qbtn_ident = QtGui.QPushButton('Run identification') self.qbtn_ident.clicked.connect(self.runSytemIdentification) # self.qbtn_ident.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) self.qbtn_stop_ident = QtGui.QPushButton('Stop identification') self.qbtn_stop_ident.clicked.connect(self.stopClicked) # Progress bar which indicates the progression of the identification self.qprogress_ident = Qt.QProgressBar() self.qprogress_ident.setTextVisible(False) self.qprogress_ident.setValue(0) # self.qprogress_ident.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) # Controls for the dither mode: # Needs: output select, frequency, amplitude, Square/Sine select, dither on/off ###################################################################### # Settings ###################################################################### self.qgroupbox_dither = Qt.QGroupBox('Continuous output', self) self.dither_output_label = Qt.QLabel('Output:') self.qcombo_dither_output = Qt.QComboBox() self.qcombo_dither_output.addItems(['DAC 0', 'DAC 1', 'DAC 2']) self.qcombo_dither_output.setCurrentIndex(0) self.qcombo_dither_output.currentIndexChanged.connect( self.ditherClicked) # Modulation frequency: self.qedit_freq_label = Qt.QLabel('Frequency [Hz]:') self.qedit_dither_freq = Qt.QLineEdit('1e6') self.qedit_dither_freq.textChanged.connect(self.ditherClicked) self.qedit_dither_freq.setMaximumWidth(60) # Amplitude: self.qlabel_dither_amplitude = Qt.QLabel('Amplitude [0-1]:') self.qedit_dither_amplitude = Qt.QLineEdit('0.01') self.qedit_dither_amplitude.textChanged.connect(self.ditherClicked) self.qedit_dither_amplitude.setMaximumWidth(60) # Sine/Square wave self.qradio_sinewave = Qt.QRadioButton('Sine wave') self.qradio_squarewave = Qt.QRadioButton('Square wave') self.qsign_group = Qt.QButtonGroup(self) self.qsign_group.addButton(self.qradio_sinewave) self.qsign_group.addButton(self.qradio_squarewave) self.qradio_sinewave.setChecked(True) self.qradio_squarewave.setChecked(False) self.qradio_sinewave.clicked.connect(self.ditherClicked) self.qradio_squarewave.clicked.connect(self.ditherClicked) # On/Off button self.qbtn_dither = QtGui.QPushButton('Activate dither') self.qbtn_dither.clicked.connect(self.ditherClicked) self.qbtn_dither.setCheckable(True) # Put all the widgets into a grid layout grid = QtGui.QGridLayout() grid.addWidget(self.dither_output_label, 0, 0) grid.addWidget(self.qcombo_dither_output, 0, 1) grid.addWidget(self.qedit_freq_label, 1, 0) grid.addWidget(self.qedit_dither_freq, 1, 1) grid.addWidget(self.qlabel_dither_amplitude, 2, 0) grid.addWidget(self.qedit_dither_amplitude, 2, 1) grid.addWidget(self.qradio_sinewave, 3, 0) grid.addWidget(self.qradio_squarewave, 3, 1) grid.addWidget(self.qbtn_dither, 4, 0, 1, 2) self.qgroupbox_dither.setLayout(grid) ###################################################################### # Settings ###################################################################### self.qgroupbox_test_osc = Qt.QGroupBox( 'Variable duty-cycle oscillator') self.qlbl_osc_freq = Qt.QLabel('Frequency [Hz]:') self.qedit_osc_freq = Qt.QLineEdit('200e3') self.qedit_osc_freq.textChanged.connect(self.oscClicked) # On/Off button self.qbtn_osc = QtGui.QPushButton('Activate output') self.qbtn_osc.setCheckable(True) self.qbtn_osc.setChecked(True) self.qbtn_osc.clicked.connect(self.oscClicked) # Polarity setting self.qchk_osc_polarity = Qt.QCheckBox('Invert polarity') self.qchk_osc_polarity.clicked.connect(self.oscClicked) # Duty cycle slider self.q_osc_duty_cyle = Qt.QSlider() self.q_osc_duty_cyle.valueChanged.connect(self.oscClicked) self.q_osc_duty_cyle.setSliderPosition(0) self.q_osc_duty_cyle.setOrientation(Qt.Qt.Horizontal) # Units are millionth of the full range available self.q_osc_duty_cyle.setMinimum(0) self.q_osc_duty_cyle.setMaximum(1e6) self.q_osc_duty_cyle.setSingleStep(1e6 / 100. / 3.) self.q_osc_duty_cyle.setPageStep(1e6 / 10.) # Put all the widgets into a grid layout grid = QtGui.QGridLayout() grid.addWidget(self.qlbl_osc_freq, 0, 0) grid.addWidget(self.qedit_osc_freq, 0, 1) grid.addWidget(self.qbtn_osc, 1, 0, 1, 2) grid.addWidget(self.qchk_osc_polarity, 2, 0, 1, 2) grid.addWidget(self.q_osc_duty_cyle, 3, 0, 1, 2) self.qgroupbox_test_osc.setLayout(grid) # Put all the widgets into a grid layout grid = QtGui.QGridLayout() grid.addWidget(transfer_input_label, 0, 0) grid.addWidget(self.qcombo_transfer_input, 0, 1) grid.addWidget(transfer_output_label, 1, 0) grid.addWidget(self.qcombo_transfer_output, 1, 1) grid.addWidget(settling_time_label, 2, 0) grid.addWidget(self.qedit_settling_time, 2, 1) grid.addWidget(freq_start_label, 3, 0) grid.addWidget(self.qedit_freq_start, 3, 1) grid.addWidget(freq_end_label, 4, 0) grid.addWidget(self.qedit_freq_end, 4, 1) grid.addWidget(freq_number_label, 5, 0) grid.addWidget(self.qedit_freq_number, 5, 1) grid.addWidget(amplitude_label, 6, 0) grid.addWidget(self.qedit_output_amplitude, 6, 1) grid.addWidget(self.qlbl_integration_time, 7, 0, 1, 2) grid.addWidget(self.qbtn_ident, 8, 0, 1, 2) grid.addWidget(self.qbtn_stop_ident, 9, 0, 1, 2) grid.addWidget(self.qprogress_ident, 10, 0, 1, 2) self.qgroupbox_vna = Qt.QGroupBox('Swept sine', self) self.qgroupbox_vna.setLayout(grid) vbox = Qt.QVBoxLayout() vbox.addWidget(self.qgroupbox_vna) vbox.addWidget(self.qgroupbox_dither) # vbox.addWidget(self.qgroupbox_test_osc) # Spacer which takes up the rest of the space: spacerItem = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Expanding) vbox.addItem(spacerItem) self.setLayout(vbox) # Adjust the size and position of the window # self.resize(800, 600) self.center() self.setWindowTitle('VNA control') self.show()
def __init__(self): super().__init__() self.setWindowTitle(WINDOW_TITLE) self.last_load_path = '.' self.file_name = None self.image_source = None self.image_result = None self.lb_image_view = Qt.QLabel() self.lb_image_view.setAlignment(Qt.Qt.AlignCenter) self.pb_load_image = Qt.QPushButton('Load') self.pb_load_image.clicked.connect(self.load) self.pb_save_as = Qt.QPushButton('Save as...') self.pb_save_as.clicked.connect(self.save_as) self.rb_original = Qt.QRadioButton('Original') self.rb_original.clicked.connect(self._do_pixelate) self.rb_result = Qt.QRadioButton('Result') self.rb_result.setChecked(True) self.rb_result.clicked.connect(self._do_pixelate) self.cb_draw_margin = Qt.QCheckBox('Draw margin') self.cb_draw_margin.setChecked(True) self.cb_draw_margin.clicked.connect(self._do_pixelate) self.sl_pixel_size = Qt.QSlider(Qt.Qt.Horizontal) self.sl_pixel_size.setRange(2, 200) self.sl_pixel_size.setValue(9) self.sb_pixel_size = Qt.QSpinBox() self.sb_pixel_size.setRange(self.sl_pixel_size.minimum(), self.sl_pixel_size.maximum()) self.sb_pixel_size.setValue(self.sl_pixel_size.value()) self.sl_pixel_size.sliderMoved.connect(self.sb_pixel_size.setValue) self.sb_pixel_size.valueChanged.connect(self.sl_pixel_size.setValue) self.sl_pixel_size.sliderMoved.connect(self._do_pixelate) self.sb_pixel_size.valueChanged.connect(self._do_pixelate) line = Qt.QFrame() line.setFrameShape(Qt.QFrame.HLine) line.setFrameShadow(Qt.QFrame.Sunken) layout_button = Qt.QHBoxLayout() layout_button.addWidget(self.rb_original) layout_button.addWidget(self.rb_result) layout_button.addStretch() layout_button.addWidget(self.cb_draw_margin) layout_button_2 = Qt.QHBoxLayout() layout_button_2.addWidget(Qt.QLabel('Pixel size:')) layout_button_2.addWidget(self.sl_pixel_size) layout_button_2.addWidget(self.sb_pixel_size) main_layout = Qt.QVBoxLayout() main_layout.addWidget(self.lb_image_view) main_layout.addWidget(self.pb_load_image) main_layout.addWidget(line) main_layout.addLayout(layout_button) main_layout.addLayout(layout_button_2) main_layout.addWidget(self.pb_save_as) self.setLayout(main_layout) self._do_pixelate()