From: Drew Fisher Date: Wed, 8 Jul 2009 15:21:32 +0000 (-0700) Subject: Fix a bug in DB loading and use statusbar for messages. X-Git-Url: http://git.zarvox.org/shortlog/static/%7B%7B%20url_for%28%27main.signup_page%27%29%20%7D%7D?a=commitdiff_plain;h=89b220d90f1dff4f8ef2dc69f56cd6038cde6c44;p=wp3.git Fix a bug in DB loading and use statusbar for messages. --- diff --git a/mainapp.py b/mainapp.py index d7539f3..599cd3d 100644 --- a/mainapp.py +++ b/mainapp.py @@ -55,22 +55,27 @@ class MainApp (QMainWindow): def newFile(self): - self.db.close() fileName = QFileDialog.getSaveFileName(self, "Save new file as:", ".", "Databases (*.db)") - self.db.setDatabaseName(fileName) - self.db.open() - q = QSqlQuery(self.db) - q.exec_(MainApp.schema) - print "Closed the existing database, created",fileName + if not fileName.isEmpty(): # If they cancelled, do nothing + if not fileName.endsWith(".db"): # if they leave off the extension, add it + fileName = fileName.append(".db") + self.db.close() + self.db.setDatabaseName(fileName) + self.db.open() + q = QSqlQuery(self.db) + q.exec_(MainApp.schema) + self.statusBar().showMessage("Closed the existing database, created " + fileName) + else: + self.statusBar().showMessage("Cancelled creating new database") def openFile(self): fileName = QFileDialog.getOpenFileName(self, "Open dataset", ".", "Databases (*.db)") if not fileName.isEmpty(): self.db.close() self.db.setDatabaseName(fileName) self.db.open() - print "Loaded database",fileName + self.statusBar().showMessage("Successfully loaded database " + fileName) else: - print "Canceled loading database" + self.statusBar().showMessage("Canceled loading database") def mergeWizard(self): fileName = QFileDialog.getOpenFileName(self, "Import which dataset?", ".", "Databases (*.db)" ) print "and then we'd import data from",fileName