Exemplo n.º 1
0
 def event(self, e):
     assert isinstance(e, Qt.QEvent)
     if e.type() == 215:
         # QEvent::WindowChangeInternal, an enum value equal to 215, is used internally by Qt and is not exposed by
         # PyQt5 (there is no Qt.QEvent.WindowChangeInternal, but simply comparing against the value it would have
         # works).  Upon receipt of a WindowChangeInternal event, QOpenGLWidget releases its C++ smart pointer 
         # reference to its context, causing the smart pointer's atomic reference counter to decrement.  If the count
         # has reached 0, the context is destroyed, and this is typically the case - but not always, and there is
         # no way to ensure that it will be in any particular instance (the atomic counter value could be incremented
         # by another thread in the interval between the query and actual smart pointer reset call).  So, QOpenGLWidget
         # can't know if it ought to make the context current before releasing the context's smart pointer, although
         # doing so would enable cleanup of GL resources.  Furthermore, QContext's destructor can not make itself
         # current - doing so requires a QSurface, and QContext has no knowledge of any QSurface instances.
         # 
         # So, to get around all this nonsense, we intercept the WindowChangeInternal event, make our context current,
         # emit the context_about_to_change signal to cause any cleanup that requires the old context to be current,
         # make no context current, and then, finally, we allow QOpenGLWidget to respond to the event.
         self.makeCurrent()
         had_logger = hasattr(self, 'logger')
         try:
             if had_logger:
                 self.stop_logging()
             self.context_about_to_change.emit(self)
         except Exception as e:
             Qt.qDebug('Exception of type {} in response to context_about_to_change signal: {}'.format(type(e), str(e)))
         self.doneCurrent()
         r = super().event(e)
         self.makeCurrent()
         if had_logger:
             self.start_logging()
         self.context_changed.emit(self)
         self.doneCurrent()
         return r
     return super().event(e)
Exemplo n.º 2
0
def _on_gl_logger_message(message):
    Qt.qDebug('GL LOG MESSAGE (severity: {}, source: {}, type: {}, GL ID: {}): "{}"'.format(
        _GL_LOGGER_MESSAGE_SEVERITIES[message.severity()],
        _GL_LOGGER_MESSAGE_SOURCES[message.source()],
        _GL_LOGGER_MESSAGE_TYPES[message.type()],
        message.id(),
        message.message()))
Exemplo n.º 3
0
 def _getd_blend_function(self, midx, role):
     if role == CHOICES_QITEMDATA_ROLE:
         return Qt.QVariant(self.blend_function_choices)
     elif role == Qt.Qt.DisplayRole:
         v = self.signaling_list[midx.row()].blend_function
         try:
             c = self.blend_function_value_to_choice[v]
             return Qt.QVariant(c)
         except KeyError:
             Qt.qDebug('No choice for blend function "{}".'.format(v))
Exemplo n.º 4
0
 def _setd_blend_function(self, midx, c, role):
     if role == Qt.Qt.EditRole:
         if isinstance(c, Qt.QVariant):
             c = c.value()
         try:
             v = self.blend_function_choice_to_value[c]
             self.signaling_list[midx.row()].blend_function = v
             return True
         except KeyError:
             Qt.qDebug('No blend function for choice "{}".'.format(c))
     return False
Exemplo n.º 5
0
 def make_widgets_for_property(self, ptuple):
     try:
         self.pattr(ptuple[0])
     except:
         e = 'Failed to read value of "{}{}", so this property will not be presented in the GUI.'
         Qt.qDebug(e.format(self.PROPERTY_ROOT, ptuple[0]))
         return
     layout = self.layout()
     row = layout.rowCount()
     label = Qt.QLabel(ptuple[0] + ':')
     layout.addWidget(label, row, 0)
     widget = self.widget_makers[ptuple[1]](*ptuple)
     layout.addWidget(widget, row, 1)
     return label, widget
Exemplo n.º 6
0
def main():
    exit_on_ctrl_c()

    app = qt.QApplication(sys.argv)

    qt.qmlRegisterType(marquee.Marquee, 'Widgets', 1, 0, 'Marquee')
    qt.qmlRegisterType(radiator_screen.RadiatorScreen, 'Screens', 1, 0, 'RadiatorScreen')

    window = main_window.MainWindow()
    window.showFullScreen()

    mqtt = mqtt_service.MqttService()
    mqtt.start()

    sys.exit(app.exec_())
Exemplo n.º 7
0
def main(top_block_cls=top_block, options=None):

    if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
        style = gr.prefs().get_string('qtgui', 'style', 'raster')
        Qt.QApplication.setGraphicsSystem(style)
    qapp = Qt.QApplication(sys.argv)

    tb = top_block_cls()
    tb.start()
    tb.show()

    def quitting():
        tb.stop()
        tb.wait()
    qapp.aboutToQuit.connect(quitting)
    qapp.exec_()
Exemplo n.º 8
0
    def processFrame(self, frame, levels):
        histogram = [0.0] * levels

        if levels and frame.map(Qt.QAbstractVideoBuffer.ReadOnly):
            pixelFormat = frame.pixelFormat()

            if (pixelFormat == QVideoFrame.Format_YUV420P or
                    pixelFormat == QVideoFrame.Format_NV12):
                # process YUV data
                bits = frame.bits()
                for index in range(frame.height() * frame.width()):
                    histogram[(bits[index] * levels) >> 8] += 1.0
            else:
                imageFormat = QVideoFrame.imageFormatFromPixelFormat(
                    pixelFormat)
                if imageFormat != Qt.QImage.Format_Invalid:
                    # process rgb data
                    image = Qt.QImage(
                        frame.bits(),
                        frame.width(),
                        frame.height(),
                        imageFormat)
                    for y in range(image.height()):
                        for x in range(image.width()):
                            pixel = image.pixel(x, y)
                            histogram[(Qt.qGray(pixel) * levels) >> 8] += 1.0

            # find max value
            maxValue = max(histogram)

            # normalize values between 0 and 1
            if maxValue > 0.0:
                histogram = list(map(lambda x: x / maxValue, histogram))

            frame.unmap()
        self.histogramReady.emit(histogram)
