Beispiel #1
0
    def __init__(self, parent=None):
        super(PythonMcu, self).__init__(parent)

        font = QFont()
        font.setStyleHint(QFont.TypeWriter, QFont.PreferAntialias)

        char_format = QTextCharFormat()
        char_format.setFontFamily(font.defaultFamily())
        text_width = QFontMetrics(char_format.font()).width('*') * 80

        # must be defined before starting the logger!
        self._edit_logger = QPlainTextEdit()
        self._edit_logger.setReadOnly(True)
        self._edit_logger.setCurrentCharFormat(char_format)
        self._edit_logger.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self._edit_logger.setFixedWidth(text_width)

        # must be defined before reading the configuration file!
        self._edit_usage_hint = QPlainTextEdit()
        self._edit_usage_hint.setReadOnly(True)
        self._edit_usage_hint.setCurrentCharFormat(char_format)

        self.callback_log('')
        self.callback_log(configuration.get_full_description())
        self.callback_log('')
        self.callback_log('')
        self.callback_log('Version numbers')
        self.callback_log('===============')
        self.callback_log('Python:  %s (%s)' % ( \
                platform.python_version(), platform.python_implementation()))
        self.callback_log('PySide:  %s' % PySide.__version__)
        self.callback_log('pygame:  %s' % pygame.version.ver)
        self.callback_log('')
        self.callback_log('')

        # auto-scroll log window by setting cursor to end of document
        self._edit_logger.moveCursor(QTextCursor.End, QTextCursor.MoveAnchor)

        self._read_configuration()

        self._timer = None
        self._interconnector = None

        icon = self.style().standardIcon(QStyle.SP_TitleBarMenuButton)
        self.setWindowIcon(icon)

        mcu_model_ids = ['Logic Control', 'Logic Control XT', \
                              'Mackie Control', 'Mackie Control XT']

        hardware_controllers = [ \
            'Novation ZeRO SL MkII', \
            'Novation ZeRO SL MkII (MIDI)'
        ]

        # get version number of "Python MCU"
        version = configuration.get_application_information('version')
        self.setWindowTitle(configuration.get_version(True))

        # create layouts and add widgets
        self.layout = QHBoxLayout()
        self.setLayout(self.layout)

        self.layout_2 = QVBoxLayout()
        self.layout.addLayout(self.layout_2)

        self.frame_mcu = QFrame()
        self.frame_mcu.setFrameStyle(QFrame.Box)
        self.frame_mcu.setFrameShadow(QFrame.Sunken)
        self.layout_2.addWidget(self.frame_mcu)
        self.grid_layout_mcu = QGridLayout()
        self.frame_mcu.setLayout(self.grid_layout_mcu)

        self.frame_controller = QFrame()
        self.frame_controller.setFrameStyle(QFrame.Box)
        self.frame_controller.setFrameShadow(QFrame.Sunken)
        self.layout_2.addWidget(self.frame_controller)
        self.grid_layout_controller = QGridLayout()
        self.frame_controller.setLayout(self.grid_layout_controller)


        self._combo_mcu_model_id = self._create_combo_box( \
            self.grid_layout_mcu, self._mcu_emulated_model, \
                'Emulation:', mcu_model_ids)

        connection_types = [MackieHostControl.ASSUME_SUCCESSFUL_CONNECTION, \
                                MackieHostControl.CHALLENGE_RESPONSE, \
                                MackieHostControl.WAIT_FOR_MIDI_DATA]
        self._combo_mcu_connection = self._create_combo_box( \
            self.grid_layout_mcu, self._mcu_connection, \
                'Connection:', connection_types)

        self._combo_mcu_midi_input = self._create_combo_box( \
            self.grid_layout_mcu, self._mcu_midi_input, \
                'MIDI In:', MidiConnection.get_midi_inputs())

        self._combo_mcu_midi_output = self._create_combo_box( \
            self.grid_layout_mcu, self._mcu_midi_output, \
                'MIDI Out:', MidiConnection.get_midi_outputs())


        self._combo_hardware_controller = self._create_combo_box( \
            self.grid_layout_controller, self._hardware_controller, \
                'Controller:', hardware_controllers)

        self._combo_controller_midi_input = self._create_combo_box( \
            self.grid_layout_controller, self._controller_midi_input, \
                'MIDI In:', MidiConnection.get_midi_inputs())

        self._combo_controller_midi_output = self._create_combo_box( \
            self.grid_layout_controller, self._controller_midi_output, \
                'MIDI Out:', MidiConnection.get_midi_outputs())

        self.grid_layout_controller.addWidget( \
            self._edit_usage_hint, self.grid_layout_controller.rowCount(), \
                0, 1, 2)

        self.layout.addWidget(self._edit_logger)

        self.bottom_layout = QHBoxLayout()
        self.layout_2.addLayout(self.bottom_layout)

        self.button_start_stop = QPushButton('&Start')
        self.bottom_layout.addWidget(self.button_start_stop)
        self.button_start_stop.setDefault(True)
        self.button_start_stop.setFocus()
        self.button_start_stop.clicked.connect(self.interconnector_start_stop)

        self.button_close = QPushButton('&Close')
        self.bottom_layout.addWidget(self.button_close)
        self.button_close.clicked.connect(self.close_application)

        self.button_about = QPushButton('A&bout')
        self.bottom_layout.addWidget(self.button_about)
        self.button_about.clicked.connect(self.display_about)

        self._enable_controls(True)

        self._timer = QTimer(self)
        self._timer.setInterval(int(self._midi_latency))
        self._timer.timeout.connect(self.process_midi_input)
