def __init__(self, parent=None): QT.QWidget.__init__(self, parent) mainlayout = QT.QVBoxLayout() self.setLayout(mainlayout) mainlayout.addWidget(QT.QLabel(u'<h1><b>Select device</b>')) but = QT.QPushButton('refresh device list') but.clicked.connect(self.resfresh_device_list) mainlayout.addWidget(but) mainlayout.addWidget(QT.QLabel(u'Input device')) self.comboin = QT.QComboBox() mainlayout.addWidget(self.comboin) mainlayout.addWidget(QT.QLabel(u'Output device')) self.comboout = QT.QComboBox() mainlayout.addWidget(self.comboout) mainlayout.addStretch() mainlayout.addWidget(QT.QLabel(u'<h1><b>Test device</b>')) self.freqgainduration = FreqGainDuration() mainlayout.addWidget(self.freqgainduration) but = QT.QPushButton('Test play sinus') but.clicked.connect(self.test_play_sinus) mainlayout.addWidget(but) but = QT.QPushButton('Test input to output') but.clicked.connect(self.play_input_to_output) mainlayout.addWidget(but) self.resfresh_device_list()
def load(self): fd = QT.QFileDialog(fileMode=QT.QFileDialog.ExistingFile, acceptMode=QT.QFileDialog.AcceptOpen) fd.setNameFilters(['Hearingloss setup (*.json)', 'All (*)']) fd.setViewMode(QT.QFileDialog.Detail) if fd.exec_(): filename = fd.selectedFiles()[0] config = json.load(open(filename, 'r', encoding='utf8')) self.set_configuration(**config)
def save(self): fd = QT.QFileDialog(fileMode=QT.QFileDialog.AnyFile, acceptMode=QT.QFileDialog.AcceptSave, defaultSuffix='json') fd.setNameFilter('Hearingloss setup (*.json)') if fd.exec_(): filename = fd.selectedFiles()[0] json.dump(self.get_configuration(), open(filename, 'w', encoding='utf8'), indent=4, separators=(',', ': '))
def __init__(self, parent=None): QT.QWidget.__init__(self, parent) mainlayout = QT.QVBoxLayout() self.setLayout(mainlayout) mainlayout.addWidget(QT.QLabel(u'OpenCL Platform')) self.combo_platform = QT.QComboBox() mainlayout.addWidget(self.combo_platform) mainlayout.addWidget(QT.QLabel(u'OpenCL Device')) self.combo_dev = QT.QComboBox() mainlayout.addWidget(self.combo_dev) mainlayout.addStretch() self.resfresh_platform_list() self.combo_platform.currentIndexChanged.connect( self.resfresh_device_list) if len(pyopencl.get_platforms()) > 0: self.resfresh_device_list(0)
def __init__(self, parent=None): QT.QWidget.__init__(self, parent) self.resize(600, 600) mainlayout = QT.QVBoxLayout() self.setLayout(mainlayout) self.gpuDeviceSelection = GpuDeviceSelection() mainlayout.addWidget(self.gpuDeviceSelection) self.params = pg.parametertree.Parameter.create(name='params', type='group', children=_params) self.tree_params = pg.parametertree.ParameterTree(parent=self) self.tree_params.header().hide() self.tree_params.setParameters(self.params, showTop=True) mainlayout.addWidget(self.tree_params) but = QT.QPushButton('run benchmark') mainlayout.addWidget(but) but.clicked.connect(self.run_benchmark)
def __init__(self, parent=None): QT.QWidget.__init__(self, parent) mainlayout = QT.QVBoxLayout() self.setLayout(mainlayout) self.resize(400, 400) #~ self.client = client self.params = pg.parametertree.Parameter.create(name='wifi_device', type='group', children=_params) self.tree_params = pg.parametertree.ParameterTree(parent=self) self.tree_params.header().hide() self.tree_params.setParameters(self.params, showTop=True) mainlayout.addWidget(self.tree_params)
def __init__(self, with_all_params=True, parent=None): QT.QWidget.__init__(self, parent) mainlayout = QT.QVBoxLayout() self.setLayout(mainlayout) self.resize(400, 400) if with_all_params: children = _params else: children = _params[1:-2] self.params = pg.parametertree.Parameter.create(name='simulator', type='group', children=children) #~ layout = QT.QVBoxLayout() #~ self.setLayout(layout) self.tree_params = pg.parametertree.ParameterTree(parent=self) self.tree_params.header().hide() self.tree_params.setParameters(self.params, showTop=True) mainlayout.addWidget(self.tree_params)
def __init__(self, parent=None): QT.QWidget.__init__(self, parent) mainlayout = QT.QVBoxLayout() self.setLayout(mainlayout) self.canvas = MplCanvas() mainlayout.addWidget(self.canvas) self.mode = 'simple' h = QT.QHBoxLayout() mainlayout.addLayout(h) h.addSpacerItem(QT.QSpacerItem(130, 0)) g = QT.QGridLayout() h.addLayout(g) self.spin_passive_loss = {} self.spin_comp_degree = {} for i in range(n): g.addWidget(QT.QLabel('{} Hz'.format(freqs[i])), 0, i) self.spin_passive_loss[i] = s = pg.SpinBox(suffix='dBLoss', bounds=[0, 120], step=1) g.addWidget(s, 1, i) s.sigValueChanged.connect(self.on_spinbox_changed) self.spin_comp_degree[i] = s = pg.SpinBox(suffix='%', bounds=[0, 100], step=10) g.addWidget(s, 2, i) s.sigValueChanged.connect(self.on_spinbox_changed) h.addSpacerItem(QT.QSpacerItem(110, 0)) self.compression_degree = np.array([1.] * n) self.passive_loss_db = np.array([0.] * n) self.hearing_level = None self.lines = plot_hearingloss(self.canvas.ax, self.hearing_level, self.compression_degree, self.passive_loss_db, mode=self.mode) self.refresh_spinbox()
def __init__(self, client=None, parent=None): QT.QWidget.__init__(self, parent) self.client = client self.resize(600, 600) mainlayout = QT.QVBoxLayout() self.setLayout(mainlayout) self.devicewidget = WifiDeviceWidget(client=client) mainlayout.addWidget(self.devicewidget) ## mainlayout.addWidget(QT.QLabel(u'<h1><b>Audio params</b>')) h = QT.QHBoxLayout() mainlayout.addLayout(h) but = QT.QPushButton('Get params from device') h.addWidget(but) but.clicked.connect(self.get_params_from_device) but = QT.QPushButton('Set params to device') h.addWidget(but) but.clicked.connect(self.set_params_to_device) self.wifiDeviceParameter = WifiDeviceParameter() mainlayout.addWidget(self.wifiDeviceParameter) ## mainlayout.addWidget(QT.QLabel(u'<h1><b>ssid</b>')) but = QT.QPushButton('Apply ssid') mainlayout.addWidget(but) but.clicked.connect(self.set_ssid) self.edit_ssid = QT.QLineEdit() mainlayout.addWidget(self.edit_ssid) ## mainlayout.addWidget(QT.QLabel(u'<h1><b>Audio loop</b>')) h = QT.QHBoxLayout() mainlayout.addLayout(h) but = QT.QPushButton('Start') h.addWidget(but) but.clicked.connect(self.start_audio) but = QT.QPushButton('Stop') h.addWidget(but) but.clicked.connect(self.stop_audio) self.thread_audio_loop = ThreadAudioStream(client.client_protocol, parent=self) self.thread_audio_loop.connection_broken.connect( self.client.on_connection_broken)
import sys from hearinglosssimulator.gui.myqt import QT, mkQApp, QT_MODE print('QT_MODE', QT_MODE) import hearinglosssimulator.gui.icons #~ print(dir(hearinglosssimulator.gui.icons)) if __name__ == '__main__': app = mkQApp() w = QT.QWidget() w.show() w.setWindowIcon(QT.QIcon(':/bypass.png')) app.exec_()
def __init__(self, parent=None): QT.QWidget.__init__(self, parent) mainlayout = QT.QVBoxLayout() self.setLayout(mainlayout) h = QT.QHBoxLayout() mainlayout.addLayout(h) self.tab = QT.QTabWidget() h.addWidget(self.tab) ears = ('left', 'right') self.hl_params = {} for ear in ears: p = OneChannelHearingLossParameter() self.hl_params[ear] = p self.tab.addTab(p, ear) v = QT.QVBoxLayout() h.addLayout(v) v.addWidget(QT.QLabel('Hear level presets:')) self.combo_hearing_level_preset = QT.QComboBox() self.combo_hearing_level_preset.setMinimumHeight(48) v.addWidget(self.combo_hearing_level_preset) self.combo_hearing_level_preset.addItems(hearing_level_preset.keys()) self.combo_hearing_level_preset.currentIndexChanged.connect( self.on_change_preset) v.addWidget(QT.QLabel('Compression healthiness:')) self.combo_compression_loss_preset = QT.QComboBox() self.combo_compression_loss_preset.setMinimumHeight(48) v.addWidget(self.combo_compression_loss_preset) self.combo_compression_loss_preset.addItems(compression_ratio.keys()) self.combo_compression_loss_preset.setCurrentIndex(2) self.combo_compression_loss_preset.currentIndexChanged.connect( self.on_change_preset) v.addSpacing(30) but = QT.QPushButton(u'Copy L>R') v.addWidget(but) but.clicked.connect(self.copy_l_to_r) but = QT.QPushButton(u'Load') v.addWidget(but) but.clicked.connect(self.load) but = QT.QPushButton(u'Save') v.addWidget(but) but.clicked.connect(self.save) v.addStretch() self.nb_channel = 2