Esempio n. 1
0
 def __init__(self):
     self.dialog = QtGui.QDialog()
     self.ui = Ui_Select_Offset()
     self.ui.setupUi(self.dialog)
Esempio n. 2
0
class VisOffsetSelector(object):
    """
    Display and assign actions for the offset-selection window.
    """

    def __init__(self):
        self.dialog = QtGui.QDialog()
        self.ui = Ui_Select_Offset()
        self.ui.setupUi(self.dialog)

    def trigger(self):
        """
        Set up and get information from a window that asks the user for an offest value. The return
        value corresponds to the quarterLength duration the user chose.

        :returns: The interval offset chosen by the user, or "ALL," if relevant.
        :rtype: ``unicode``
        """
        self.dialog.show()
        # signals
        buttons = [self.ui.btn_8.clicked,
                   self.ui.btn_4.clicked,
                   self.ui.btn_2.clicked,
                   self.ui.btn_1.clicked,
                   self.ui.btn_0_5.clicked,
                   self.ui.btn_0_25.clicked,
                   self.ui.btn_0_125.clicked,
                   self.ui.btn_0_0625.clicked,
                   self.ui.btn_none.clicked]
        for btn_sig in buttons:
            btn_sig.connect(self._change_offset)
        # hold currently-selected duration
        self.current_duration = 0.5
        # show the form!
        self.dialog.exec_()
        # (User chooses stuff)
        # ... then...
        # Return the currently-selected duration
        return unicode(self.current_duration)

    @QtCore.pyqtSlot()
    def _change_offset(self):
        if self.ui.btn_8.isChecked():
            self.current_duration = 8.0
        elif self.ui.btn_4.isChecked():
            self.current_duration = 4.0
        elif self.ui.btn_2.isChecked():
            self.current_duration = 2.0
        elif self.ui.btn_1.isChecked():
            self.current_duration = 1.0
        elif self.ui.btn_0_5.isChecked():
            self.current_duration = 0.5
        elif self.ui.btn_0_25.isChecked():
            self.current_duration = 0.25
        elif self.ui.btn_0_125.isChecked():
            self.current_duration = 0.125
        elif self.ui.btn_0_0625.isChecked():
            self.current_duration = 0.0625
        elif self.ui.btn_none.isChecked():
            self.current_duration = u'ALL'
        self.ui.music21_durat.display(unicode(self.current_duration))