Beispiel #2
0
    def __init__(self, parent=None):
        super(PythonMcu, self).__init__(parent)

        font = QFont()
        font.setStyleHint(QFont.TypeWriter, QFont.PreferAntialias)

        char_format = QTextCharFormat()
        char_format.setFontFamily(font.defaultFamily())
        text_width = QFontMetrics(char_format.font()).width('*') * 80

        # must be defined before starting the logger!
        self._edit_logger = QPlainTextEdit()
        self._edit_logger.setReadOnly(True)
        self._edit_logger.setCurrentCharFormat(char_format)
        self._edit_logger.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self._edit_logger.setFixedWidth(text_width)

        # must be defined before reading the configuration file!
        self._edit_usage_hint = QPlainTextEdit()
        self._edit_usage_hint.setReadOnly(True)
        self._edit_usage_hint.setCurrentCharFormat(char_format)

        self.callback_log('')
        self.callback_log(configuration.get_full_description())
        self.callback_log('')
        self.callback_log('')
        self.callback_log('Version numbers')
        self.callback_log('===============')
        self.callback_log('Python:  %s (%s)' % ( \
                platform.python_version(), platform.python_implementation()))
        self.callback_log('PySide:  %s' % PySide.__version__)
        self.callback_log('pygame:  %s' % pygame.version.ver)
        self.callback_log('')
        self.callback_log('')

        # auto-scroll log window by setting cursor to end of document
        self._edit_logger.moveCursor(QTextCursor.End, QTextCursor.MoveAnchor)

        self._read_configuration()

        self._timer = None
        self._interconnector = None

        icon = self.style().standardIcon(QStyle.SP_TitleBarMenuButton)
        self.setWindowIcon(icon)

        mcu_model_ids = ['Logic Control', 'Logic Control XT', \
                              'Mackie Control', 'Mackie Control XT']

        hardware_controllers = [ \
            'Novation ZeRO SL MkII', \
            'Novation ZeRO SL MkII (MIDI)'
        ]

        # get version number of "Python MCU"
        version = configuration.get_application_information('version')
        self.setWindowTitle(configuration.get_version(True))

        # create layouts and add widgets
        self.layout = QHBoxLayout()
        self.setLayout(self.layout)

        self.layout_2 = QVBoxLayout()
        self.layout.addLayout(self.layout_2)

        self.frame_mcu = QFrame()
        self.frame_mcu.setFrameStyle(QFrame.Box)
        self.frame_mcu.setFrameShadow(QFrame.Sunken)
        self.layout_2.addWidget(self.frame_mcu)
        self.grid_layout_mcu = QGridLayout()
        self.frame_mcu.setLayout(self.grid_layout_mcu)

        self.frame_controller = QFrame()
        self.frame_controller.setFrameStyle(QFrame.Box)
        self.frame_controller.setFrameShadow(QFrame.Sunken)
        self.layout_2.addWidget(self.frame_controller)
        self.grid_layout_controller = QGridLayout()
        self.frame_controller.setLayout(self.grid_layout_controller)


        self._combo_mcu_model_id = self._create_combo_box( \
            self.grid_layout_mcu, self._mcu_emulated_model, \
                'Emulation:', mcu_model_ids)

        connection_types = [MackieHostControl.ASSUME_SUCCESSFUL_CONNECTION, \
                                MackieHostControl.CHALLENGE_RESPONSE, \
                                MackieHostControl.WAIT_FOR_MIDI_DATA]
        self._combo_mcu_connection = self._create_combo_box( \
            self.grid_layout_mcu, self._mcu_connection, \
                'Connection:', connection_types)

        self._combo_mcu_midi_input = self._create_combo_box( \
            self.grid_layout_mcu, self._mcu_midi_input, \
                'MIDI In:', MidiConnection.get_midi_inputs())

        self._combo_mcu_midi_output = self._create_combo_box( \
            self.grid_layout_mcu, self._mcu_midi_output, \
                'MIDI Out:', MidiConnection.get_midi_outputs())


        self._combo_hardware_controller = self._create_combo_box( \
            self.grid_layout_controller, self._hardware_controller, \
                'Controller:', hardware_controllers)

        self._combo_controller_midi_input = self._create_combo_box( \
            self.grid_layout_controller, self._controller_midi_input, \
                'MIDI In:', MidiConnection.get_midi_inputs())

        self._combo_controller_midi_output = self._create_combo_box( \
            self.grid_layout_controller, self._controller_midi_output, \
                'MIDI Out:', MidiConnection.get_midi_outputs())

        self.grid_layout_controller.addWidget( \
            self._edit_usage_hint, self.grid_layout_controller.rowCount(), \
                0, 1, 2)

        self.layout.addWidget(self._edit_logger)

        self.bottom_layout = QHBoxLayout()
        self.layout_2.addLayout(self.bottom_layout)

        self.button_start_stop = QPushButton('&Start')
        self.bottom_layout.addWidget(self.button_start_stop)
        self.button_start_stop.setDefault(True)
        self.button_start_stop.setFocus()
        self.button_start_stop.clicked.connect(self.interconnector_start_stop)

        self.button_close = QPushButton('&Close')
        self.bottom_layout.addWidget(self.button_close)
        self.button_close.clicked.connect(self.close_application)

        self.button_about = QPushButton('A&bout')
        self.bottom_layout.addWidget(self.button_about)
        self.button_about.clicked.connect(self.display_about)

        self._enable_controls(True)

        self._timer = QTimer(self)
        self._timer.setInterval(int(self._midi_latency))
        self._timer.timeout.connect(self.process_midi_input)