Exemplo n.º 9
0
 def paint(self, qpainter, option, widget):
     assert widget is not None, 'histogram_scene.HistogramItem.paint called with widget=None.  Ensure that view caching is disabled.'
     if self._gl_widget is None:
         self._gl_widget = widget
     else:
         assert self._gl_widget is widget
     layer = self.layer
     if layer is None or layer.image is None:
         if self._tex is not None:
             self._tex.destroy()
             self._tex = None
     else:
         image = layer.image
         layer = self.layer
         widget_size = widget.size()
         histogram = image.histogram
         h_r = layer.histogram_min, layer.histogram_max
         h_w = h_r[1] - h_r[0]
         r = image.range
         w = r[1] - r[0]
         bin_width = w / histogram.shape[-1]
         bin_count = h_w / bin_width
         bin_idx_offset = int((h_r[0] - r[0]) / bin_width)
         with ExitStack() as estack:
             qpainter.beginNativePainting()
             estack.callback(qpainter.endNativePainting)
             GL = QGL()
             histogram_alternate_column_shading_enabled = (
                 self.layer_stack.histogram_alternate_column_shading_enabled
                 and widget_size.width() >= bin_count)
             desired_shader_type = ('G', histogram_alternate_column_shading_enabled)
             if desired_shader_type in self.progs:
                 prog = self.progs[desired_shader_type]
                 if not GL.glIsProgram(prog.programId()):
                     # The current GL context is in a state of flux, likely because a histogram view is in a dock widget that is in
                     # the process of being floated or docked.
                     return
             else:
                 fs_fn = (
                     'histogram_item_fragment_shader__alternate_column_colored.glsl'
                     if histogram_alternate_column_shading_enabled else
                     'histogram_item_fragment_shader.glsl')
                 prog = self.build_shader_prog(
                     desired_shader_type,
                     'planar_quad_vertex_shader.glsl',
                     fs_fn)
             desired_tex_width = image.histogram.shape[-1]
             tex = self._tex
             if tex is not None:
                 if tex.width() != desired_tex_width:
                     tex.destroy()
                     tex = self._tex = None
             if tex is None:
                 tex = Qt.QOpenGLTexture(Qt.QOpenGLTexture.Target1D)
                 tex.setFormat(Qt.QOpenGLTexture.R32F)
                 tex.setWrapMode(Qt.QOpenGLTexture.ClampToEdge)
                 tex.setMipLevels(1)
                 tex.setAutoMipMapGenerationEnabled(False)
                 tex.setSize(desired_tex_width)
                 tex.allocateStorage()
                 # tex stores histogram bin counts - values that are intended to be addressed by element without
                 # interpolation.  Thus, nearest neighbor for texture filtering.
                 tex.setMinMagFilters(Qt.QOpenGLTexture.Nearest, Qt.QOpenGLTexture.Nearest)
                 tex.bind()
                 estack.callback(tex.release)
                 tex.serial = -1
             else:
                 tex.bind()
                 estack.callback(tex.release)
             if image.num_channels == 1:
                 pass
             elif image.num_channels == 2:
                 histogram = histogram[0,:]
             elif image.num_channels >= 3:
                 histogram = (0.2126 * histogram[0,:] + 0.7152 * histogram[1,:] + 0.0722 * histogram[2,:]).astype(numpy.uint32)
             # print(bin_count, bin_idx_offset, bin_idx_offset + bin_count, histogram[bin_idx_offset:bin_idx_offset + bin_count].max())
             max_bin_val = histogram[bin_idx_offset:bin_idx_offset + math.ceil(bin_count)].max()
             if tex.serial != self._layer_data_serial:
                 orig_unpack_alignment = GL.glGetIntegerv(GL.GL_UNPACK_ALIGNMENT)
                 if orig_unpack_alignment != 1:
                     GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
                     # QPainter font rendering for OpenGL surfaces will become broken if we do not restore GL_UNPACK_ALIGNMENT
                     # to whatever QPainter had it set to (when it prepared the OpenGL context for our use as a result of
                     # qpainter.beginNativePainting()).
                     estack.callback(lambda oua=orig_unpack_alignment: GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, oua))
                 PyGL.glTexSubImage1D(
                     PyGL.GL_TEXTURE_1D, 0, 0, desired_tex_width, GL.GL_RED,
                     GL.GL_UNSIGNED_INT,
                     memoryview(histogram)
                 )
                 tex.serial = self._layer_data_serial
                 self._tex = tex
             glQuad = GL_QUAD()
             if not glQuad.buffer.bind():
                 Qt.qDebug('GL_QUAD.buffer.bind() failed')
                 return
             estack.callback(glQuad.buffer.release)
             glQuad.vao.bind()
             estack.callback(glQuad.vao.release)
             if not prog.bind():
                 Qt.qDebug('prog.bind() failed')
                 return
             estack.callback(prog.release)
             vert_coord_loc = prog.attributeLocation('vert_coord')
             if vert_coord_loc < 0:
                 Qt.qDebug('vert_coord_loc < 0')
                 return
             prog.enableAttributeArray(vert_coord_loc)
             prog.setAttributeBuffer(vert_coord_loc, GL.GL_FLOAT, 0, 2, 0)
             prog.setUniformValue('tex', 0)
             dpi_ratio = widget.devicePixelRatio()
             prog.setUniformValue('inv_view_size', 1/(dpi_ratio * widget_size.width()), 1/(dpi_ratio * widget_size.height()))
             prog.setUniformValue('x_offset', (h_r[0] - r[0]) / w)
             prog.setUniformValue('x_factor', h_w / w)
             inv_max_transformed_bin_val = max_bin_val**-self.gamma_gamma
             prog.setUniformValue('inv_max_transformed_bin_val', inv_max_transformed_bin_val)
             prog.setUniformValue('gamma_gamma', self.gamma_gamma)
             prog.setUniformValue('opacity', self.opacity())
             if histogram_alternate_column_shading_enabled:
                 prog.setUniformValue('bin_count', int(histogram.shape[-1]))
             self.set_blend(estack)
             GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
             GL.glDrawArrays(GL.GL_TRIANGLE_FAN, 0, 4)
Exemplo n.º 10
0
 def on_loaded(self):
     super().on_loaded()
     if not MandelbrotWidget._QML_REGISTERED:
         Qt.qmlRegisterType(Mandelbrot, 'MandelbrotImport', 1, 0, 'Mandelbrot')
         MandelbrotWidget._QML_REGISTERED = True
     self.rootObject().setProperty('mandelbrot', self.mandelbrot)
Exemplo n.º 11
0
    def keyPressEvent(self, event):
        if self.open_connection_button.isEnabled() \
                or self.deactivate_autonomy_button.isEnabled():
            return

        key = event.key()

        if not event.isAutoRepeat():
            # Driving logic
            if key == QtCore.Qt.Key_W:
                if key not in self.drive_keys_pressed:
                    self.drive_keys_pressed.append(key)

                forwarding_prefix = ForwardingPrefix.MOTOR.value
                sub_messages = {
                    'l': MOTOR_SPEEDS[Motor.DRIVE_MOTORS.value],
                    'r': MOTOR_SPEEDS[Motor.DRIVE_MOTORS.value]
                }
                message = Message(forwarding_prefix, sub_messages).message
                self.client.send_message(message)
            elif key == QtCore.Qt.Key_S:
                if key not in self.drive_keys_pressed:
                    self.drive_keys_pressed.append(key)

                forwarding_prefix = ForwardingPrefix.MOTOR.value
                sub_messages = {
                    'l': -1 * MOTOR_SPEEDS[Motor.DRIVE_MOTORS.value],
                    'r': -1 * MOTOR_SPEEDS[Motor.DRIVE_MOTORS.value]
                }
                message = Message(forwarding_prefix, sub_messages).message
                self.client.send_message(message)
            elif key == QtCore.Qt.Key_A:
                if key not in self.drive_keys_pressed:
                    self.drive_keys_pressed.append(key)

                forwarding_prefix = ForwardingPrefix.MOTOR.value
                sub_messages = {
                    'l': -1 * MOTOR_SPEEDS[Motor.DRIVE_MOTORS.value],
                    'r': 1 * MOTOR_SPEEDS[Motor.DRIVE_MOTORS.value]
                }
                message = Message(forwarding_prefix, sub_messages).message
                self.client.send_message(message)
            elif key == QtCore.Qt.Key_D:
                if key not in self.drive_keys_pressed:
                    self.drive_keys_pressed.append(key)

                forwarding_prefix = ForwardingPrefix.MOTOR.value
                sub_messages = {
                    'l': 1 * MOTOR_SPEEDS[Motor.DRIVE_MOTORS.value],
                    'r': -1 * MOTOR_SPEEDS[Motor.DRIVE_MOTORS.value]
                }
                message = Message(forwarding_prefix, sub_messages).message
                self.client.send_message(message)

            # Motor speed adjustment mode logic
            elif key == QtCore.Qt.Key_1:
                self.motor_speed_to_adjust = Motor.DRIVE_MOTORS.value
                print 'Motor speed adjustment mode:', str(
                    self.motor_speed_to_adjust)
            elif key == QtCore.Qt.Key_2:
                self.motor_speed_to_adjust = Motor.ACTUATOR.value
                print 'Motor speed adjustment mode:', str(
                    self.motor_speed_to_adjust)
            elif key == QtCore.Qt.Key_3:
                self.motor_speed_to_adjust = Motor.BUCKET.value
                print 'Motor speed adjustment mode:', str(
                    self.motor_speed_to_adjust)

            # Actuator logic
            elif key == QtCore.Qt.Key_U:
                if key not in self.actuator_keys_pressed:
                    self.actuator_keys_pressed.append(key)

                forwarding_prefix = ForwardingPrefix.MOTOR.value
                sub_messages = {'a': MOTOR_SPEEDS[Motor.ACTUATOR.value]}
                message = Message(forwarding_prefix, sub_messages).message
                self.client.send_message(message)
            elif key == QtCore.Qt.Key_J:
                if key not in self.actuator_keys_pressed:
                    self.actuator_keys_pressed.append(key)

                forwarding_prefix = ForwardingPrefix.MOTOR.value
                sub_messages = {'a': -1 * MOTOR_SPEEDS[Motor.ACTUATOR.value]}
                message = Message(forwarding_prefix, sub_messages).message
                self.client.send_message(message)

            # Bucket logic
            elif key == QtCore.Qt.Key_I:
                if key not in self.bucket_keys_pressed:
                    self.bucket_keys_pressed.append(key)

                forwarding_prefix = ForwardingPrefix.MOTOR.value
                sub_messages = {'b': MOTOR_SPEEDS[Motor.BUCKET.value]}
                message = Message(forwarding_prefix, sub_messages).message
                self.client.send_message(message)
            elif key == QtCore.Qt.Key_K:
                if key not in self.bucket_keys_pressed:
                    self.bucket_keys_pressed.append(key)

                forwarding_prefix = ForwardingPrefix.MOTOR.value
                sub_messages = {'b': -1 * MOTOR_SPEEDS[Motor.BUCKET.value]}
                message = Message(forwarding_prefix, sub_messages).message
                self.client.send_message(message)

        # Motor speed adjustment logic
        if key == QtCore.Qt.Key_Up:
            if MOTOR_SPEEDS[self.motor_speed_to_adjust] < MAX_MOTOR_SPEED:
                MOTOR_SPEEDS[self.motor_speed_to_adjust] += 1
                print MOTOR_SPEEDS[self.motor_speed_to_adjust]
                if len(self.drive_keys_pressed):
                    self.keyPressEvent(
                        Qt.QKeyEvent(Qt.QEvent.KeyPress,
                                     self.drive_keys_pressed[-1],
                                     QtCore.Qt.NoModifier))
        elif key == QtCore.Qt.Key_Down:
            if MOTOR_SPEEDS[self.motor_speed_to_adjust] > 0:
                MOTOR_SPEEDS[self.motor_speed_to_adjust] -= 1
                print MOTOR_SPEEDS[self.motor_speed_to_adjust]
                if len(self.drive_keys_pressed):
                    self.keyPressEvent(
                        Qt.QKeyEvent(Qt.QEvent.KeyPress,
                                     self.drive_keys_pressed[-1],
                                     QtCore.Qt.NoModifier))
