Python PyQt5.QtCore.Qt.WaitCursor() Examples

The following are 27 code examples of PyQt5.QtCore.Qt.WaitCursor(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore.Qt , or try the search function .
Example #1
Source File: SignalFrame.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def export_demodulated(self):
        try:
            initial_name = self.signal.name + "-demodulated.complex"
        except Exception as e:
            logger.exception(e)
            initial_name = "demodulated.complex"

        filename = FileOperator.get_save_file_name(initial_name)
        if filename:
            try:
                self.setCursor(Qt.WaitCursor)
                data = self.signal.qad
                if filename.endswith(".wav"):
                    data = self.signal.qad.astype(np.float32)
                    data /= np.max(np.abs(data))
                FileOperator.save_data(IQArray(data, skip_conversion=True), filename, self.signal.sample_rate,
                                       num_channels=1)
                self.unsetCursor()
            except Exception as e:
                QMessageBox.critical(self, self.tr("Error exporting demodulated data"), e.args[0]) 
Example #2
Source File: ProjectManager.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def read_opened_filenames(self):
        if self.project_file is not None:
            tree = ET.parse(self.project_file)
            root = tree.getroot()
            file_names = []

            for file_tag in root.findall("open_file"):
                pos = int(file_tag.attrib["position"])
                filename = file_tag.attrib["name"]
                if not os.path.isfile(filename):
                    filename = os.path.normpath(os.path.join(self.project_path, filename))
                file_names.insert(pos, filename)

            QApplication.setOverrideCursor(Qt.WaitCursor)
            file_names = FileOperator.uncompress_archives(file_names, QDir.tempPath())
            QApplication.restoreOverrideCursor()
            return file_names
        return [] 
Example #3
Source File: MainController.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def show_open_dialog(self, directory=False):
        dialog = FileOperator.get_open_dialog(directory_mode=directory, parent=self, name_filter="full")
        if dialog.exec_():
            try:
                file_names = dialog.selectedFiles()
                folders = [folder for folder in file_names if os.path.isdir(folder)]

                if len(folders) > 0:
                    folder = folders[0]
                    for f in self.signal_tab_controller.signal_frames:
                        self.close_signal_frame(f)

                    self.project_manager.set_project_folder(folder)
                else:
                    self.setCursor(Qt.WaitCursor)
                    file_names = FileOperator.uncompress_archives(file_names, QDir.tempPath())
                    self.add_files(file_names)
                    self.unsetCursor()
            except Exception as e:
                Errors.exception(e)
                self.unsetCursor() 
Example #4
Source File: SignalFrame.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def on_export_fta_wanted(self):
        try:
            initial_name = self.signal.name + "-spectrogram.ft"
        except Exception as e:
            logger.exception(e)
            initial_name = "spectrogram.ft"

        filename = FileOperator.get_save_file_name(initial_name, caption="Export spectrogram")
        if not filename:
            return
        QApplication.setOverrideCursor(Qt.WaitCursor)
        try:
            self.ui.gvSpectrogram.scene_manager.spectrogram.export_to_fta(sample_rate=self.signal.sample_rate,
                                                                          filename=filename,
                                                                          include_amplitude=filename.endswith(".fta"))
        except Exception as e:
            Errors.exception(e)
        finally:
            QApplication.restoreOverrideCursor() 
Example #5
Source File: SignalFrame.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def contextMenuEvent(self, event: QContextMenuEvent):
        if self.signal is None:
            return

        menu = QMenu()
        apply_to_all_action = menu.addAction(self.tr("Apply values (BitLen, 0/1-Threshold, Tolerance) to all signals"))
        menu.addSeparator()
        auto_detect_action = menu.addAction(self.tr("Auto-Detect signal parameters"))
        action = menu.exec_(self.mapToGlobal(event.pos()))
        if action == apply_to_all_action:
            self.setCursor(Qt.WaitCursor)
            self.apply_to_all_clicked.emit(self.signal)
            self.unsetCursor()
        elif action == auto_detect_action:
            self.setCursor(Qt.WaitCursor)
            self.signal.auto_detect(detect_modulation=False, detect_noise=False)
            self.unsetCursor() 
Example #6
Source File: SignalFrame.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def on_cb_signal_view_index_changed(self):
        self.setCursor(Qt.WaitCursor)

        self.__set_spectrogram_adjust_widgets_visibility()

        if self.ui.cbSignalView.currentText().lower() == "spectrogram":
            self.ui.stackedWidget.setCurrentWidget(self.ui.pageSpectrogram)
            self.draw_spectrogram(show_full_scene=True)
            self.__set_selected_bandwidth()
            self.ui.labelRSSI.hide()
        else:
            self.ui.stackedWidget.setCurrentWidget(self.ui.pageSignal)
            self.ui.gvSignal.scene_type = self.ui.cbSignalView.currentIndex()
            self.scene_manager.mod_type = self.signal.modulation_type
            self.ui.gvSignal.redraw_view(reinitialize=True)
            self.ui.labelRSSI.show()

            self.ui.gvSignal.auto_fit_view()
            self.ui.gvSignal.refresh_selection_area()
            qApp.processEvents()
            self.on_slider_y_scale_value_changed()  # apply YScale to new view
            self.__set_samples_in_view()
            self.__set_duration()

        self.unsetCursor() 
Example #7
Source File: SignalFrame.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def draw_spectrogram(self, show_full_scene=False, force_redraw=False):
        self.setCursor(Qt.WaitCursor)
        window_size = 2 ** self.ui.sliderFFTWindowSize.value()
        data_min, data_max = self.ui.sliderSpectrogramMin.value(), self.ui.sliderSpectrogramMax.value()

        redraw_needed = self.ui.gvSpectrogram.scene_manager.set_parameters(self.signal.iq_array.data,
                                                                           window_size=window_size,
                                                                           data_min=data_min, data_max=data_max)
        self.ui.gvSpectrogram.scene_manager.update_scene_rect()

        if show_full_scene:
            self.ui.gvSpectrogram.show_full_scene()

        if redraw_needed or force_redraw:
            self.ui.gvSpectrogram.scene_manager.show_full_scene()
            self.ui.gvSpectrogram.show_full_scene()

        self.on_slider_y_scale_value_changed()

        self.__set_samples_in_view()
        self.unsetCursor() 
Example #8
Source File: ModulatorDialog.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def handle_signal_loaded(self, protocol):
        self.setCursor(Qt.WaitCursor)
        self.ui.cbShowDataBitsOnly.setEnabled(True)
        self.ui.chkBoxLockSIV.setEnabled(True)
        self.ui.btnAutoDetect.setEnabled(True)
        self.protocol = protocol

        # Apply bit length of original signal to current modulator
        self.ui.spinBoxSamplesPerSymbol.setValue(self.ui.gVOriginalSignal.signal.samples_per_symbol)

        # https://github.com/jopohl/urh/issues/130
        self.ui.gVModulated.show_full_scene(reinitialize=True)
        self.ui.gVCarrier.show_full_scene(reinitialize=True)
        self.ui.gVData.show_full_scene(reinitialize=True)

        self.unsetCursor() 
Example #9
Source File: progressBar.py    From dzetsaka with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, inMsg=' Loading...', inMaxStep=1):
        """
        """
        # Save reference to the QGIS interface
        # initialize progressBar
        # QApplication.processEvents() # Help to keep UI alive
        self.iface = iface

        widget = iface.messageBar().createMessage('Please wait  ', inMsg)

        prgBar = QProgressBar()
        self.prgBar = prgBar

        widget.layout().addWidget(self.prgBar)
        iface.messageBar().pushWidget(widget)
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

        # if Max 0 and value 0, no progressBar, only cursor loading
        # default is set to 0
        prgBar.setValue(1)
        # set Maximum for progressBar
        prgBar.setMaximum(inMaxStep) 
