X-Git-Url: https://harishankar.org/repos/?p=biaweb_qt.git;a=blobdiff_plain;f=main_window.py;h=36320753c987a4ce42230e259b2596975651cfe5;hp=d19186605a83a3726fc4c2e01a18d6d0ae8ea746;hb=51a6ece9a63764e7a57230081d299f36d3186918;hpb=16ae2cf83fb95a5d87220d3f06608c8560afe5a6 diff --git a/main_window.py b/main_window.py index d191866..3632075 100644 --- a/main_window.py +++ b/main_window.py @@ -4,16 +4,38 @@ import PyQt4 import ui_main_window import site_configuration_dialog as scd +import biaweb_db import sys class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow): def __init__ (self): PyQt4.QtGui.QMainWindow.__init__ (self) self.setupUi (self) + self.current_db = None def onFileNew (self): dlg = scd.SiteConfigDialog (self) - dlg.exec_ () + if dlg.exec_ () == PyQt4.QtGui.QDialog.Accepted: + site_title = str (dlg.site_title.text ()).strip () + site_url = str (dlg.site_url.text ()).strip () + keywords = str (dlg.keywords.text ()).strip () + destination = str (dlg.destination.text ()).strip () + description = str (dlg.description.toPlainText ()).strip () + num_rss = dlg.num_rss_items.value () + copyright = str (dlg.copyright.text ()).strip () + + savefilename = PyQt4.QtGui.QFileDialog.getSaveFileName (self, "Save site database to") + + if savefilename: + self.current_db = savefilename + self.setWindowTitle ("BiaWeb - " + self.current_db) + flag = biaweb_db.create_db (str (savefilename), site_title, site_url, keywords, description, + copyright, num_rss, destination) + if flag == True: + PyQt4.QtGui.QMessageBox.information (self, "Success", + "New site db successfully created") + else: + PyQt4.QtGui.QMessageBox.critical (self, "Error", "SQLite 3 error in creating database.") def onFileQuit (self): sys.exit (0)