Exemplo n.º 12
0
 def closeEvent(self, event):
     self.settings = Qt.QSettings("GNU Radio", "top_block")
     self.settings.setValue("geometry", self.saveGeometry())
     event.accept()
Exemplo n.º 13
0
    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")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 45
        self.nfilts = nfilts = 25
        self.samp_rate = samp_rate = 44.1E3
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts)
        self.fc_slider = fc_slider = 2200

        self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base()


        ##################################################
        # Blocks
        ##################################################
        self._fc_slider_range = Range(0, 18200, 200, 2200, 150)
        self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, 'fc', "counter_slider", float)
        self.top_layout.addWidget(self._fc_slider_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	1 #number of inputs
        )
        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)

        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        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 xrange(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_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=BPSK,
          differential=True,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=0.25,
          verbose=False,
          log=False,
          )
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
        	itemsize=gr.sizeof_char*1,
        	addr='127.0.0.1',
        	port=1235,
        	server=True,
        )
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=1,
        		bits_per_symbol=1,
        		preamble='',
        		access_code='',
        		pad_for_usrp=False,
        	),
        	payload_length=1,
        )
        self.audio_sink_0 = audio.sink(44100, '', True)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, fc_slider, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_constellation_modulator_0, 0))
        self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_complex_to_real_1, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_1, 0))
        self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_xx_0, 0))
Exemplo n.º 14
0
class FiltersWindowView(BaseMainWindowView):
    auto_update_triggered = Qt.pyqtSignal()

    splitter: QSplitter
    collapseToggleButton: QPushButton

    linkImages: QCheckBox
    showHistogramLegend: QCheckBox
    combinedHistograms: QCheckBox
    invertDifference: QCheckBox
    overlayDifference: QCheckBox

    previewsLayout: QVBoxLayout
    previews: FilterPreviews
    stackSelector: StackSelectorWidgetView

    notification_icon: QLabel
    notification_text: QLabel

    presenter: FiltersWindowPresenter

    applyButton: QPushButton
    applyToAllButton: QPushButton
    filterSelector: QComboBox

    def __init__(self, main_window: 'MainWindowView'):
        super(FiltersWindowView, self).__init__(main_window,
                                                'gui/ui/filters_window.ui')

        self.main_window = main_window
        self.presenter = FiltersWindowPresenter(self, main_window)
        self.roi_view = None
        self.roi_view_averaged = False
        self.splitter.setSizes([200, 9999])
        self.splitter.setStretchFactor(0, 1)

        # Populate list of operations and handle filter selection
        self.filterSelector.addItems(self.presenter.model.filter_names)
        self.filterSelector.currentTextChanged.connect(
            self.handle_filter_selection)
        self.filterSelector.currentTextChanged.connect(
            self._update_apply_all_button)
        self.handle_filter_selection("")

        # Handle stack selection
        self.stackSelector.stack_selected_uuid.connect(
            self.presenter.set_stack_uuid)
        self.stackSelector.stack_selected_uuid.connect(
            self.auto_update_triggered.emit)

        # Handle apply filter
        self.applyButton.clicked.connect(
            lambda: self.presenter.notify(PresNotification.APPLY_FILTER))
        self.applyToAllButton.clicked.connect(lambda: self.presenter.notify(
            PresNotification.APPLY_FILTER_TO_ALL))

        self.previews = FilterPreviews(self)
        self.previews.setSizePolicy(QSizePolicy.Expanding,
                                    QSizePolicy.Expanding)
        self.previewsLayout.addWidget(self.previews)
        self.clear_previews()

        self.combinedHistograms.stateChanged.connect(
            self.histogram_mode_changed)
        self.showHistogramLegend.stateChanged.connect(
            self.histogram_legend_is_changed)
        # set here to trigger the changed event
        self.showHistogramLegend.setChecked(True)

        self.linkImages.stateChanged.connect(self.link_images_changed)
        # set here to trigger the changed event
        self.linkImages.setChecked(True)
        self.invertDifference.stateChanged.connect(
            lambda: self.presenter.notify(PresNotification.UPDATE_PREVIEWS))
        self.overlayDifference.stateChanged.connect(
            lambda: self.presenter.notify(PresNotification.UPDATE_PREVIEWS))

        # Handle preview index selection
        self.previewImageIndex.valueChanged[int].connect(
            self.presenter.set_preview_image_index)

        # Preview update triggers
        self.auto_update_triggered.connect(self.on_auto_update_triggered)
        self.updatePreviewButton.clicked.connect(
            lambda: self.presenter.notify(PresNotification.UPDATE_PREVIEWS))

        self.stackSelector.subscribe_to_main_window(main_window)
        self.stackSelector.select_eligible_stack()

        # Handle help button pressed
        self.filterHelpButton.pressed.connect(self.open_help_webpage)
        self.collapseToggleButton.pressed.connect(self.toggle_filters_section)

    def cleanup(self):
        self.stackSelector.unsubscribe_from_main_window()
        if self.roi_view is not None:
            self.roi_view.close()
            self.roi_view = None
        self.auto_update_triggered.disconnect()
        self.main_window.filters = None
        self.presenter = None

    def show(self):
        super(FiltersWindowView, self).show()
        self.auto_update_triggered.emit()

    def handle_filter_selection(self, filter_name: str):
        """
        Handle selection of a filter from the drop down list.
        """
        # If a divider select the one below the divider.
        if filter_name == self.presenter.divider:
            self.filterSelector.setCurrentIndex(
                self.filterSelector.currentIndex() + 1)

        # Remove all existing items from the properties layout
        delete_all_widgets_from_layout(self.filterPropertiesLayout)

        # Do registration of new filter
        self.presenter.notify(PresNotification.REGISTER_ACTIVE_FILTER)

        # Update preview on filter selection (on the off chance the default
        # options are valid)
        self.auto_update_triggered.emit()

    def on_auto_update_triggered(self):
        """
        Called when the signal indicating the filter, filter properties or data
        has changed such that the previews are now out of date.
        """
        self.clear_notification_dialog()
        if self.previewAutoUpdate.isChecked() and self.isVisible():
            self.presenter.notify(PresNotification.UPDATE_PREVIEWS)

    def clear_previews(self):
        self.previews.clear_items()

    def histogram_mode_changed(self):
        combined_histograms = self.combinedHistograms.isChecked()
        self.previews.combined_histograms = combined_histograms

        # Clear old histogram bits
        self.previews.delete_histograms()
        self.previews.delete_histogram_labels()

        # Init the correct histograms
        if combined_histograms:
            self.previews.init_histogram()
        else:
            self.previews.init_separate_histograms()
        self.previews.update_histogram_data()

    def histogram_legend_is_changed(self):
        self.previews.histogram_legend_visible = self.showHistogramLegend.isChecked(
        )
        legend = self.previews.histogram_legend
        if legend:
            if self.showHistogramLegend.isChecked():
                legend.show()
            else:
                legend.hide()

    def link_images_changed(self):
        if self.linkImages.isChecked():
            self.previews.link_all_views()
        else:
            self.previews.unlink_all_views()

    @property
    def preview_image_before(self) -> ImageItem:
        return self.previews.image_before

    @property
    def preview_image_after(self) -> ImageItem:
        return self.previews.image_after

    @property
    def preview_image_difference(self) -> ImageItem:
        return self.previews.image_difference

    def show_error_dialog(self, msg=""):
        self.notification_text.show()
        self.notification_icon.setPixmap(QApplication.style().standardPixmap(
            QStyle.SP_MessageBoxCritical))
        self.notification_text.setText(str(msg))

    def clear_notification_dialog(self):
        self.notification_icon.clear()
        self.notification_text.clear()
        self.notification_text.hide()

    def show_operation_completed(self, operation_name):
        self.notification_text.show()
        self.notification_icon.setPixmap(QApplication.style().standardPixmap(
            QStyle.SP_DialogYesButton))
        self.notification_text.setText(
            f"{operation_name} completed successfully!")

    def open_help_webpage(self):
        filter_module_path = self.presenter.get_filter_module_name(
            self.filterSelector.currentIndex())
        try:
            open_api_webpage(filter_module_path)
        except RuntimeError as err:
            self.show_error_dialog(str(err))

    def ask_confirmation(self, msg: str):
        response = QMessageBox.question(self, "Confirm action", msg,
                                        QMessageBox.Ok
                                        | QMessageBox.Cancel)  # type:ignore
        return response == QMessageBox.Ok

    def _update_apply_all_button(self, filter_name):
        list_of_apply_single_stack = ["ROI Normalisation", "Flat-fielding"]
        if filter_name in list_of_apply_single_stack:
            self.applyToAllButton.setEnabled(False)
        else:
            self.applyToAllButton.setEnabled(True)

    def roi_visualiser(self, roi_field):
        # Start the stack visualiser and ensure that it uses the ROI from here in the rest of this
        try:
            images = self.presenter.stack.presenter.get_image(
                self.presenter.model.preview_image_idx)
        except Exception:
            # Happens if nothing has been loaded, so do nothing as nothing can't be visualised
            return

        window = QMainWindow(self)
        window.setWindowTitle("Select ROI")
        window.setMinimumHeight(600)
        window.setMinimumWidth(600)
        self.roi_view = MIImageView(window)
        window.setCentralWidget(self.roi_view)
        self.roi_view.setWindowTitle("Select ROI for operation")

        def toggle_average_images(images_):
            if self.roi_view_averaged:
                self.roi_view.setImage(images_.data)
                self.roi_view_averaged = False
            else:
                averaged_images = np.sum(
                    self.presenter.stack.presenter.images.data, axis=0)
                self.roi_view.setImage(averaged_images)
                self.roi_view_averaged = True
            self.roi_view.roi.show()
            self.roi_view.ui.roiPlot.hide()

        # Add context menu bits:
        menu = QMenu(self.roi_view)
        toggle_show_averaged_image = QAction("Toggle show averaged image",
                                             menu)
        toggle_show_averaged_image.triggered.connect(
            lambda: toggle_average_images(images))
        menu.addAction(toggle_show_averaged_image)
        menu.addSeparator()
        self.roi_view.imageItem.menu = menu

        self.roi_view.setImage(images.data)

        def roi_changed_callback(callback):
            roi_field.setText(callback.to_list_string())
            roi_field.editingFinished.emit()

        self.roi_view.roi_changed_callback = lambda callback: roi_changed_callback(
            callback)

        # prep the MIImageView to display in this context
        self.roi_view.ui.roiBtn.hide()
        self.roi_view.ui.histogram.hide()
        self.roi_view.ui.menuBtn.hide()
        self.roi_view.ui.roiPlot.hide()
        self.roi_view.roi.show()
        self.roi_view.ui.gridLayout.setRowStretch(1, 5)
        self.roi_view.ui.gridLayout.setRowStretch(0, 95)
        self.roi_view.button_stack_right.hide()
        self.roi_view.button_stack_left.hide()
        button = QPushButton("OK", window)
        button.clicked.connect(lambda: window.close())
        self.roi_view.ui.gridLayout.addWidget(button)

        window.show()

    def toggle_filters_section(self):
        if self.collapseToggleButton.text() == "<<":
            self.splitter.setSizes([0, 9999])
            self.collapseToggleButton.setText(">>")
        else:
            self.splitter.setSizes([200, 9999])
            self.collapseToggleButton.setText("<<")
Exemplo n.º 15
0
def _register_qml_types():
    Qt.qmlRegisterType(SimpleListModel, 'Analysis', 1, 0, 'SimpleListModel')
    Qt.qmlRegisterType(ManualFocusScore, 'Analysis', 1, 0, 'ManualFocusScore')
    Qt.qmlRegisterType(ExperimentManualFocusScorer, 'Analysis', 1, 0, 'ExperimentManualFocusScorer')