Example #10
Source File: mediainfo.py    From vidcutter with GNU General Public License v3.0 5 votes vote down vote up
def showKeyframes(self):
        qApp.setOverrideCursor(Qt.WaitCursor)
        keyframes = self.parent.videoService.getKeyframes(self.media, formatted_time=True)
        kframes = KeyframesDialog(keyframes, self)
        kframes.show() 
Example #11
Source File: interSubs.py    From interSubs with MIT License 5 votes vote down vote up
def main(self):
		while 1:
			to_new_word = False

			try:
				word, globalX = config.queue_to_translate.get(False)
			except:
				time.sleep(config.update_time)
				continue

			# changing cursor to hourglass during translation
			QApplication.setOverrideCursor(Qt.WaitCursor)

			threads = []
			for translation_function_name in config.translation_function_names:
				threads.append(threading.Thread(target = globals()[translation_function_name], args = (word,)))
			for x in threads:
				x.start()
			while any(thread.is_alive() for thread in threads):
				if config.queue_to_translate.qsize():
					to_new_word = True
					break
				time.sleep(config.update_time)

			QApplication.restoreOverrideCursor()

			if to_new_word:
				continue

			if config.block_popup:
				continue

			self.get_translations.emit(word, globalX, False)

# drawing layer
# because can't calculate outline with precision 
Example #12
Source File: GeneratorTableView.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def on_de_bruijn_action_triggered(self):
        self.setCursor(Qt.WaitCursor)

        row = self.rowAt(self.context_menu_pos.y())
        _, _, start, end = self.selection_range()
        self.model().generate_de_bruijn(row, start, end)

        self.unsetCursor() 
