X-Git-Url: https://harishankar.org/repos/?p=biaweb_qt.git;a=blobdiff_plain;f=templates_dialog.py;h=20f2e18e76b88d7a4a8021aa31f0392a2310f7ba;hp=64cc70ca3158fa6b1f37dc49ee929e1f6396b7cb;hb=3ded989fee52f6804d0f8b5b5c0847a9030c7f04;hpb=6ba107bc3e5bef66a447978048e6c41ed038e969 diff --git a/templates_dialog.py b/templates_dialog.py index 64cc70c..20f2e18 100644 --- a/templates_dialog.py +++ b/templates_dialog.py @@ -16,12 +16,20 @@ class TemplatesDialog (PyQt4.QtGui.QDialog, ui_templates_dialog.Ui_TemplatesDial # populate the templates tpls = biaweb_db.get_templates (self.current_db) - for tpl_name, tpl_content in tpls: - self.templates.addItem (str (tpl_name)) + # if templates populated + if tpls: + for tpl_name, tpl_content in tpls: + self.templates.addItem (str (tpl_name)) + else: + PyQt4.QtGui.QMessageBox.critical (self, "Error", "SQLite 3 error in retrieving templates") def onEdit (self): # get the currently selected list item - tpl_name = str (self.templates.currentItem ().data (0).toString ()) + sel_item = self.templates.currentItem () + # if no item is selected return + if sel_item is None: + return + tpl_name = str (sel_item.data (0).toString ()) # get the template content from the database tpl_str = biaweb_db.get_template_text (self.current_db, tpl_name)