Exemplo n.º 16
0
    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")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.variable_function_probe_0 = variable_function_probe_0 = 0
        self.sample_rate = sample_rate = 1e6
        self.vector_length = vector_length = 1
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = variable_function_probe_0
        self.suppress_tune_transients_chooser = suppress_tune_transients_chooser = 0
        self.source_min_output_buffer = source_min_output_buffer = 2**14*4
        self.max_sample_rate = max_sample_rate = 122.88e6
        self.max_attenuation = max_attenuation = 5000
        self.center_freq = center_freq = 915e6
        self.bandwidth = bandwidth = sample_rate
        self.atten_quart_db = atten_quart_db = 55

        ##################################################
        # Blocks
        ##################################################
        self._sample_rate_range = Range(0.1e6, max_sample_rate, 0.1e6, 1e6, 200)
        self._sample_rate_win = RangeWidget(self._sample_rate_range, self.set_sample_rate, 'Sample Rate', "counter_slider", float)
        self.top_grid_layout.addWidget(self._sample_rate_win, 1, 0, 1, 1)
        [self.top_grid_layout.setRowStretch(r,1) for r in range(1,2)]
        [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,1)]
        self._suppress_tune_transients_chooser_options = (0, 1, )
        self._suppress_tune_transients_chooser_labels = ('False', 'True', )
        self._suppress_tune_transients_chooser_tool_bar = Qt.QToolBar(self)
        self._suppress_tune_transients_chooser_tool_bar.addWidget(Qt.QLabel('Suppress Tune Transients'+": "))
        self._suppress_tune_transients_chooser_combo_box = Qt.QComboBox()
        self._suppress_tune_transients_chooser_tool_bar.addWidget(self._suppress_tune_transients_chooser_combo_box)
        for label in self._suppress_tune_transients_chooser_labels: self._suppress_tune_transients_chooser_combo_box.addItem(label)
        self._suppress_tune_transients_chooser_callback = lambda i: Qt.QMetaObject.invokeMethod(self._suppress_tune_transients_chooser_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._suppress_tune_transients_chooser_options.index(i)))
        self._suppress_tune_transients_chooser_callback(self.suppress_tune_transients_chooser)
        self._suppress_tune_transients_chooser_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_suppress_tune_transients_chooser(self._suppress_tune_transients_chooser_options[i]))
        self.top_layout.addWidget(self._suppress_tune_transients_chooser_tool_bar)
        self._center_freq_range = Range(100e6, 6000e6, 1e6, 915e6, 200)
        self._center_freq_win = RangeWidget(self._center_freq_range, self.set_center_freq, 'Frequency', "counter_slider", float)
        self.top_grid_layout.addWidget(self._center_freq_win, 0, 0, 1, 1)
        [self.top_grid_layout.setRowStretch(r,1) for r in range(0,1)]
        [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,1)]
        self.blocks_probe_rate_0 = blocks.probe_rate(gr.sizeof_gr_complex*1, 500.0, 0.15)
        self._bandwidth_range = Range(0.1e6, max_sample_rate, 0.1e6, sample_rate, 200)
        self._bandwidth_win = RangeWidget(self._bandwidth_range, self.set_bandwidth, 'Bandwidth', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bandwidth_win, 1, 1, 1, 1)
        [self.top_grid_layout.setRowStretch(r,1) for r in range(1,2)]
        [self.top_grid_layout.setColumnStretch(c,1) for c in range(1,2)]
        self._atten_quart_db_range = Range(1, max_attenuation, 1, 55, 200)
        self._atten_quart_db_win = RangeWidget(self._atten_quart_db_range, self.set_atten_quart_db, 'Attenuation ', "counter_slider", float)
        self.top_grid_layout.addWidget(self._atten_quart_db_win, 0, 1, 1, 1)
        [self.top_grid_layout.setRowStretch(r,1) for r in range(0,1)]
        [self.top_grid_layout.setColumnStretch(c,1) for c in range(1,2)]
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)

        if None:
          self._variable_qtgui_label_0_formatter = None
        else:
          self._variable_qtgui_label_0_formatter = lambda x: eng_notation.num_to_str(x)

        self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Rx Rate'+": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 5, 0, 1, 1)
        [self.top_grid_layout.setRowStretch(r,1) for r in range(5,6)]
        [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,1)]

        def _variable_function_probe_0_probe():
            while True:
                val = self.blocks_probe_rate_0.rate()
                try:
                    self.set_variable_function_probe_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))
        _variable_function_probe_0_thread = threading.Thread(target=_variable_function_probe_0_probe)
        _variable_function_probe_0_thread.daemon = True
        _variable_function_probe_0_thread.start()

        self.sidekiq_sidekiq_tx_0 = sidekiq.sidekiq_tx(sample_rate, atten_quart_db, center_freq, bandwidth, 1, bool(suppress_tune_transients_chooser),
                0, 32764, ())

        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_gr_complex*1, '', ""); self.blocks_tag_debug_0.set_display(True)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.analog_sig_source_x_0 = analog.sig_source_c(sample_rate, analog.GR_COS_WAVE, 1000, 0, 0)
        (self.analog_sig_source_x_0).set_min_output_buffer(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.sidekiq_sidekiq_tx_0, 'telemetry'), (self.blocks_message_debug_0, 'print'))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_probe_rate_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_tag_debug_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0), (self.sidekiq_sidekiq_tx_0, 0))
Exemplo n.º 17
0
 def showEvent(self, event: Qt.QShowEvent) -> None:
     super().showEvent(event)
     self.graphics_view.setSizePolicy(
         Qt.QSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding))
Exemplo n.º 18
0
 def sizeHint(self):
     """Overwritten QWidget.sizeHint"""
     return Qt.QSize(640, 480)
Exemplo n.º 19
0
    def __init__(self):
        parser = ArgumentParser()
        parser.add_argument("-f", "--file", dest="filename", 
                    help="write record to FILE", metavar="FILE", required=True)
        args = parser.parse_args()
        print("Writing to file {}".format(args.filename))

        gr.top_block.__init__(self, "Not titled yet")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Not titled yet")
        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", "somfy_record")

        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.samp_rate = samp_rate = 2.4e6
        self.fmid = fmid = 868.949e6
        self.filename = filename = "./" + args.filename

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + ''
        )
        self.rtlsdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(fmid, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, filename, False)
        self.blocks_file_sink_0.set_unbuffered(False)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_file_sink_0, 0))
