示例#1
0
    def __init__(self, GuitarTools, **kwargs):
        super().__init__(**kwargs)

        self.GuitarTools = GuitarTools

        loader = UiLoader()

        self.ui = loader.load(LocalPath('listening.ui'))
示例#2
0
    def __init__(self, GuitarTools, **kwargs):

        self.GuitarTools = GuitarTools

        loader = UiLoader()

        loader.registerCustomWidget(QTableWidgetFixed)
        self.ui = loader.load(LocalPath('changes.ui'))

        # Load the UI before calling super
        super().__init__(**kwargs)

        #
        # Setup table widget (desire to subclass) TESTING!
        #

        self.ui.tableWidget_Chords.setColumnCount(5)
        self.ui.tableWidget_Chords.setRowCount(0)
        self.ui.tableWidget_Chords.setHorizontalHeaderLabels(
            ["Active", "Required", "Chord", "Quality", "Pairs"])
        self.ui.tableWidget_Chords.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.ui.tableWidget_Chords.setFixedWidth()

        # Changes table
        self.ui.tableWidget_Changes.resizeColumnsToContents()
        self.ui.tableWidget_Changes.resizeRowsToContents()

        #
        # Setup combo boxes
        #

        self.ui.comboBox_Chord1.setInsertPolicy(
            QtWidgets.QComboBox.InsertAlphabetically)
        self.ui.comboBox_Chord2.setInsertPolicy(
            QtWidgets.QComboBox.InsertAlphabetically)

        #
        # Connect widgets!
        #

        self.ui.pushButton_SuggestChanges.clicked.connect(
            self.SuggestChordChanges)
        self.ui.pushButton_RecordChanges.clicked.connect(
            self.RecordChordChanges)
        self.ui.pushButton_NewChord.clicked.connect(self.NewChord)

        #
        # Logic for actual suggesting of chord changes
        #

        self._history = {}

        # Seed the random number generator
        random.seed()
示例#3
0
    def __init__(self, GuitarTools, **kwargs):
                
        self.GuitarTools = GuitarTools
        
        loader = UiLoader()

        loader.registerCustomWidget(QTableWidgetFixed)
        self.ui = loader.load(LocalPath('songs.ui'))
        
        # Load the UI before calling super
        super().__init__(**kwargs)

        #
        # Setup table widget (desire to subclass) TESTING!
        #

        self.ui.tableWidget_Songs.setColumnCount(3)
        self.ui.tableWidget_Songs.setRowCount(0)
        # self.ui.tableWidget_Songs.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        
        self.ui.tableWidget_Songs.setHorizontalHeaderLabels(["Song", 
                                                              "Active", 
                                                              "Age"
                                                              ])

        header = self.ui.tableWidget_Songs.horizontalHeader()       
        header.setSectionResizeMode(SONG_NAME_INDEX, QtWidgets.QHeaderView.Stretch)
        header.setSectionResizeMode(ACTIVE_CHECK_INDEX, QtWidgets.QHeaderView.ResizeToContents)
        header.setSectionResizeMode(SONG_QUALITY_INDEX, QtWidgets.QHeaderView.ResizeToContents)
        
        #
        # Connect widgets!
        #

        self.ui.pushButton_SuggestSong.clicked.connect(self.SuggestSong)
        self.ui.pushButton_NewSong.clicked.connect(self.NewSong)
        
        self._history = {}
        
        # Seed the random number generator
        random.seed()
示例#4
0
    def __init__(self, GuitarTools, **kwargs):

        # Must load UI first!
        loader = UiLoader()
        loader.registerCustomWidget(QProgressBarNumber)

        self.ui = loader.load(LocalPath('timer.ui'))

        self.GuitarTools = GuitarTools

        # set all autoconfig items
        super().__init__(**kwargs)

        self.ui.pushButton_StartPause.clicked.connect(self.timerStartPause)
        self.ui.pushButton_Reset.clicked.connect(self.timerReset)

        #
        # Set defaults
        #

        self.timerReset()