Example #13
Source File: FuzzingTableView.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def resize_me(self):
        qApp.setOverrideCursor(Qt.WaitCursor)
        w = QFontMetrics(self.font()).widthChar("0") + 2
        for i in range(10):
            self.setColumnWidth(i, 3 * w)
        for i in range(10, self.model().col_count):
            self.setColumnWidth(i, w * (len(str(i + 1)) + 1))
        qApp.restoreOverrideCursor() 
Example #14
Source File: MainController.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __add_urls_to_group(self, file_urls, group_id=0):
        local_files = [file_url.toLocalFile() for file_url in file_urls if file_url.isLocalFile()]
        if len(local_files) > 0:
            self.setCursor(Qt.WaitCursor)
            self.add_files(FileOperator.uncompress_archives(local_files, QDir.tempPath()), group_id=group_id)
            self.unsetCursor() 
Example #15
Source File: MainController.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def on_open_recent_action_triggered(self):
        action = self.sender()
        try:
            if os.path.isdir(action.data()):
                self.project_manager.set_project_folder(action.data())
            elif os.path.isfile(action.data()):
                self.setCursor(Qt.WaitCursor)
                self.add_files(FileOperator.uncompress_archives([action.data()], QDir.tempPath()))
                self.unsetCursor()
        except Exception as e:
            Errors.exception(e)
            self.unsetCursor() 
Example #16
Source File: MainController.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def add_signal(self, signal, group_id=0, index=-1):
        self.setCursor(Qt.WaitCursor)
        pa = ProtocolAnalyzer(signal)
        sig_frame = self.signal_tab_controller.add_signal_frame(pa, index=index)
        pa = self.compare_frame_controller.add_protocol(pa, group_id)

        signal.blockSignals(True)
        has_entry = self.project_manager.read_project_file_for_signal(signal)

        if self.ui.actionAuto_detect_new_signals.isChecked() and not has_entry and not signal.changed:
            sig_frame.ui.stackedWidget.setCurrentWidget(sig_frame.ui.pageLoading)
            qApp.processEvents()
            if not signal.already_demodulated:
                signal.auto_detect(detect_modulation=True, detect_noise=False)
            sig_frame.ui.stackedWidget.setCurrentWidget(sig_frame.ui.pageSignal)

        signal.blockSignals(False)

        self.signal_protocol_dict[sig_frame] = pa

        sig_frame.refresh_signal(draw_full_signal=True)
        sig_frame.refresh_signal_information(block=True)

        qApp.processEvents()
        sig_frame.show_protocol(refresh=True)

        if self.project_manager.read_participants_for_signal(signal, pa.messages):
            sig_frame.ui.gvSignal.redraw_view()

        sig_frame.ui.gvSignal.auto_fit_view()
        self.set_frame_numbers()

        self.compare_frame_controller.filter_search_results()
        self.refresh_main_menu()
        self.unsetCursor() 
Example #17
Source File: media_cue_menus.py    From linux-show-player with GNU General Public License v3.0 5 votes vote down vote up
def add_uri_audio_media_cue():
        """Add audio MediaCue(s) form user-selected files"""

        if get_backend() is None:
            QMessageBox.critical(MainWindow(), 'Error', 'Backend not loaded')
            return

        # Default path to system "music" folder
        path = QStandardPaths.writableLocation(QStandardPaths.MusicLocation)

        # Get the backend extensions and create a filter for the Qt file-dialog
        extensions = get_backend().supported_extensions()
        filters = qfile_filters(extensions, anyfile=False)
        # Display a file-dialog for the user to choose the media-files
        files, _ = QFileDialog.getOpenFileNames(MainWindow(),
                                                translate('MediaCueMenus',
                                                          'Select media files'),
                                                path, filters)

        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

        # Create media cues, and add them to the Application cue_model
        for file in files:
            cue = CueFactory.create_cue('URIAudioCue', uri='file://' + file)
            # Use the filename without extension as cue name
            cue.name = os.path.splitext(os.path.basename(file))[0]
            Application().cue_model.add(cue)

        QApplication.restoreOverrideCursor() 
