Exemplo n.º 1
0
    def closeEvent(self, event):
        """ Override the method of parent class QWidget.

        The closeEvent method define the behaviour of clicking exit button 'x' of the window. Before exit the
        programm, a messagebox is called to confirm with the user if they want to exit the program. If yes,
        all measurement process and children process will be terminated to ensure that there is no possible exception
        caused by the exit of the program.


        Args:
            event: Fixed argument for method closeEvent of parent class.

        Returns:
            None

        """

        reply = QMessageBox.question(
            self, 'Window Close', 'Are you sure you want to exit the program?',
            QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
        if reply == QMessageBox.Yes:
            event.accept()
            # Stop all sub-threads and sub-processes, than wait for them to exit before exiting the main program
            # (to prevent exception raising)
            if self.read_measurement_thread.is_alive():
                cmd.stop_measurement()
                self.read_measurement_thread.join()
            if self.graph_process_v.is_alive(
            ) or self.graph_process_xyz.is_alive():
                self.graph_process_v.terminate()
                self.graph_process_xyz.terminate()
                self.graph_process_v.join()
                self.graph_process_xyz.join()
        else:
            event.ignore()
Exemplo n.º 2
0
    def set_offset(self):
        """The callback function of button 'Set offset'

        Returns:
            None

        """
        cmd.stop_measurement()
        self.button_run_c.setText('Run')
        cmd.set_offset()
Exemplo n.º 3
0
    def run_c(self):
        """The callback function of button 'Run'

        Returns:
            None

        """
        if self.button_run_c.text() == 'Run':
            cmd.stop_measurement()
            cmd.start_measurement(mode='c')
            self.read_measurement_thread = threading.Thread(target=cmd.read_measurement, daemon=True)
            self.read_measurement_thread.start()
            self.button_run_c.setText('Stop')
        else:
            cmd.stop_measurement()
            self.button_run_c.setText('Run')