Possibilità di esportare il canzoniere in latex (anche se

Leonardo Robol [2009-04-26 17:11]
Possibilità di esportare il canzoniere in latex (anche se
non ancora completata)
Filename
latex_manager.py
songbook-editor.py
diff --git a/latex_manager.py b/latex_manager.py
index 73c9ab7..eeb0441 100644
--- a/latex_manager.py
+++ b/latex_manager.py
@@ -65,3 +65,18 @@ class latex_manager():
             else:
                 j += 1
         return m
+
+    def export_songbook(self,song_list):
+        # Assume that song list is an array of songs and
+        # create a songbook with them
+
+        # New buffer
+        buf = unicode()
+
+        for song in song_list:
+            buf += "\n\n" # Put some space between songs
+            buf += "% Canzone:" + song.title + "\n\n"
+            buf += self.create_song(song)
+
+        # Give buffer back to be printed
+        return buf
diff --git a/songbook-editor.py b/songbook-editor.py
index ffbc86e..1a4bdf2 100755
--- a/songbook-editor.py
+++ b/songbook-editor.py
@@ -182,12 +182,18 @@ class interface(QtGui.QMainWindow):

     def export_songbook(self):
         # Chiedo al latex manager di farlo.. :)
-        return 0
-
-
-
-
+        sbk = lm.export_songbook(self.song_db)
+
+        # Apriamo un file
+        filename = QtGui.QFileDialog.getSaveFileName(self, "Salva file latex", "/home/leonardo", "LaTeX Source File (*.tex)")
+        if(filename == ''):
+            # We do not have to do nothing, the user clicked Cancel
+            return 0
+        handle = open(filename, 'w')
+        handle.write(sbk.encode("utf-8"))
+        handle.close()

+


 if __name__ == "__main__":
ViewGit