Exemplo n.º 20
0
    def __init__(self):
        gr.top_block.__init__(self, "twodimension_usrp_b210s")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("twodimension_usrp_b210s")
        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", "twodimension_usrp_b210s")

        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.maxtheta = maxtheta = 150
        self.columns = columns = 100
        self.shiftarrL = shiftarrL = np.radians(
            np.linspace(start=maxtheta,
                        stop=0,
                        num=int(columns / 2),
                        endpoint=False))
        self.left = left = np.pad(shiftarrL, (0, int(columns / 2)), 'constant')
        self.variable_function_probe_0_0 = variable_function_probe_0_0 = 0
        self.variable_function_probe_0 = variable_function_probe_0 = 1
        self.right = right = np.flip(left, axis=0)
        self.variable_qtgui_label_0_0_0_0 = variable_qtgui_label_0_0_0_0 = variable_function_probe_0_0
        self.variable_qtgui_label_0_0_0 = variable_qtgui_label_0_0_0 = variable_function_probe_0
        self.variable_qtgui_label_0_0 = variable_qtgui_label_0_0 = left
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = right
        self.threshold = threshold = -60
        self.scale = scale = 20000
        self.samp_rate = samp_rate = 100e3
        self.minmag = minmag = 0
        self.maxmag = maxmag = .0035
        self.keep = keep = 50
        self.gain = gain = 20
        self.freq = freq = 422e6
        self.displayscale = displayscale = 5

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'Time rasters')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'Steering vectors')
        self.top_grid_layout.addWidget(self.tab)
        self._scale_range = Range(0, 60000, 1000, 20000, 200)
        self._scale_win = RangeWidget(self._scale_range, self.set_scale,
                                      'scale', "counter_slider", float)
        self.top_grid_layout.addWidget(self._scale_win)
        self.blocks_probe_signal_x_0_0 = blocks.probe_signal_f()
        self.blocks_probe_signal_x_0 = blocks.probe_signal_f()
        self.video_sdl_sink_1_1_0 = video_sdl.sink_s(0, columns, columns, 0,
                                                     columns * displayscale,
                                                     columns * displayscale)
        self._variable_qtgui_label_0_0_0_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_0_0_0_formatter = None
        else:
            self._variable_qtgui_label_0_0_0_0_formatter = lambda x: str(x)

        self._variable_qtgui_label_0_0_0_0_tool_bar.addWidget(
            Qt.QLabel('Probe Signal Min' + ": "))
        self._variable_qtgui_label_0_0_0_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_0_0_0_formatter(
                    self.variable_qtgui_label_0_0_0_0)))
        self._variable_qtgui_label_0_0_0_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_0_0_0_label)
        self.top_grid_layout.addWidget(
            self._variable_qtgui_label_0_0_0_0_tool_bar)
        self._variable_qtgui_label_0_0_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_0_0_formatter = None
        else:
            self._variable_qtgui_label_0_0_0_formatter = lambda x: str(x)

        self._variable_qtgui_label_0_0_0_tool_bar.addWidget(
            Qt.QLabel('Probe Signal Max' + ": "))
        self._variable_qtgui_label_0_0_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_0_0_formatter(
                    self.variable_qtgui_label_0_0_0)))
        self._variable_qtgui_label_0_0_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_0_0_label)
        self.top_grid_layout.addWidget(
            self._variable_qtgui_label_0_0_0_tool_bar)
        self._variable_qtgui_label_0_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_0_formatter = None
        else:
            self._variable_qtgui_label_0_0_formatter = lambda x: repr(x)

        self._variable_qtgui_label_0_0_tool_bar.addWidget(
            Qt.QLabel('variable_qtgui_label_0_0' + ": "))
        self._variable_qtgui_label_0_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_0_formatter(
                    self.variable_qtgui_label_0_0)))
        self._variable_qtgui_label_0_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_0_label)
        self.tab_layout_1.addWidget(self._variable_qtgui_label_0_0_tool_bar)
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_formatter = None
        else:
            self._variable_qtgui_label_0_formatter = lambda x: repr(x)

        self._variable_qtgui_label_0_tool_bar.addWidget(
            Qt.QLabel('variable_qtgui_label_0' + ": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_formatter(
                    self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_label)
        self.tab_layout_1.addWidget(self._variable_qtgui_label_0_tool_bar)

        def _variable_function_probe_0_0_probe():
            while True:

                val = self.blocks_probe_signal_x_0_0.level()
                try:
                    self.set_variable_function_probe_0_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1))

        _variable_function_probe_0_0_thread = threading.Thread(
            target=_variable_function_probe_0_0_probe)
        _variable_function_probe_0_0_thread.daemon = True
        _variable_function_probe_0_0_thread.start()

        def _variable_function_probe_0_probe():
            while True:

                val = self.blocks_probe_signal_x_0.level()
                try:
                    self.set_variable_function_probe_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1))

        _variable_function_probe_0_thread = threading.Thread(
            target=_variable_function_probe_0_probe)
        _variable_function_probe_0_thread.daemon = True
        _variable_function_probe_0_thread.start()

        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("", "type=b200, name=origb210")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 2)),
            ),
        )
        self.uhd_usrp_source_0_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0_0.set_gain(gain, 0)
        self.uhd_usrp_source_0_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0_0.set_center_freq(freq, 1)
        self.uhd_usrp_source_0_0.set_gain(gain, 1)
        self.uhd_usrp_source_0_0.set_antenna('RX2', 1)
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "type=b200, name=newb210")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 2)),
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_center_freq(freq, 1)
        self.uhd_usrp_source_0.set_gain(gain, 1)
        self.uhd_usrp_source_0.set_antenna('RX2', 1)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self._threshold_range = Range(-160, -10, 5, -60, 200)
        self._threshold_win = RangeWidget(self._threshold_range,
                                          self.set_threshold,
                                          'squelch threshold',
                                          "counter_slider", int)
        self.top_grid_layout.addWidget(self._threshold_win)
        self.qtgui_time_raster_sink_x_0_0 = qtgui.time_raster_sink_f(
            samp_rate / keep, columns, columns, [], [], "Elevation", 1)

        self.qtgui_time_raster_sink_x_0_0.set_update_time(0.01)
        self.qtgui_time_raster_sink_x_0_0.set_intensity_range(minmag, maxmag)
        self.qtgui_time_raster_sink_x_0_0.enable_grid(False)
        self.qtgui_time_raster_sink_x_0_0.enable_axis_labels(True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 1, 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_time_raster_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_raster_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_raster_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_time_raster_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_raster_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_raster_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_time_raster_sink_x_0_0_win)
        self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_f(
            samp_rate / keep, columns, columns, [], [], "Azimuth", 1)

        self.qtgui_time_raster_sink_x_0.set_update_time(0.01)
        self.qtgui_time_raster_sink_x_0.set_intensity_range(minmag, maxmag)
        self.qtgui_time_raster_sink_x_0.enable_grid(False)
        self.qtgui_time_raster_sink_x_0.enable_axis_labels(True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 1, 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_time_raster_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_time_raster_sink_x_0_win)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, columns)
        self.blocks_vector_source_x_0_0_0_1 = blocks.vector_source_f(
            left, True, 1, [])
        self.blocks_vector_source_x_0_0_0_0_0 = blocks.vector_source_f(
            right, True, 1, [])
        self.blocks_vector_source_x_0_0_0_0 = blocks.vector_source_f(
            right, True, 1, [])
        self.blocks_vector_source_x_0_0_0 = blocks.vector_source_f(
            left, True, 1, [])
        self.blocks_sub_xx_0_0_1 = blocks.sub_ff(1)
        self.blocks_sub_xx_0_0_0_0 = blocks.sub_ff(1)
        self.blocks_sub_xx_0_0_0 = blocks.sub_ff(1)
        self.blocks_sub_xx_0_0 = blocks.sub_ff(1)
        self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(
            gr.sizeof_float * 1, int(samp_rate / keep))
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, columns)
        self.blocks_repeat_0_0_0_0_2 = blocks.repeat(gr.sizeof_float * 1,
                                                     columns)
        self.blocks_repeat_0_0_0_0_1_0 = blocks.repeat(gr.sizeof_float * 1,
                                                       columns)
        self.blocks_repeat_0_0_0_0_1 = blocks.repeat(gr.sizeof_float * 1,
                                                     columns)
        self.blocks_repeat_0_0_0_0_0_1_0 = blocks.repeat(
            gr.sizeof_float * 1, columns)
        self.blocks_repeat_0_0_0_0_0_1 = blocks.repeat(gr.sizeof_float * 1,
                                                       columns)
        self.blocks_repeat_0_0_0_0_0_0 = blocks.repeat(gr.sizeof_float * 1,
                                                       columns)
        self.blocks_repeat_0_0_0_0_0 = blocks.repeat(gr.sizeof_float * 1,
                                                     columns)
        self.blocks_repeat_0_0_0_0 = blocks.repeat(gr.sizeof_float * 1,
                                                   columns)
        self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_gr_complex * columns,
                                               columns)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, columns)
        self.blocks_min_xx_0 = blocks.min_ff(int(samp_rate / keep), 1)
        self.blocks_max_xx_0 = blocks.max_ff(int(samp_rate / keep), 1)
        self.blocks_magphase_to_complex_0_0_0_0_1 = blocks.magphase_to_complex(
            1)
        self.blocks_magphase_to_complex_0_0_0_0_0_0 = blocks.magphase_to_complex(
            1)
        self.blocks_magphase_to_complex_0_0_0_0_0 = blocks.magphase_to_complex(
            1)
        self.blocks_magphase_to_complex_0_0_0_0 = blocks.magphase_to_complex(1)
        self.blocks_keep_one_in_n_0_2 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * 1, keep)
        self.blocks_keep_one_in_n_0_1 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * 1, keep)
        self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * 1, keep)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * 1, keep)
        self.blocks_float_to_short_0_1_0 = blocks.float_to_short(1, scale)
        self.blocks_complex_to_magphase_0_0_0_1 = blocks.complex_to_magphase(1)
        self.blocks_complex_to_magphase_0_0_0_0_0 = blocks.complex_to_magphase(
            1)
        self.blocks_complex_to_magphase_0_0_0_0 = blocks.complex_to_magphase(1)
        self.blocks_complex_to_magphase_0_0_0 = blocks.complex_to_magphase(1)
        self.blocks_complex_to_mag_squared_0_1 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_pwr_squelch_xx_0_1 = analog.pwr_squelch_cc(
            -60, 1e-4, 0, False)
        self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(
            -60, 1e-4, 0, False)
        self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(
            -60, 1e-4, 0, False)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(
            -60, 1e-4, 0, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.blocks_keep_one_in_n_0_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0_0, 0),
                     (self.blocks_keep_one_in_n_0_1, 0))
        self.connect((self.analog_pwr_squelch_xx_0_1, 0),
                     (self.blocks_keep_one_in_n_0_2, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.blocks_complex_to_mag_squared_0_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.qtgui_time_raster_sink_x_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.qtgui_time_raster_sink_x_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_1, 0),
                     (self.blocks_float_to_short_0_1_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_1, 0),
                     (self.blocks_stream_to_vector_0_1, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0, 0),
                     (self.blocks_repeat_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0, 1),
                     (self.blocks_repeat_0_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_0, 1),
                     (self.blocks_repeat_0_0_0_0_0_1, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_0, 0),
                     (self.blocks_repeat_0_0_0_0_1, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_0_0, 1),
                     (self.blocks_repeat_0_0_0_0_0_1_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_0_0, 0),
                     (self.blocks_repeat_0_0_0_0_1_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_1, 1),
                     (self.blocks_repeat_0_0_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_magphase_0_0_0_1, 0),
                     (self.blocks_repeat_0_0_0_0_2, 0))
        self.connect((self.blocks_float_to_short_0_1_0, 0),
                     (self.video_sdl_sink_1_1_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blocks_complex_to_magphase_0_0_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_0, 0),
                     (self.blocks_complex_to_magphase_0_0_0_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_1, 0),
                     (self.blocks_complex_to_magphase_0_0_0_1, 0))
        self.connect((self.blocks_keep_one_in_n_0_2, 0),
                     (self.blocks_complex_to_magphase_0_0_0_0_0, 0))
        self.connect((self.blocks_magphase_to_complex_0_0_0_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_magphase_to_complex_0_0_0_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_magphase_to_complex_0_0_0_0_0_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.blocks_magphase_to_complex_0_0_0_0_1, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.blocks_max_xx_0, 0),
                     (self.blocks_probe_signal_x_0, 0))
        self.connect((self.blocks_min_xx_0, 0),
                     (self.blocks_probe_signal_x_0_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_repeat_0_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_0, 0),
                     (self.blocks_sub_xx_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_0_0, 0),
                     (self.blocks_sub_xx_0_0_1, 0))
        self.connect((self.blocks_repeat_0_0_0_0_0_1, 0),
                     (self.blocks_sub_xx_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_0_1_0, 0),
                     (self.blocks_sub_xx_0_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_1, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_1_0, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0_0_0, 0))
        self.connect((self.blocks_repeat_0_0_0_0_2, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0_1, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.blocks_repeat_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1, 0),
                     (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1, 0),
                     (self.blocks_min_xx_0, 0))
        self.connect((self.blocks_sub_xx_0_0, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0, 1))
        self.connect((self.blocks_sub_xx_0_0_0, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0_0, 1))
        self.connect((self.blocks_sub_xx_0_0_0_0, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0_0_0, 1))
        self.connect((self.blocks_sub_xx_0_0_1, 0),
                     (self.blocks_magphase_to_complex_0_0_0_0_1, 1))
        self.connect((self.blocks_vector_source_x_0_0_0, 0),
                     (self.blocks_sub_xx_0_0, 1))
        self.connect((self.blocks_vector_source_x_0_0_0_0, 0),
                     (self.blocks_sub_xx_0_0_0, 1))
        self.connect((self.blocks_vector_source_x_0_0_0_0_0, 0),
                     (self.blocks_sub_xx_0_0_0_0, 1))
        self.connect((self.blocks_vector_source_x_0_0_0_1, 0),
                     (self.blocks_sub_xx_0_0_1, 1))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_add_xx_1, 0))
        self.connect((self.uhd_usrp_source_0, 1),
                     (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.analog_pwr_squelch_xx_0_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.analog_pwr_squelch_xx_0_0_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 1),
                     (self.analog_pwr_squelch_xx_0_1, 0))