示例#5
0
    def __init__(self, *args, **kwargs):

        self.url = QtCore.QUrl()
        super().__init__(*args, **kwargs)

        loader = UiLoader()
        loader.registerCustomWidget(QWebEngineViewBrowser)
        loader.load(LocalPath('browser.ui'), self)

        #
        # Setup browser
        #

        # wow, I segfault python:
        # self.webEngineViewBrowser_Browser.page().profile().cookieStore().deleteAllCookies()

        webEngineProfile = QtWebEngineWidgets.QWebEngineProfile.defaultProfile(
        )

        webEngineProfile.setPersistentCookiesPolicy(
            QtWebEngineWidgets.QWebEngineProfile.NoPersistentCookies)

        webEngineProfile.cookieStore().deleteAllCookies()

        #
        # Link Browser and address display
        #

        self.lineEdit_address.editingFinished.connect(self.load)
        self.webEngineViewBrowser_Browser.urlChanged.connect(self.urlChanged)

        #
        # Direct Browser to first site
        #

        self.webEngineViewBrowser_Browser.load(self.url)
示例#6
0
    def __init__(self, application, **kwargs):
        super().__init__(**kwargs)

        self.qt_application = application

        loader = UiLoader()

        self.ui = loader.load(LocalPath('mainwindow.ui'), GuitarToolsWindow())

        # set all autoconfig items
        self.set_state(**kwargs)

        self.scriptDir = os.path.dirname(
            os.path.realpath(__file__)) + os.path.sep
        IconPath = self.scriptDir + 'Images' + os.path.sep + 'GuitarIcon.png'

        # set icon
        self.ui.setWindowIcon(QtGui.QIcon(IconPath))
        self.qt_application.setWindowIcon(QtGui.QIcon(IconPath))

        # #####################################################################
        #
        # Custom widgets
        #
        # #####################################################################

        #
        # Timer
        #
        self.Timer = Timer(self, autoconfig_name_key='timer')
        self.ui.verticalLayout_Timer.addWidget(self.Timer.ui)
        self.Timer.ui.progressBarNumber_Countdown.beep.connect(
            self.qt_application.beep)

        #
        # Metronome
        #
        self.Metronome = Metronome(autoconfig_name_key='metronome')
        self.ui.verticalLayout_Metronome.addWidget(self.Metronome)

        # Now link the metronome to the timer
        self.Timer.ui.progressBarNumber_Countdown.repeatTimeout.connect(
            self.Metronome.externalTimerIndex)

        self.Metronome.timerSettings.connect(
            self.Timer.ui.progressBarNumber_Countdown.setTimes)

        self.Metronome.timerSettingsGo.connect(
            self.Timer.ui.progressBarNumber_Countdown.stop)

        self.Metronome.timerSettingsGo.connect(
            self.Timer.ui.progressBarNumber_Countdown.start)

        self.ui.verticalSlider_Volume.valueChanged.connect(
            self.Metronome.setVolume)
        self.ui.verticalSlider_Volume.valueChanged.emit(
            self.ui.verticalSlider_Volume.value())

        #
        # Chord changes
        #
        self.Changes = Changes(self, autoconfig_name_key='changes')
        self.ui.verticalLayout_Changes.addWidget(self.Changes.ui)

        #
        # Songs Suggestor
        #
        self.Songs = Songs(self, autoconfig_name_key='songs')
        self.ui.verticalLayout_Songs.addWidget(self.Songs.ui)

        #
        # Listening
        #
        self.Listening = Listening(self, autoconfig_name_key='listening')
        self.ui.verticalLayout_Listening.addWidget(self.Listening.ui)

        #
        # Render menubar: work around a bug in osx where menubar is not active.
        #
        if sys.platform == "darwin":
            self.ui.menubar.setNativeMenuBar(False)

        # Window Title
        self._SetWindowTitle()

        #
        # Connect widgets!
        #

        # Select log file.
        self.ui.actionSelect_Log_File.triggered.connect(self.SetLogFile)
        self._logfile = None

        self.ui.actionSave_Log_File.triggered.connect(self.SaveChanges)

        self.SetFilename(None)

        # Quit
        self.ui.actionQuit.triggered.connect(self.Quit)

        self.qt_application.aboutToQuit.connect(self.GracefulShutdown)

        #
        # Setup complete.  Show the user interface
        #

        self.ui.show()

        # Now load the default settings

        ConfigFile = self.scriptDir + 'examples' + os.path.sep + 'changes.ini'
        self.SetFilename(ConfigFile)
        self._SetWindowTitle()
