From 89b220d90f1dff4f8ef2dc69f56cd6038cde6c44 Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Wed, 8 Jul 2009 08:21:32 -0700 Subject: [PATCH] Fix a bug in DB loading and use statusbar for messages. --- mainapp.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) 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 -- 2.39.5