diff --git a/examples/example.pdf b/examples/example.pdf
deleted file mode 100644
index b0dbd0e..0000000
Binary files a/examples/example.pdf and /dev/null differ
diff --git a/examples/example.png b/examples/example.png
deleted file mode 100644
index 00dd3ea..0000000
Binary files a/examples/example.png and /dev/null differ
diff --git a/examples/example.xml b/examples/example.xml
index 4bbb21e..b0f503a 100644
--- a/examples/example.xml
+++ b/examples/example.xml
@@ -1 +1 @@
-CompositionA. Person4Bx,x,2,3,4,1E0,2,2,1,0,0Cm9x,x,8,8,8,10D7♭5♯94BThese are notes.4E12Cm96D7♭5♯96For quiet contemplation.
\ No newline at end of file
+Example SongIvan Holmes4Cx,3,2,0,1,0F1,3,3,2,1,1G3,2,0,0,0,3C/G3,3,2,0,1,0Dmx,x,0,2,3,116CIntro, strum lightly4C4F8G4C4F8G4C4Dm4C/G4G4C4Contemplation time8CCrescendo until end
\ No newline at end of file
diff --git a/examples/test.xml b/examples/test.xml
new file mode 100644
index 0000000..ca83cb8
--- /dev/null
+++ b/examples/test.xml
@@ -0,0 +1 @@
+CompositionA. Person4Bx,x,2,3,4,1E0,2,2,1,0,0Cm9x,x,8,8,8,10D7♭5♯94BThese are notes.4E12Cm96D7♭5♯96For quiet contemplation.46D7♭5♯9A very long block to test wrapping!
\ No newline at end of file
diff --git a/gui.py b/gui.py
index 3a59c50..1dca7f2 100755
--- a/gui.py
+++ b/gui.py
@@ -250,7 +250,6 @@ class DocumentWindow(QMainWindow):
filePath = QFileDialog.getSaveFileName(self.window.tabWidget, 'Save file', self.getPath("workingPath"), "Chordsheet ML files (*.xml *.cml)")[0]
if filePath:
self.saveFile(filePath)
- self.updateTitleBar() # as we now have a new filename
def saveFile(self, filePath):
"""
@@ -260,6 +259,7 @@ class DocumentWindow(QMainWindow):
self.doc.saveXML(self.currentFilePath)
self.lastDoc = copy(self.doc)
self.setPath("workingPath", self.currentFilePath)
+ self.updateTitleBar() # as we may have a new filename
def menuFileSavePDFAction(self):
self.updateDocument()
@@ -472,18 +472,21 @@ class DocumentWindow(QMainWindow):
"""
Update the preview shown by rendering a new PDF and drawing it to the scroll area.
"""
- self.currentPreview = io.BytesIO()
- savePDF(self.doc, self.style, self.currentPreview)
-
- pdfView = fitz.Document(stream=self.currentPreview, filetype='pdf')
- pix = pdfView[0].getPixmap(matrix = fitz.Matrix(4, 4), alpha = False) # render at 4x resolution and scale
+ try:
+ self.currentPreview = io.BytesIO()
+ savePDF(self.doc, self.style, self.currentPreview)
- fmt = QImage.Format_RGB888
- qtimg = QImage(pix.samples, pix.width, pix.height, pix.stride, fmt)
+ pdfView = fitz.Document(stream=self.currentPreview, filetype='pdf')
+ pix = pdfView[0].getPixmap(matrix = fitz.Matrix(4, 4), alpha = False) # render at 4x resolution and scale
- self.window.imageLabel.setPixmap(QPixmap.fromImage(qtimg).scaled(self.window.scrollArea.width()-30, self.window.scrollArea.height()-30, Qt.KeepAspectRatio, transformMode=Qt.SmoothTransformation))
- # -30 because the scrollarea has a margin of 12 each side (extra for safety)
- self.window.imageLabel.repaint() # necessary on Mojave with PyInstaller (or previous contents will be shown)
+ fmt = QImage.Format_RGB888
+ qtimg = QImage(pix.samples, pix.width, pix.height, pix.stride, fmt)
+
+ self.window.imageLabel.setPixmap(QPixmap.fromImage(qtimg).scaled(self.window.scrollArea.width()-30, self.window.scrollArea.height()-30, Qt.KeepAspectRatio, transformMode=Qt.SmoothTransformation))
+ # -30 because the scrollarea has a margin of 12 each side (extra for safety)
+ self.window.imageLabel.repaint() # necessary on Mojave with PyInstaller (or previous contents will be shown)
+ except:
+ warning = QMessageBox.warning(self, "Preview failed", "Could not update the preview.", buttons=QMessageBox.Ok, defaultButton=QMessageBox.Ok)
def updateTitleBar(self):
"""