Example #18
Source File: SignalFrame.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def on_bandpass_filter_triggered(self, f_low: float, f_high: float):
        self.filter_abort_wanted = False

        QApplication.instance().setOverrideCursor(Qt.WaitCursor)
        filter_bw = Filter.read_configured_filter_bw()
        filtered = Array("f", 2 * self.signal.num_samples)
        p = Process(target=perform_filter,
                    args=(filtered, self.signal.iq_array.as_complex64(), f_low, f_high, filter_bw))
        p.daemon = True
        p.start()

        while p.is_alive():
            QApplication.instance().processEvents()

            if self.filter_abort_wanted:
                p.terminate()
                p.join()
                QApplication.instance().restoreOverrideCursor()
                return

            time.sleep(0.1)

        filtered = np.frombuffer(filtered.get_obj(), dtype=np.complex64)
        signal = self.signal.create_new(new_data=filtered.astype(np.complex64))
        signal.name = self.signal.name + " filtered with f_low={0:.4n} f_high={1:.4n} bw={2:.4n}".format(f_low, f_high,
                                                                                                         filter_bw)
        self.signal_created.emit(signal)
        QApplication.instance().restoreOverrideCursor() 
Example #19
Source File: GeneratorTabController.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def on_btn_fuzzing_clicked(self):
        fuz_mode = "Successive"
        if self.ui.rbConcurrent.isChecked():
            fuz_mode = "Concurrent"
        elif self.ui.rBExhaustive.isChecked():
            fuz_mode = "Exhaustive"

        self.setCursor(Qt.WaitCursor)
        fuzz_action = Fuzz(self.table_model.protocol, fuz_mode)
        self.table_model.undo_stack.push(fuzz_action)
        for row in fuzz_action.added_message_indices:
            self.table_model.update_checksums_for_row(row)
        self.unsetCursor()
        self.ui.tableMessages.setFocus() 
Example #20
Source File: sparrow-wifi.py    From sparrow-wifi with GNU General Public License v3.0 5 votes vote down vote up
def setWaitCursor(self):
        self.setCursor(Qt.WaitCursor) 
Example #21
Source File: SignalFrame.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def on_set_noise_in_graphic_view_clicked(self):
        self.setCursor(Qt.WaitCursor)
        start = self.ui.gvSignal.selection_area.x
        end = start + self.ui.gvSignal.selection_area.width

        new_thresh = self.signal.calc_relative_noise_threshold_from_range(start, end)
        self.ui.spinBoxNoiseTreshold.setValue(new_thresh)
        self.ui.spinBoxNoiseTreshold.editingFinished.emit()
        self.unsetCursor() 
Example #22
Source File: sparrowdialogs.py    From sparrow-wifi with GNU General Public License v3.0 5 votes vote down vote up
def onScanClicked(self, pressed):
        if self.btnScan.isChecked():
            # Scanning is on.  Turn red to indicate click would stop
            if self.comboScanType.currentText() == 'Promiscuous Discovery':
                ubertooth = True
                
                if not self.usingRemoteAgent:
                    if not self.mainWin.hasUbertooth:
                        self.btnScan.setChecked(False)
                        return
                else:
                    if not self.mainWin.hasRemoteUbertooth:
                        self.btnScan.setChecked(False)
                        return
            else:
                ubertooth = False
                
            self.btnScan.setStyleSheet("background-color: rgba(255,0,0,255); border: none;")
            self.btnScan.setText('&Stop scanning')
            self.comboScanType.setEnabled(False)
            
            if not self.mainWin.remoteAgentUp:
                self.scanPromiscuous = ubertooth
                self.bluetooth.startDiscovery(ubertooth)
            else:
                self.setCursor(Qt.WaitCursor)
                errcode, errmsg = startRemoteBluetoothDiscoveryScan(self.remoteAgentIP, self.remoteAgentPort, ubertooth)
                self.setCursor(Qt.ArrowCursor)

                if errcode != 0:
                    QMessageBox.question(self, 'Error',"Could not start remote scan: " + errmsg, QMessageBox.Ok)
                    self.btnScan.setChecked(False)
                    self.btnScan.setStyleSheet("background-color: rgba(2,128,192,255); border: none;")
                    self.btnScan.setText('&Scan')
                    self.comboScanType.setEnabled(True)
                    return
                    
            self.btTimer.start(self.btTimerTimeout)
        else:
            self.btTimer.stop()
            
            self.btnScan.setStyleSheet("background-color: rgba(2,128,192,255); border: none;")
            self.btnScan.setText('&Scan')
            self.comboScanType.setEnabled(True)
            self.setCursor(Qt.WaitCursor)
            if not self.mainWin.remoteAgentUp:
                self.bluetooth.stopDiscovery()
            else:
                errcode, errmsg = stopRemoteBluetoothDiscoveryScan(self.remoteAgentIP, self.remoteAgentPort)
            self.setCursor(Qt.ArrowCursor) 
