From: Drew Fisher Date: Sat, 22 Aug 2009 03:06:02 +0000 (-0500) Subject: Boilerplate for a photo-merge class. X-Git-Url: http://git.zarvox.org/shortlog/%7B%7B%20url_for%28%27main.logout_page%27%29%20%7D%7D?a=commitdiff_plain;h=7c94470c252c17848828a0462b9a5d5f01b92720;p=wp3.git Boilerplate for a photo-merge class. --- diff --git a/chooseaction.py b/chooseaction.py index 4433855..82c13ae 100644 --- a/chooseaction.py +++ b/chooseaction.py @@ -34,4 +34,7 @@ class ChooseAction (QWidget): pass def exportDocument(self): fileName = QFileDialog.getSaveFileName(self, "Save new file as:", ".", "OpenDocument Text Documents (*.odt)") - print "Will export db as",fileName + if not fileName.isEmpty(): + if not fileName.endsWith(".odt"): # if they leave off the extension, add it + fileName = fileName.append(".odt") + self.emit(QtCore.SIGNAL("exportDocument(QString)"),fileName) diff --git a/mainapp.py b/mainapp.py index ae0102c..e57fe55 100644 --- a/mainapp.py +++ b/mainapp.py @@ -4,6 +4,7 @@ from PyQt4.QtSql import * from chooseaction import ChooseAction from editperson import EditPerson +from mergephotos import MergePhotos class MainApp (QMainWindow): schema = "CREATE TABLE people ( id INTEGER PRIMARY KEY AUTOINCREMENT, forename TEXT NOT NULL, surname TEXT NOT NULL, netid TEXT NOT NULL, email TEXT, birthday TEXT, phone TEXT, major TEXT, dorm TEXT, room INTEGER, photo BLOB, createtime TEXT NOT NULL, mtime TEXT NOT NULL);" @@ -20,8 +21,10 @@ class MainApp (QMainWindow): self.center = QStackedWidget() self.chooseaction = ChooseAction(self,self.db) self.editperson = EditPerson(self,self.db) + self.mergephotos = MergePhotos(self,self.db) self.center.addWidget(self.chooseaction) self.center.addWidget(self.editperson) + self.center.addWidget(self.mergephotos) self.setCentralWidget(self.center) self.createActions() @@ -42,6 +45,7 @@ class MainApp (QMainWindow): self.fileQuitAction = QAction("&Quit",self) QObject.connect( self.fileQuitAction, SIGNAL("triggered()"), self.quit) QObject.connect( self.chooseaction, SIGNAL("editPerson()"), self.editPersonSlot) + QObject.connect( self.chooseaction, SIGNAL("exportDocument(QString)"), self.exportDocumentSlot) QObject.connect( self.editperson, SIGNAL("done()"), self.returnToMainMenu) QObject.connect( self, SIGNAL("databaseChanged(QString)"), self.editperson.updateDB) QObject.connect( self, SIGNAL("mergeDone()"), self.editperson.reselect ) @@ -143,6 +147,9 @@ class MainApp (QMainWindow): def editPersonSlot(self): self.editperson.model.select() # update the table self.center.setCurrentWidget(self.editperson) + def mergePhotos(self): + print "beginning photo merge" + self.mergephotos.beginMerge() if __name__ == "__main__" : diff --git a/mergephotos.py b/mergephotos.py new file mode 100644 index 0000000..f9d3198 --- /dev/null +++ b/mergephotos.py @@ -0,0 +1,16 @@ +from PyQt4.QtCore import * +from PyQt4.QtGui import * +from PyQt4.QtSql import * + +class MergePhotos(QWidget): + def __init__(self, parent=None, db=None): + QWidget.__init__(self, parent) + self.db = db + self.layout = QGridLayout() + self.label = QLabel("Content goes here") + self.layout.addWidget(self.label,0,0) + self.setLayout(self.layout) + + def beginMerge(self): + print QFileDialog.getExistingDirectory( None, "Pick folder of photos", ".") +