示例#7
0
    def __init__(self, *args, **kwargs):
        
        # Setup widget
        QtWidgets.QWidget.__init__(self, *args, **kwargs)
        loader = UiLoader()
        loader.registerCustomWidget(QTableWidgetMetronome)
        loader.load(LocalPath('metronome.ui'), self)
        
        #
        # Setup initial values
        #

        self._externalTimerIndex = -1
        self._MetronomeIndex = 0
        self._MetronomeLoud = True
        self._TimerConnected = False

        # Perform autoconfig
        AutoConfig.__init__(self, autoconfig_name_key='metronome')
        
        # Empty array of emph buttons
        self._pushButtons_Click = []
        
        #
        # Connect widgets!
        #

        # Metronome sound
        AudioFormat = QtMultimedia.QAudioFormat()
        AudioFormat.setChannelCount(1)
        AudioFormat.setSampleRate(44100)
        AudioFormat.setSampleSize(16)
        AudioFormat.setCodec("audio/pcm")
        AudioFormat.setByteOrder(QtMultimedia.QAudioFormat.LittleEndian)
        AudioFormat.setSampleType(QtMultimedia.QAudioFormat.SignedInt)
        
        self.MetronomeOutput = QtMultimedia.QAudioOutput(AudioFormat)
        self.MetronomeOutput.setVolume(1.0)
        self.MetronomeBuffer = QtCore.QBuffer()
        self.MetronomeDataSilent = QtCore.QByteArray()
        self.MetronomeDataQuiet = QtCore.QByteArray()
        self.MetronomeDataLoud = QtCore.QByteArray()

        self._make_click()
        
        # Metronome Flash timer
        self.MetronomeTimer = QtCore.QTimer()
        self.MetronomeTimer.setTimerType(QtCore.Qt.PreciseTimer)
        
        # Metronome MetronomeUnFlash timer
        self.MetronomeUnFlashTimer = QtCore.QTimer()
        self.MetronomeUnFlashTimer.setTimerType(QtCore.Qt.PreciseTimer)

        # Start / stop metronome
        self.comboBox_Metronome.currentIndexChanged.connect(self.MetronomeStartStop)
        
        # Spinboxes: if metronome is running, change speed / emphasis based on changes
        self.BPM_spinBox.setKeyboardTracking(False)
        self.BPM_spinBox.valueChanged.connect(self.MetronomeUpdate)

        self.Emph_spinBox.setKeyboardTracking(False)
        self.Emph_spinBox.valueChanged.connect(self.emphUpdate)
        
        # Build button array
        self.emphUpdate()

        self.spinBox_Skipped.setKeyboardTracking(False)
        self.spinBox_Skipped.valueChanged.connect(self.MetronomeUpdate)

        # Presets
        self.pushButton_Preset_1.clicked.connect(lambda: self.Preset(1))
        self.pushButton_Preset_2.clicked.connect(lambda: self.Preset(2))
        self.pushButton_Preset_5.clicked.connect(lambda: self.Preset(5))
        self.pushButton_Preset_10.clicked.connect(lambda: self.Preset(10))

        # Table mode
        self.tableWidgetMetronome.setColumnCount(4)
        self.tableWidgetMetronome.setRowCount(0)
        self.tableWidgetMetronome.setHorizontalHeaderLabels(
                ["Duration", "BPM", "Beats per measure", "Skipped"]
                )
        self.tableWidgetMetronome.setFixedWidth()