Example #23
Source File: DecoderDialog.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def set_signal(self):
        indx = self.ui.combobox_signals.currentIndex()
        if indx != 0:
            self.ui.inpt.setReadOnly(True)
        else:
            self.ui.inpt.setReadOnly(False)
            self.ui.inpt.setText("10010110")
            self.decoder_update()
            return

        self.setCursor(Qt.WaitCursor)

        signal = self.signals[indx - 1]
        pa = ProtocolAnalyzer(signal)
        pa.get_protocol_from_signal()
        self.ui.inpt.setText("".join(pa.plain_bits_str))
        self.ui.inpt.setCursorPosition(0)

        if signal is not None and pa.messages:
            last_message = pa.messages[-1]
            lookup = {i: msg.bit_sample_pos for i, msg in enumerate(pa.messages)}

            plot_data = signal.qad[lookup[0][0]:lookup[pa.num_messages - 1][len(last_message) - 1]]
            self.ui.graphicsView_signal.plot_data(plot_data)

        self.ui.graphicsView_signal.centerOn(0, 0)
        self.unsetCursor() 
Example #24
Source File: Signal.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def save_as(self, filename: str):
        QApplication.instance().setOverrideCursor(Qt.WaitCursor)
        self.filename = filename
        FileOperator.save_signal(self)
        self.name = os.path.splitext(os.path.basename(filename))[0]
        self.changed = False
        QApplication.instance().restoreOverrideCursor() 
Example #25
Source File: GeneratorTabController.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def on_fuzzing_finished(self):
        self.ui.stackedWidgetFuzzing.setCurrentWidget(self.ui.pageFuzzingUI)
        # Calculate Checksums for Fuzzed Messages
        self.setCursor(Qt.WaitCursor)

        self.unsetCursor() 
Example #26
Source File: GeneratorTabController.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def on_view_type_changed(self):
        self.setCursor(Qt.WaitCursor)
        self.table_model.proto_view = self.ui.cbViewType.currentIndex()
        self.ui.tableMessages.resize_columns()
        self.unsetCursor() 
Example #27
Source File: experiment_dialog.py    From raster-vision-qgis with GNU General Public License v3.0 4 votes vote down vote up
def load_experiment_clicked(self):
        experiment_uri = self.experiment_uri_line_edit.text()
        Log.log_info("Loading experiment at {}".format(experiment_uri))
        QtWidgets.QApplication.setOverrideCursor(Qt.WaitCursor)
        try:
            msg = load_json_config(experiment_uri, ExperimentConfigMsg())
        except (NotReadableError, ProtobufParseException) as e:
            reply = QMessageBox.warning(self.iface.mainWindow(), 'Error',
                                        'Unable to read experiment file. See log more details.', QMessageBox.Ok)
            Log.log_warning('Unable to read experiment file: {}'.format(experiment_uri))
            Log.log_exception(e)
            return
        finally:
            QtWidgets.QApplication.restoreOverrideCursor()

        experiment = rv.ExperimentConfig.from_proto(msg)
        self.experiment = experiment
        ds = experiment.dataset

        self.train_scene_list.clear()
        for scene in ds.train_scenes:
            item = QtWidgets.QListWidgetItem(scene.id, self.train_scene_list)
            item.setFlags(QtCore.Qt.ItemIsUserCheckable |
                          QtCore.Qt.ItemIsEnabled)
            item.setCheckState(QtCore.Qt.Checked)
            self.train_scene_list.addItem(item)

        self.validation_scene_list.clear()
        for scene in ds.validation_scenes:
            item = QtWidgets.QListWidgetItem(scene.id, self.validation_scene_list)
            item.setFlags(QtCore.Qt.ItemIsUserCheckable |
                          QtCore.Qt.ItemIsEnabled)
            item.setCheckState(QtCore.Qt.Checked)
            self.validation_scene_list.addItem(item)

        self.test_scene_list.clear()
        for scene in ds.test_scenes:
            item = QtWidgets.QListWidgetItem(scene.id, self.test_scene_list)
            item.setFlags(QtCore.Qt.ItemIsUserCheckable |
                          QtCore.Qt.ItemIsEnabled)
            item.setCheckState(QtCore.Qt.Checked)
            self.test_scene_list.addItem(item)