Exemplo n.º 21
0
    def __init__(self, app, exam_id, users, questions_ids, results_table):
        super().__init__()
        cnt_rows, cnt_columns = len(users), len(questions_ids)
        sums = get_sums(results_table)
        order = sorted([i for i in range(cnt_rows)],
                       key=lambda i: sums[i],
                       reverse=True)
        users = [users[i] for i in order]
        sums = [sums[i] for i in order]
        questions_ids = questions_ids
        results_table = [results_table[i] for i in order]
        style_str = ('padding-left: 15px;'
                     'padding-right: 15px;'
                     'padding-top: 10px;'
                     'padding-bottom: 10px;'
                     'border-radius: 0px;'
                     'border-bottom: 1px solid grey;'
                     'border-right: 1px solid grey;')

        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(lambda: app.display_exam(exam_id))

        results_title = Qt.QLabel('Таблица результатов', self)
        results_title.setFont(Qt.QFont('Arial', 30))

        update_button = Qt.QPushButton(Qt.QIcon(common.UPDATE), '', self)
        update_button.setObjectName('Flat')
        update_button.setCursor(Qt.Qt.PointingHandCursor)
        update_button.setIconSize(Qt.QSize(35, 35))
        update_button.setFixedSize(Qt.QSize(55, 55))
        update_button.clicked.connect(
            lambda: app.display_results_page(exam_id))

        scroll_area = Qt.QScrollArea()
        scroll_area.setFrameShape(Qt.QFrame.NoFrame)

        grid_layout = Qt.QGridLayout()
        grid_layout.setSpacing(0)

        user_column = Qt.QLabel('Участник', self)
        user_column.setFont(Qt.QFont('Arial', 20))
        user_column.setAlignment(Qt.Qt.AlignCenter)
        user_column.setStyleSheet(style_str)
        grid_layout.addWidget(user_column, 0, 0)

        sum_column = Qt.QLabel('Σ', self)
        sum_column.setFont(Qt.QFont('Arial', 20))
        sum_column.setAlignment(Qt.Qt.AlignCenter)
        sum_column.setStyleSheet(style_str)
        grid_layout.addWidget(sum_column, 0, 1)

        for j in range(cnt_columns):
            question_column = Qt.QLabel(str(j + 1), self)
            question_column.setFont(Qt.QFont('Arial', 20))
            question_column.setAlignment(Qt.Qt.AlignCenter)
            question_column.setStyleSheet(style_str)
            grid_layout.addWidget(question_column, 0, j + 2)

        for i in range(cnt_rows):
            user_row = Qt.QLabel(users[i]['name'], self)
            user_row.setFont(Qt.QFont('Arial', 20))
            user_row.setAlignment(Qt.Qt.AlignCenter)
            user_row.setStyleSheet(style_str)
            grid_layout.addWidget(user_row, i + 1, 0)

            sum_cell = Qt.QLabel(str(sums[i]), self)
            sum_cell.setFont(Qt.QFont('Arial', 20))
            sum_cell.setAlignment(Qt.Qt.AlignCenter)
            sum_cell.setStyleSheet(style_str)
            grid_layout.addWidget(sum_cell, i + 1, 1)

        for i in range(cnt_rows):
            for j in range(cnt_columns):
                question_details = common.get_question_details(
                    results_table[i][j])
                question_style = common.main_question_style(
                    results_table[i][j])

                if not results_table[i][j]:
                    cell = Qt.QLabel(' ', self)
                    cell.setFont(Qt.QFont('Arial', 20))
                    cell.setStyleSheet(style_str)
                else:
                    cell = Qt.QPushButton(question_details['score'], self)
                    cell.setObjectName('Flat')
                    cell.setFont(Qt.QFont('Arial', 20))
                    cell.setStyleSheet(style_str + 'color: ' +
                                       question_style['main_color'])
                    cell.setCursor(Qt.Qt.PointingHandCursor)
                    cell.clicked.connect(
                        common.return_lambda(app.display_student_answer_page,
                                             exam_id, questions_ids[j],
                                             users[i]['rowid']))
                grid_layout.addWidget(cell, i + 1, j + 2)

        scroll_widget = Qt.QWidget(self)
        scroll_widget.setLayout(grid_layout)
        scroll_area.setWidget(scroll_widget)

        upper_layout = Qt.QHBoxLayout()
        upper_layout.addWidget(back_button)
        upper_layout.addStretch(1)
        upper_layout.addWidget(results_title)
        upper_layout.addStretch(1)
        upper_layout.addWidget(update_button)

        layout = Qt.QVBoxLayout()
        layout.addLayout(upper_layout)
        layout.addSpacerItem(Qt.QSpacerItem(0, 40))
        layout.addWidget(scroll_area)
        self.setLayout(layout)
