Browse Source

Update examples and fix preview crash

master
Ivan Holmes 5 years ago
parent
commit
7899aee96e
  1. BIN
      examples/example.pdf
  2. BIN
      examples/example.png
  3. 2
      examples/example.xml
  4. 1
      examples/test.xml
  5. 5
      gui.py

BIN
examples/example.pdf

BIN
examples/example.png

Before

Width: 2480  |  Height: 3507  |  Size: 274 KiB

2
examples/example.xml

@ -1 +1 @@
<chordsheet><title>Composition</title><composer>A. Person</composer><timesignature>4</timesignature><chords><chord><name>B</name><voicing instrument="guitar">x,x,2,3,4,1</voicing></chord><chord><name>E</name><voicing instrument="guitar">0,2,2,1,0,0</voicing></chord><chord><name>Cm9</name><voicing instrument="guitar">x,x,8,8,8,10</voicing></chord><chord><name>D7&#9837;5&#9839;9</name></chord></chords><progression><block><length>4</length><chord>B</chord><notes>These are notes.</notes></block><block><length>4</length><chord>E</chord></block><block><length>12</length><chord>Cm9</chord></block><block><length>6</length><chord>D7&#9837;5&#9839;9</chord></block><block><length>6</length><notes>For quiet contemplation.</notes></block></progression></chordsheet>
<chordsheet><title>Example Song</title><composer>Ivan Holmes</composer><timesignature>4</timesignature><chords><chord><name>C</name><voicing instrument="guitar">x,3,2,0,1,0</voicing></chord><chord><name>F</name><voicing instrument="guitar">1,3,3,2,1,1</voicing></chord><chord><name>G</name><voicing instrument="guitar">3,2,0,0,0,3</voicing></chord><chord><name>C/G</name><voicing instrument="guitar">3,3,2,0,1,0</voicing></chord><chord><name>Dm</name><voicing instrument="guitar">x,x,0,2,3,1</voicing></chord></chords><progression><block><length>16</length><chord>C</chord><notes>Intro, strum lightly</notes></block><block><length>4</length><chord>C</chord></block><block><length>4</length><chord>F</chord></block><block><length>8</length><chord>G</chord></block><block><length>4</length><chord>C</chord></block><block><length>4</length><chord>F</chord></block><block><length>8</length><chord>G</chord></block><block><length>4</length><chord>C</chord></block><block><length>4</length><chord>Dm</chord></block><block><length>4</length><chord>C/G</chord></block><block><length>4</length><chord>G</chord></block><block><length>4</length><chord>C</chord></block><block><length>4</length><notes>Contemplation time</notes></block><block><length>8</length><chord>C</chord><notes>Crescendo until end</notes></block></progression></chordsheet>

1
examples/test.xml

@ -0,0 +1 @@
<chordsheet><title>Composition</title><composer>A. Person</composer><timesignature>4</timesignature><chords><chord><name>B</name><voicing instrument="guitar">x,x,2,3,4,1</voicing></chord><chord><name>E</name><voicing instrument="guitar">0,2,2,1,0,0</voicing></chord><chord><name>Cm9</name><voicing instrument="guitar">x,x,8,8,8,10</voicing></chord><chord><name>D7&#9837;5&#9839;9</name></chord></chords><progression><block><length>4</length><chord>B</chord><notes>These are notes.</notes></block><block><length>4</length><chord>E</chord></block><block><length>12</length><chord>Cm9</chord></block><block><length>6</length><chord>D7&#9837;5&#9839;9</chord></block><block><length>6</length><notes>For quiet contemplation.</notes></block><block><length>46</length><chord>D7&#9837;5&#9839;9</chord><notes>A very long block to test wrapping!</notes></block></progression></chordsheet>

5
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,6 +472,7 @@ class DocumentWindow(QMainWindow):
"""
Update the preview shown by rendering a new PDF and drawing it to the scroll area.
"""
try:
self.currentPreview = io.BytesIO()
savePDF(self.doc, self.style, self.currentPreview)
@ -484,6 +485,8 @@ class DocumentWindow(QMainWindow):
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):
"""

Loading…
Cancel
Save