Skip to content

Instantly share code, notes, and snippets.

@marcusmueller
Created May 16, 2024 21:48
Show Gist options
  • Save marcusmueller/7ed884e2707715995e75da1ece433966 to your computer and use it in GitHub Desktop.
Save marcusmueller/7ed884e2707715995e75da1ece433966 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: GPL-3.0
#
# GNU Radio Python Flow Graph
# Title: Not titled yet
# GNU Radio version: v3.11.0.0git-747-g778912c3
from PyQt5 import Qt
from gnuradio import qtgui
from gnuradio import gr
from gnuradio.filter import firdes
from gnuradio.fft import window
import sys
import signal
from PyQt5 import Qt
from argparse import ArgumentParser
from gnuradio.eng_arg import eng_float, intx
from gnuradio import eng_notation
class default(gr.top_block, Qt.QWidget):
def __init__(self):
gr.top_block.__init__(self, "Not titled yet", catch_exceptions=True)
Qt.QWidget.__init__(self)
self.setWindowTitle("Not titled yet")
qtgui.util.check_set_qss()
try:
self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
except BaseException as exc:
print(f"Qt GUI: Could not set Icon: {str(exc)}", file=sys.stderr)
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", "default")
try:
geometry = self.settings.value("geometry")
if geometry:
self.restoreGeometry(geometry)
except BaseException as exc:
print(f"Qt GUI: Could not restore geometry: {str(exc)}", file=sys.stderr)
##################################################
# Variables
##################################################
self.variable_qtgui_toggle_switch_0 = variable_qtgui_toggle_switch_0 = 0
self.samp_rate = samp_rate = 32000
##################################################
# Blocks
##################################################
self._variable_qtgui_toggle_switch_0_choices = {'Pressed': 1, 'Released': 0}
_variable_qtgui_toggle_switch_0_toggle_switch = qtgui.GrToggleSwitch(self.set_variable_qtgui_toggle_switch_0, '', self._variable_qtgui_toggle_switch_0_choices, False, "green", "gray", 4, 50, 1, 1, self, 'value')
self.variable_qtgui_toggle_switch_0 = _variable_qtgui_toggle_switch_0_toggle_switch
self.top_layout.addWidget(_variable_qtgui_toggle_switch_0_toggle_switch)
def closeEvent(self, event):
self.settings = Qt.QSettings("GNU Radio", "default")
self.settings.setValue("geometry", self.saveGeometry())
self.stop()
self.wait()
event.accept()
def get_variable_qtgui_toggle_switch_0(self):
return self.variable_qtgui_toggle_switch_0
def set_variable_qtgui_toggle_switch_0(self, variable_qtgui_toggle_switch_0):
self.variable_qtgui_toggle_switch_0 = variable_qtgui_toggle_switch_0
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
def main(top_block_cls=default, options=None):
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def sig_handler(sig=None, frame=None):
tb.stop()
tb.wait()
Qt.QApplication.quit()
signal.signal(signal.SIGINT, sig_handler)
signal.signal(signal.SIGTERM, sig_handler)
timer = Qt.QTimer()
timer.start(500)
timer.timeout.connect(lambda: None)
qapp.exec_()
if __name__ == '__main__':
main()
options:
parameters:
author: ''
catch_exceptions: 'True'
category: '[GRC Hier Blocks]'
cmake_opt: ''
comment: ''
copyright: ''
description: ''
gen_cmake: 'On'
gen_linking: dynamic
generate_options: qt_gui
hier_block_src_path: '.:'
id: default
max_nouts: '0'
output_language: python
placement: (0,0)
qt_qss_theme: ''
realtime_scheduling: ''
run: 'True'
run_command: '{python} -u {filename}'
run_options: prompt
sizing_mode: fixed
thread_safe_setters: ''
title: Not titled yet
window_size: (1000,1000)
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [8, 8]
rotation: 0
state: enabled
blocks:
- name: variable_qtgui_toggle_switch_0
id: variable_qtgui_toggle_switch
parameters:
cellalignment: '1'
comment: ''
gui_hint: ''
initPressed: 'False'
label: ''
outputmsgname: value
position: '4'
pressed: '1'
released: '0'
switchOffBackground: gray
switchOnBackground: green
type: int
value: '0'
verticalalignment: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [31.25, 136.25]
rotation: 0.0
state: enabled
connections: []
metadata:
file_format: 1
grc_version: v3.11.0.0git-747-g778912c3
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment