示例#1
0
文件: soundtest.py 项目: bmazin/SDR
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        sys.excepthook = self.handle_exception

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.sound_thread = sound_Worker(self)
        self.timer_thread = timer_Worker(self)
        self.polling_timer = QTimer()

        QObject.connect(self.polling_timer, SIGNAL("timeout()"), self.update_remaining_time)
        QObject.connect(self.ui.pushButton, SIGNAL("clicked()"), self.playsound1)
        QObject.connect(self.ui.pushButton_2, SIGNAL("clicked()"), self.playsound2)
        QObject.connect(self.ui.pushButton_3, SIGNAL("clicked()"), self.playsound3)
        QObject.connect(self.ui.pushButton_4, SIGNAL("clicked()"), self.playsound4)
        QObject.connect(self.ui.pushButton_5, SIGNAL("clicked()"), self.countdown)
        QObject.connect(self.timer_thread, SIGNAL("timeout()"), self.playsound1)
示例#2
0
文件: soundtest.py 项目: bmazin/SDR
class StartQt4(QMainWindow):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        sys.excepthook = self.handle_exception

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.sound_thread = sound_Worker(self)
        self.timer_thread = timer_Worker(self)
        self.polling_timer = QTimer()

        QObject.connect(self.polling_timer, SIGNAL("timeout()"), self.update_remaining_time)
        QObject.connect(self.ui.pushButton, SIGNAL("clicked()"), self.playsound1)
        QObject.connect(self.ui.pushButton_2, SIGNAL("clicked()"), self.playsound2)
        QObject.connect(self.ui.pushButton_3, SIGNAL("clicked()"), self.playsound3)
        QObject.connect(self.ui.pushButton_4, SIGNAL("clicked()"), self.playsound4)
        QObject.connect(self.ui.pushButton_5, SIGNAL("clicked()"), self.countdown)
        QObject.connect(self.timer_thread, SIGNAL("timeout()"), self.playsound1)

    def handle_exception(self, exc_type, exc_value, exc_traceback):
        self.playsound3()
        print "".join(traceback.format_exception(exc_type, exc_value, exc_traceback))

    def playsound(self, file):
        if self.sound_thread.isRunning() == False:
            self.sound_thread.play_wav(file)
        else:
            time.sleep(0.1)
            self.playsound(file)

    def playsound1(self):
        file = "ARCON-complete.wav"
        self.playsound(file)

    def playsound2(self):
        file = "ARCON-eradicate.wav"
        self.playsound(file)

    def playsound3(self):
        file = "ARCON-nuclear.wav"
        self.playsound(file)

    def playsound4(self):
        file = "ARCON-returned.wav"
        self.playsound(file)

    def countdown(self):
        num = self.ui.spinBox.value()
        if num == 0:
            raise ValueError("timer cannot be 0")
        self.timer_thread.start_timer(num)
        self.polling_timer.start(200)
        arr = [0, 1, 2, 3, 4]
        print arr[10]

    def update_remaining_time(self):
        try:
            self.timer_thread and self.timer_thread.isRunning()
        except AttributeError:
            self.ui.lcdNumber.display(self.ui.obs_time_spinBox.value())
        else:
            self.ui.lcdNumber.display(self.timer_thread.remaining_time)