From 7ab5130fbb0ccafad686dbaa39becaf6bb7248cd Mon Sep 17 00:00:00 2001 From: Nils <> Date: Sun, 19 Dec 2021 21:46:37 +0100 Subject: [PATCH] fix some float conversions that broke with python 3.10 and pyqt --- engine/main.py | 3 ++- qtgui/mainwindow.py | 9 ++++----- qtgui/songeditor.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engine/main.py b/engine/main.py index d8db5f9..ce2f6dd 100644 --- a/engine/main.py +++ b/engine/main.py @@ -157,7 +157,8 @@ class Data(template.engine.sequencer.Score): #Possible case, but needs checking. elif int(inverseScaleFactor) == inverseScaleFactor: - assert int(scaleFactor * self.howManyUnits) == scaleFactor * self.howManyUnits, (scaleFactor, self.howManyUnits) + #The following assertion is simply not correct. scaleFactor 0.5 and howManyUnits 11 means with 11 steps per measure you go from group 4 to 2, or 2 to 1. With "delete if fail". normal operation + #assert int(scaleFactor * self.howManyUnits) == scaleFactor * self.howManyUnits, (scaleFactor, self.howManyUnits) #Test, if in "fail" mode if errorHandling == "fail": diff --git a/qtgui/mainwindow.py b/qtgui/mainwindow.py index 28825ac..c492d59 100644 --- a/qtgui/mainwindow.py +++ b/qtgui/mainwindow.py @@ -371,15 +371,16 @@ class MainWindow(TemplateMainWindow): bpmCheckbox.stateChanged.connect(bpmCheckboxChanged) - def callback_quarterNotesPerMinuteChanged(newValue): - #We just receive an int, not a dict. + def callback_quarterNotesPerMinuteChanged(newValue:float): + """We just receive a float, not a dict. Jack supports floats as tempo. + However, we only use ints here and our spinbox is int.""" beatsPerMinute.blockSignals(True) bpmCheckbox.blockSignals(True) if newValue: bpmCheckbox.setChecked(True) beatsPerMinute.setEnabled(True) - beatsPerMinute.setValue(newValue) + beatsPerMinute.setValue(int(newValue)) else: beatsPerMinute.setEnabled(False) bpmCheckbox.setChecked(False) @@ -389,8 +390,6 @@ class MainWindow(TemplateMainWindow): bpmCheckbox.blockSignals(False) api.callbacks.quarterNotesPerMinuteChanged.append(callback_quarterNotesPerMinuteChanged) - - #Number of Measures numberOfMeasures = QtWidgets.QSpinBox() numberOfMeasures.setMinimum(1) diff --git a/qtgui/songeditor.py b/qtgui/songeditor.py index 77bb9fd..c60e4bb 100644 --- a/qtgui/songeditor.py +++ b/qtgui/songeditor.py @@ -1455,7 +1455,7 @@ class Playhead(QtWidgets.QGraphicsLineItem): PlayHead height is set in SongEditor.callback_numberOfTracksChanged. """ - x = tickindex / self.parentScene.ticksToPixelRatio + x = int(tickindex / self.parentScene.ticksToPixelRatio) self.setX(x) if playbackStatus: # api.duringPlayback: scenePos = self.parentScene.parentView.mapFromScene(self.pos())