def load_catalogue(self): """ Open a file dialog, load a catalogue from a csv file, setup the maps and the charts """ csv_file = QtGui.QFileDialog.getOpenFileName( self, 'Open Catalogue', '') if not csv_file: return self.change_model(CatalogueModel.from_csv_file(csv_file))
def main(argv): # load plugins if os.path.exists(PLUGIN_FILE): imp.load_source('hmtk.plugin', PLUGIN_FILE) # create Qt application # Claim to be QGIS2 so that used plugins that tries to access # QSettings will get the QGIS2 settings QtGui.QApplication.setApplicationName('QGIS2') QtGui.QApplication.setOrganizationDomain('qgis.org') if QtCore.QSettings().value('locale/userLocale') is None: QtGui.QApplication.setOrganizationDomain('QGIS') app = QtGui.QApplication(argv, True) # setup QGIS QgsApplication.setPrefixPath(os.environ['QGIS_PREFIX_PATH'], True) QgsApplication.initQgis() # Install a custom exception hook that prints exception into a # MessageBox sys.excepthook = excepthook # create main window wnd = MainWindow() # classname wnd.show() if sys.platform == "darwin": wnd.raise_() if len(argv) > 1: wnd.change_model(CatalogueModel.from_csv_file(argv[1])) if len(argv) > 2: wnd.load_fault_source(argv[2]) else: wnd.load_catalogue() # Connect signal for app finish def on_quit(): QgsApplication.exitQgis() app.quit() app.lastWindowClosed.connect(on_quit) # Start the app up ret = app.exec_() sys.exit(ret)