Exemplo n.º 22
0
    def start(self, vp):
        from vtkplotter import vtkio

        for r in vp.renderers:
            self.vtkWidget.GetRenderWindow().AddRenderer(r)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()

        self.iren.AddObserver("LeftButtonPressEvent", vtkio._mouseleft)
        self.iren.AddObserver("RightButtonPressEvent", vtkio._mouseright)
        self.iren.AddObserver("MiddleButtonPressEvent", vtkio._mousemiddle)

        def keypress(obj, e):
            vtkio._keypress(obj, e)
            if self.iren.GetKeySym() in ["q", "space"]:
                self.iren.ExitCallback()
                exit()

        self.iren.AddObserver("KeyPressEvent", keypress)
        self.frame.setLayout(self.vl)
        self.setCentralWidget(self.frame)
        self.show()  # qt not Plotter method
        r.ResetCamera()
        self.iren.Start()


if __name__ == "__main__":
    app = Qt.QApplication(sys.argv)
    window = MainWindow()
    app.exec_()
Exemplo n.º 23
0
    def __init__(self):
        gr.top_block.__init__(self, "Blight 1")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Blight 1")
        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", "blight1")
        self.restoreGeometry(
            self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        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)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        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 xrange(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)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol=2,
            sensitivity=1.0,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/jvoss/sno/rf2/flag1.txt', False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_gr_complex * 1, '/home/jvoss/sno/rf2/blight1.bin', False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.digital_gfsk_mod_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_throttle_0, 0))
Exemplo n.º 24
0
    def __init__(self, hdr_format=digital.header_format_default(digital.packet_utils.default_access_code, 0)):
        gr.top_block.__init__(self, "Audio modem FSK loop back test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Audio modem FSK loop back test")
        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")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Parameters
        ##################################################
        self.hdr_format = hdr_format

        ##################################################
        # Variables
        ##################################################
        self.nfilts = nfilts = 32
        self.SPS = SPS = 147
        self.RX_decimation = RX_decimation = 49
        self.EBW = EBW = .05
        self.samp_rate = samp_rate = 44.1E3
        self.fsk_deviation_hz = fsk_deviation_hz = 100
        self.carrier_freq = carrier_freq = 1.75E3

        self.RRC_filter_taps = RRC_filter_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, EBW, 5*SPS*nfilts/RX_decimation)


        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=RX_decimation,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate/RX_decimation, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate/RX_decimation, #bw
        	"", #name
        	1 #number of inputs
        )
        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)

        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        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 xrange(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_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.qtgui_edit_box_msg_0 = qtgui.edit_box_msg(qtgui.STRING, '', '', False, False, '')
        self._qtgui_edit_box_msg_0_win = sip.wrapinstance(self.qtgui_edit_box_msg_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_edit_box_msg_0_win)
        self.epy_block_0 = epy_block_0.msg_block()
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(hdr_format, 'len_key')
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_fff(SPS/RX_decimation, 6.28/400.0*2/70, (RRC_filter_taps), nfilts, nfilts/2, 2, 1)
        self.digital_correlate_access_code_xx_ts_1_0_0 = digital.correlate_access_code_bb_ts(digital.packet_utils.default_access_code,
          2, 'len_key2')
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bf(((2*3.14*carrier_freq-2*3.14*fsk_deviation_hz,2*3.14*carrier_freq+2*3.14*fsk_deviation_hz)), 1)
        self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
        self.blocks_vco_f_0 = blocks.vco_f(samp_rate, 1, 1)
        self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'len_key2')
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_char*1, 'len_key', 0)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, SPS-1)
        self.blocks_repack_bits_bb_0_0_0_0 = blocks.repack_bits_bb(1, 8, 'len_key2', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 1, 'len_key', False, gr.GR_MSB_FIRST)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'len_key')
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_message_debug_0_0 = blocks.message_debug()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.audio_source_0 = audio.source(44100, '', True)
        self.audio_sink_0 = audio.sink(44100, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -carrier_freq, 1, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(samp_rate/(2*math.pi*fsk_deviation_hz/8.0)/(RX_decimation))
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-60, .01, 0, True)
        self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 1.0)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.blocks_message_debug_0_0, 'print'))
        self.msg_connect((self.epy_block_0, 'msg_out'), (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.qtgui_edit_box_msg_0, 'msg'), (self.epy_block_0, 'msg_in'))
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_feedforward_agc_cc_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_feedforward_agc_cc_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_vco_f_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.blocks_vco_f_0, 0), (self.audio_sink_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.digital_correlate_access_code_xx_ts_1_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_1_0_0, 0), (self.blocks_repack_bits_bb_0_0_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_binary_slicer_fb_0_0, 0))
        self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.analog_pwr_squelch_xx_0, 0))
Exemplo n.º 25
0
 def closeEvent(self, event):
     self.settings = Qt.QSettings("GNU Radio", "twodimension_usrp_b210s")
     self.settings.setValue("geometry", self.saveGeometry())
     event.accept()
Exemplo n.º 26
0
from PyQt5 import Qt


class Widget(Qt.QWidget):
    table = Qt.QTableWidget()

    def __init__(self):
        super().__init__()
        layout = Qt.QHBoxLayout(self)
        self.table.setRowCount(2)
        self.table.setColumnCount(2)
        btn = Qt.QPushButton("Добавить")
        btn2 = Qt.QPushButton("Редактировать")
        self.table.setCellWidget(1, 0, btn)
        self.table.setCellWidget(0, 1, btn2)
        self.table.resizeColumnsToContents(
        )  # выравнивание по наличию контента
        #table.setEnabled(False)
        self.table.setEditTriggers(self.table.NoEditTriggers)
        layout.addWidget(self.table)
        #btn2.clicked.connect(self.Editable)

    def Editable(self):
        self.table.setEditTriggers(self.table.DoubleClicked)


if __name__ == '__main__':
    app = Qt.QApplication([])
    w = Widget()
    w.show()
    app.exec()
Exemplo n.º 27
0
 def set_variable_qtgui_label_0(self, variable_qtgui_label_0):
     self.variable_qtgui_label_0 = variable_qtgui_label_0
     Qt.QMetaObject.invokeMethod(
         self._variable_qtgui_label_0_label, "setText",
         Qt.Q_ARG("QString", self.variable_qtgui_label_0))
Exemplo n.º 28
0
 def closeEvent(self, event):
     self.settings = Qt.QSettings("GNU Radio", "somfy_record")
     self.settings.setValue("geometry", self.saveGeometry())
     event.accept()