From ea3c529fdc87e0802b579abd6abe88fff0eb3eba Mon Sep 17 00:00:00 2001 From: Leonardo Robol Date: Sat, 11 Apr 2009 10:44:21 +0200 Subject: [PATCH] Modifiche da casa --- latex_manager.py | 7 ------ songbook-editor.mm | 30 ++------------------------ songbook-editor.py | 63 ------------------------------------------------------ 3 files changed, 2 insertions(+), 98 deletions(-) diff --git a/latex_manager.py b/latex_manager.py index 089adff..080cc7b 100644 --- a/latex_manager.py +++ b/latex_manager.py @@ -14,8 +14,6 @@ class latex_manager(): year = song.year body = song.body - # We really have to assume that latex_song is unicode, - # or the write() function will eat us! latex_song = unicode() latex_song += "\\begin{song}{" + title + "}{" + tone + "}\n{" + mauthor + "}\n{" + tauthor + "}\n{" + year + "}" + "{}\n\n\\index{" + title + "}\n\n" @@ -31,13 +29,8 @@ class latex_manager(): latex_song += "\n\\end{song}\n\n" - # Transform chords in LaTeX Chords latex_song = re.sub("\[", "\\Ch{", latex_song) - latex_song = re.sub("\](\w|\s)(\w|\s)(\w|\s)", self.quadra_to_chord_end, latex_song) latex_song = re.sub("\]", "}{}", latex_song) return latex_song - def quadra_to_chord_end(self,m): - st = "}{" + m.group(1) + m.group(2) + m.group(3) + "}" - return st diff --git a/songbook-editor.mm b/songbook-editor.mm index 762df77..fb1dc53 100644 --- a/songbook-editor.mm +++ b/songbook-editor.mm @@ -1,29 +1,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/songbook-editor.py b/songbook-editor.py index 49f301e..e69de29 100755 --- a/songbook-editor.py +++ b/songbook-editor.py @@ -1,63 +0,0 @@ -#!/usr/bin/env python - -from PyQt4 import QtGui, QtCore -from interface import * -from song import * -from latex_manager import * -import re - -class interface(QtGui.QMainWindow): - def __init__(self, lm, parent=None): - super(interface, self).__init__(parent) - self.ui = Ui_MainWindow() - self.ui.setupUi(self) - - # Connections - self.connect(self.ui.actionEsci_2, QtCore.SIGNAL("activated()"), self.exit_called) - self.connect(self.ui.btn_create_latex_song, QtCore.SIGNAL("clicked()"), self.create_latex_song) - - # Functions to manage events - def exit_called(self): - print "TODO: Save data on exit" - - def get_active_song(self): - newtitle = unicode(self.ui.le_title.text()) - newmauthor = unicode(self.ui.le_mauthor.text()) - newtauthor = unicode(self.ui.le_tauthor.text()) - newyear = unicode(self.ui.le_year.text()) - newtone = unicode(self.ui.le_tone.text()) - newsong = song(newtitle, [], newmauthor, newtauthor, newtone, newyear) - - newbody = unicode(self.ui.te_body.toPlainText()) - print newbody - newbody = re.split("\n\n+", newbody) - for paragraph in newbody: - if(len(paragraph) < 3): - break - if( (paragraph[0] == 'R') & (paragraph[1] == ':') ): - newsong.add_chorus(paragraph.split("R:")[1]) - else: - newsong.add_verse(paragraph) - - return newsong - - def create_latex_song(self): - song = self.get_active_song() - filetowrite = lm.create_song(song) - filename = QtGui.QFileDialog.getSaveFileName(self, "Salva file latex", "/home/leonardo", "LaTeX Source File (*.tex)") - handle = open(filename, 'w') - # Just remember that filetowrite is an "unicode" object, treat it - # as it just deserve - handle.write(filetowrite.encode("utf-8")) - handle.close() - - - - - -if __name__ == "__main__": - app = QtGui.QApplication(None) - lm = latex_manager() - widget = interface(lm) - widget.show() - app.exec_() -- 2.1.4