def rt3d_obs_shapefile(self): write_rt3d.rt3d_obs_shapefile(self) write_rt3d.create_rt3d_obs(self) msgBox = QMessageBox() msgBox.setWindowIcon(QtGui.QIcon(':/QSWATMOD2/pics/am_icon.png')) msgBox.setIconPixmap(QtGui.QPixmap(':/QSWATMOD2/pics/modflow_obs.png')) msgBox.setMaximumSize(1000, 200) # resize not working msgBox.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) # resize not working msgBox.setWindowTitle("Hello?") msgBox.exec_()
def __init__(self, parent=None): """Constructor for the minimum needs dialog. :param parent: Parent widget of this dialog. :type parent: QWidget """ QtWidgets.QDialog.__init__(self, parent) self.setupUi(self) self.setWindowTitle(self.tr( 'InaSAFE %s Minimum Needs Calculator' % get_version())) icon = resources_path('img', 'icons', 'show-minimum-needs.svg') self.setWindowIcon(QtGui.QIcon(icon)) self.result_layer = None self.button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False) # get qgis map layer combobox object self.layer.setFilters(QgsMapLayerProxyModel.VectorLayer) # get field that represent displaced count(population) self.displaced.setFilters(QgsFieldProxyModel.Numeric) # get field that represent aggregation name self.aggregation_name.setFilters(QgsFieldProxyModel.String) # set field to the current selected layer self.displaced.setLayer(self.layer.currentLayer()) self.aggregation_name.setLayer(self.layer.currentLayer()) self.aggregation_id.setLayer(self.layer.currentLayer()) # link map layer and field combobox self.layer.layerChanged.connect(self.displaced.setLayer) self.layer.layerChanged.connect(self.aggregation_name.setLayer) self.layer.layerChanged.connect(self.aggregation_id.setLayer) # enable/disable ok button self.update_button_status() self.displaced.fieldChanged.connect(self.update_button_status) # Set up things for context help self.help_button = self.button_box.button( QtWidgets.QDialogButtonBox.Help) # Allow toggling the help button self.help_button.setCheckable(True) self.help_button.toggled.connect(self.help_toggled) self.main_stacked_widget.setCurrentIndex(1) # Fix for issue 1699 - cancel button does nothing cancel_button = self.button_box.button( QtWidgets.QDialogButtonBox.Cancel) cancel_button.clicked.connect(self.reject) # Fix ends ok_button = self.button_box.button(QtWidgets.QDialogButtonBox.Ok) ok_button.clicked.connect(self.accept)
def __init__(self, iface, toolBar): super().__init__(iface, toolBar, QtGui.QIcon(":/exchangeGeometry.png"), QtCore.QCoreApplication.translate( "digitizingtools", "Exchange attributes between selected features"), geometryTypes=[1, 2, 3, 4, 5, 6], dtName="dtExchangeGeometry") self.enable()
def __init__(self, parent=None): """Constructor.""" super(RasterInstrukcjaDialog, self).__init__(parent) self.setupUi(self) self.setWindowTitle('%s (krok 1 z 6)' % title_app) self.setWindowIcon(QtGui.QIcon(icon_path)) self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint) ButtonsDialog.__init__(self)
def __init__(self, parent=None): """Constructor.""" super(ZbiorPrzygotowanieDialog, self).__init__(parent) self.setupUi(self) self.setWindowTitle('Tworzenie zbioru APP') self.setWindowIcon(QtGui.QIcon(icon_path)) self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint) ButtonsDialog.__init__(self)
def __init__(self, parent=None): """Constructor.""" super(PytanieAppDialog, self).__init__(parent) self.setupUi(self) self.setWindowTitle(title_question) self.setWindowIcon(QtGui.QIcon(':/plugins/wtyczka_app/img/logo.png')) self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint) ButtonsDialog.__init__(self)
def initGui(self): # Create action that will start plugin configuration self.action = QtWidgets.QAction( QtGui.QIcon(':/plugins/bulkvectorexportwithstyle/icon.png'), u"Bulk export vector layers", self.iface.mainWindow()) # connect the action to the run method self.action.triggered.connect(self.run) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu(u"&Bulk vector export", self.action)
def __init__(self, parent=None): """Constructor.""" super(PomocDialog, self).__init__(parent) self.setupUi(self) self.setWindowTitle(title_help) self.setWindowIcon(QtGui.QIcon(icon_help)) self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint) self.version_lbl.setText(PLUGIN_VERSION) self.cancel_btn.clicked.connect(self.reject)
def _add_loadable_button(self, geonode_service: models.GeonodeService): url = self.brief_dataset.service_urls.get(geonode_service) if url is not None: icon = QtGui.QIcon( f":/plugins/qgis_geonode/icon_{geonode_service.value}.svg") button = QtWidgets.QPushButton() button.setObjectName(f"{geonode_service.value.lower()}_btn") button.setIcon(icon) button.setToolTip(tr(f"Load layer via {geonode_service.value}")) button.clicked.connect(partial(self.load_dataset, geonode_service)) order = 1 if geonode_service == models.GeonodeService.OGC_WMS else 2 self.action_buttons_layout.insertWidget(order, button)
def __init__(self, parent=None): """Constructor.""" super(WektorInstrukcjaDialog, self).__init__(parent) self.setupUi(self) self.setWindowTitle('%s (krok 3 z 6)' % title_app) self.setWindowIcon(QtGui.QIcon(icon_path)) self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint) self.layers_comboBox.setAllowEmptyLayer(True) ButtonsDialog.__init__(self)
def __init__(self, iface, toolBar): super().__init__(iface, toolBar, QtGui.QIcon(":/ExtractPart.png"), QtCore.QCoreApplication.translate( "digitizingtools", "Split off one part and add it as a new feature"), geometryTypes=[1, 2, 3, 4, 5, 6], dtName="dtExtractPart") self.tool = DtSelectPartTool(self.iface) self.tool.partSelected.connect(self.partSelected) self.enable()
def initGui(self): """init actions plugin""" self.toolbar = self.iface.addToolBar(PLUGIN["name"]) self.action = PQtW.QAction(PQtG.QIcon(PLUGIN["icon"]), PLUGIN["name"], self.iface.mainWindow()) self.action.triggered.connect(self.run) self.toolbar.addAction(self.action) self.iface.addPluginToMenu(PLUGIN["menulocation"], self.action) self.configAction = PQtW.QAction(PQtG.QIcon(PLUGIN["settingsicon"]), PLUGIN["settingsname"], self.iface.mainWindow()) self.configAction.triggered.connect(self.run_config) self.iface.addPluginToMenu(PLUGIN["menusettingslocation"], self.configAction) # add label to toolbar label = PQtW.QLabel() self.toolbar.addWidget(label) label.setText(PLUGIN["toolbartext"]) # init dropdown to switch floors self.projCombo = PQtW.QComboBox(self.iface.mainWindow()) bouwlagen = PAND["bouwlagen"] minBouwlaag = bouwlagen["min"] maxBouwlaag = bouwlagen["max"] for i in range(maxBouwlaag - minBouwlaag + 1): if maxBouwlaag - i != 0: if maxBouwlaag - i == 1: init_index = i self.projCombo.addItem(str(maxBouwlaag - i)) self.projComboAction = self.toolbar.addWidget(self.projCombo) self.projCombo.setFixedWidth(100) self.projCombo.setMaxVisibleItems(30) # set intial index to floor 1 self.projCombo.setCurrentIndex(init_index) # connect to set layer subset if the index is changed self.projCombo.currentIndexChanged.connect( self.set_layer_subset_toolbar) # init projectVariable to communicate from plugin to qgis QC.QgsExpressionContextUtils.setProjectVariable( QC.QgsProject.instance(), 'actieve_bouwlaag', 1)
def DB_resetTodefaultVal(self): msgBox = QMessageBox() msgBox.setWindowIcon(QtGui.QIcon(':/APEXMOD/pics/am_icon.png')) response = msgBox.question( self, 'Set to default?', "Are you sure you want to reset the current aquifer property settings to the default values?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if response == QMessageBox.Yes: db = db_functions.db_variable(self) query = QtSql.QSqlQuery(db) query.exec_("SELECT default_val FROM mf_inputs WHERE parNames = 'ss' ") LK = str(query.first()) self.lineEdit_ss_single.setText(str(query.value(0))) self.DB_push_mf_userVal()
def __init__(self, iface, parent=None): super(KMeansClusterDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() self.layers_df = None self.pixel_size = ['0', '', ''] # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- self.messageBar = QgsMessageBar( self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout( self) # new layout to gui if isinstance(self.layout(), QtWidgets.QFormLayout): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget( 0, self.messageBar) # for use with Vertical/horizontal layout box # GUI Runtime Customisation ----------------------------------------------- self.mcboRasterLayer.setFilters(QgsMapLayerProxyModel.RasterLayer) self.mcboRasterLayer.setExcludedProviders(['wms']) # self.setMapLayers() self.setWindowIcon( QtGui.QIcon(':/plugins/pat/icons/icon_kMeansCluster.svg')) self.tabList.setColumnCount(2) self.tabList.setHorizontalHeaderItem(0, QTableWidgetItem("ID")) self.tabList.setHorizontalHeaderItem(1, QTableWidgetItem("0 Raster(s)")) self.tabList.horizontalHeader().setSectionResizeMode( QtWidgets.QHeaderView.Stretch) self.tabList.hideColumn(0) # don't need to display the unique layer ID
def __init__(self, iface, toolBar): super().__init__(iface, toolBar, QtGui.QIcon(":/splitfeature.png"), QtCore.QCoreApplication.translate( "digitizingtools", "Split Features"), geometryTypes=[2, 3, 5, 6], crsWarning=False, dtName="dtSplitFeature") self.tool = DtSplitFeatureTool(self.iface) self.tool.finishedDigitizing.connect(self.digitizingFinished) self.reset() self.enable()
def __init__(self, iface, parent=None): super(CalculateImageIndicesDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- self.messageBar = QgsMessageBar(self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout(self) # new layout to gui if isinstance(self.layout(), (QtWidgets.QFormLayout, QtWidgets.QGridLayout)): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget(0, self.messageBar) # for use with Vertical/horizontal layout box self.band_mapping = BandMapping() # GUI Runtime Customisation ----------------------------------------------- self.mcboPolygonLayer.setFilters(QgsMapLayerProxyModel.PolygonLayer) self.mcboPolygonLayer.setExcludedProviders(['wms']) self.mcboPolygonLayer.setLayer(None) self.mcboRasterLayer.setFilters(QgsMapLayerProxyModel.RasterLayer) self.mcboRasterLayer.setExcludedProviders(['wms']) rastlyrs_df = build_layer_table([self.mcboRasterLayer.layer(i) for i in range(self.mcboRasterLayer.count())]) if self.mcboRasterLayer.count() > 0: exc_lyrs = rastlyrs_df[rastlyrs_df['bandcount']<=1] self.mcboRasterLayer.setExceptedLayerList(exc_lyrs['layer'].tolist()) self.updateRaster() # self.chkAddToDisplay.setChecked(False) # self.chkAddToDisplay.hide() self.chkgrpIndices.setExclusive(False) # allow for multi selection self.setWindowIcon(QtGui.QIcon(':/plugins/pat/icons/icon_calcImgIndices.svg'))
def __init__(self, iface, toolBar): super().__init__( iface, toolBar, QtGui.QIcon(":/fillGapAll.png"), QtCore.QCoreApplication.translate( "digitizingtools", "Fill gap between polygons of all visible layers with a new feature" ), geometryTypes=[3, 6], dtName="dtFillGapAll") self.tool = DtSelectGapTool(self.iface, True) self.tool.gapSelected.connect(self.gapFound) self.enable()
def initGui(self): self.action = QtWidgets.QAction( QtGui.QIcon( ':/plugins/SpreadsheetLayers/icon/mActionAddSpreadsheetLayer.svg' ), self.tr("Add spreadsheet layer"), self) self.action.triggered.connect(self.showDialog) if Qgis.QGIS_VERSION_INT > 20400: self.iface.addLayerMenu().addAction(self.action) else: menu = self.iface.layerMenu() for action in menu.actions(): if action.isSeparator(): break self.iface.layerMenu().insertAction(action, self.action) self.iface.layerToolBar().addAction(self.action)
def __init__(self, parent=None): """Constructor.""" super(UstawieniaDialog, self).__init__(parent) self.setupUi(self) self.setWindowTitle(title_settings) self.setWindowIcon(QtGui.QIcon(icon_settings)) self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint) self.exit_btn.clicked.connect(self.reject) self.contactMail_lineEdit.setValidator( QRegExpValidator(QRegExp(r"[0-9a-zA-Z.\-\_\@\+]*"))) self.adminMail_lineEdit.setValidator( QRegExpValidator(QRegExp(r"[0-9a-zA-Z.\-\_\@\+]*")))
def loadWidget(self): name = self.objectName() arb = name.split('_') self.qtreewidgetitem = QTreeWidgetItem() self.qtreewidgetitem.setText(0,arb[-1]) if self.iconpath != None: self.qtreewidgetitem.setIcon(0,QtGui.QIcon(self.iconpath)) self.propertiesdialog.treeWidget_utils.addTopLevelItems([self.qtreewidgetitem]) self.propertiesdialog.stackedWidget.addWidget(self) self.widgetindex = self.propertiesdialog.stackedWidget.indexOf(self) #connect signals self.propertiesdialog.treeWidget_utils.itemClicked.connect(self.onClickRaw) self.propertiesdialog.tabWidget.currentChanged.connect(self.onClickRaw)
def select_apex_model(self): settings = QSettings() if settings.contains('/APEXMOD/LastInputPath'): path = str(settings.value('/APEXMOD/LastInputPath')) else: path = '' title = "Select APEX model folder (TxtInOut)!" options = QFileDialog.DontResolveSymlinks | QFileDialog.ShowDirsOnly directory = QFileDialog.getExistingDirectory(None, title, path, options) if directory: proj = QgsProject.instance() Project_Name = QFileInfo(proj.fileName()).baseName() Out_folder_temp = QgsProject.instance().readPath("./") Out_folder = os.path.normpath(Out_folder_temp + "/" + Project_Name + "/" + "APEX-MODFLOW") time = datetime.now().strftime('[%m/%d/%y %H:%M:%S]') self.dlg.textEdit_sm_link_log.append(time+' -> ' + "Copying orginal APEX inputs ... processing") self.dlg.progressBar_step.setValue(0) QCoreApplication.processEvents() count = 0 filelist = os.listdir(directory) for i in filelist: shutil.copy2(os.path.join(directory, i), Out_folder) count += 1 provalue = round(count/len(filelist)*100) self.dlg.label_StepStatus.setText(i) self.dlg.progressBar_step.setValue(provalue) QCoreApplication.processEvents() file_check = os.path.abspath(os.path.join(Out_folder, "APEXCONT.DAT")) if os.path.isfile(file_check) is True: msgBox = QMessageBox() msgBox.setWindowTitle("Copied!") msgBox.setWindowIcon(QtGui.QIcon(':/APEXMOD/pics/am_icon.png')) msgBox.setText("The APEX model has been successfully copied") msgBox.exec_() self.define_sim_period() self.dlg.lineEdit_TxtInOut.setText(Out_folder) time = datetime.now().strftime('[%m/%d/%y %H:%M:%S]') self.dlg.textEdit_sm_link_log.append(time+' -> ' + "Copying orginal APEX inputs ... passed") self.dlg.label_StepStatus.setText('Step Status: ') self.dlg.progressBar_step.setValue(0) QCoreApplication.processEvents() else: msgBox = QMessageBox() msgBox.setText("There was a problem copying the APEX model") msgBox.exec_()
def select_mf_model(self): settings = QSettings() if settings.contains('/APEXMOD/LastInputPath'): path = str(settings.value('/APEXMOD/LastInputPath')) else: path = '' title = "Select MODFLOW model folder!" options = QFileDialog.DontResolveSymlinks | QFileDialog.ShowDirsOnly directory = QFileDialog.getExistingDirectory(None, title, path, options) if directory: APEXMOD_path_dict = self.dirs_and_paths() proj = QgsProject.instance() Project_Name = QFileInfo(proj.fileName()).baseName() Out_folder = APEXMOD_path_dict['MODFLOW'] #distutils.dir_util.remove_tree(Out_folder) distutils.dir_util.copy_tree(directory, Out_folder) time = datetime.now().strftime('[%m/%d/%y %H:%M:%S]') self.dlg.textEdit_sm_link_log.append(time+' -> ' + "Copying orginal MODFLOW inputs ... processing") self.dlg.progressBar_step.setValue(0) QCoreApplication.processEvents() count = 0 filelist = os.listdir(directory) for i in filelist: shutil.copy2(os.path.join(directory, i), Out_folder) count += 1 provalue = round(count/len(filelist)*100) self.dlg.label_StepStatus.setText(i) self.dlg.progressBar_step.setValue(provalue) QCoreApplication.processEvents() file_check = ".dis" if any(file.endswith(file_check) for file in os.listdir(Out_folder)): msgBox = QMessageBox() msgBox.setWindowTitle("Copied!") msgBox.setWindowIcon(QtGui.QIcon(':/APEXMOD/pics/am_icon.png')) msgBox.setText("The MODFlOW model has been successfully copied!") msgBox.exec_() self.dlg.lineEdit_MODFLOW.setText(Out_folder) self.mf_model() time = datetime.now().strftime('[%m/%d/%y %H:%M:%S]') self.dlg.textEdit_sm_link_log.append(time+' -> ' + "Copying orginal MODFLOW inputs ... passed") self.dlg.label_StepStatus.setText('Step Status: ') self.dlg.progressBar_step.setValue(0) QCoreApplication.processEvents() else: msgBox = QMessageBox() msgBox.setText("There was a problem copying the folder") msgBox.exec_()
def __init__(self, iface, dock): """Constructor for the class.""" QDialog.__init__(self) # Class Member self.iface = iface self.dock = dock self.output_directory = None self.exposure_layer = None self.hazard_layer = None self.aggregation_layer = None self.keyword_io = KeywordIO() icon = resources_path('img', 'icons', 'save-as-scenario.svg') self.setWindowIcon(QtGui.QIcon(icon)) # Calling some init methods self.restore_state()
def export_rt_cno3_avg_m(self): mbig_df = get_rt_cno3_avg_m_df(self) selected_months = selected_rt_mon(self) self.layer = QgsProject.instance().mapLayersByName("rt_nitrate_avg_mon")[0] per = 0 self.dlg.progressBar_mf_results.setValue(0) for m in selected_months: m_vals = mbig_df.loc[m, :] QCoreApplication.processEvents() mon_nam = calendar.month_abbr[m] provider = self.layer.dataProvider() if self.layer.dataProvider().fields().indexFromName(mon_nam) == -1: field = QgsField(mon_nam, QVariant.Double, 'double', 20, 5) provider.addAttributes([field]) self.layer.updateFields() mf_hds_idx = provider.fields().indexFromName(mon_nam) tot_feats = self.layer.featureCount() count = 0 # Get features (Find out a way to change attribute values using another field) feats = self.layer.getFeatures() self.layer.startEditing() # add row number for f, mf_hd in zip(feats, m_vals): self.layer.changeAttributeValue(f.id(), mf_hds_idx, mf_hd) count += 1 provalue = round(count / tot_feats * 100) self.dlg.progressBar_rt.setValue(provalue) QCoreApplication.processEvents() self.layer.commitChanges() QCoreApplication.processEvents() # Update progress bar per += 1 progress = round((per / len(selected_months)) * 100) self.dlg.progressBar_rt_results.setValue(progress) QCoreApplication.processEvents() self.dlg.raise_() msgBox = QMessageBox() msgBox.setWindowIcon(QtGui.QIcon(':/QSWATMOD2/pics/sm_icon.png')) msgBox.setWindowTitle("Exported!") msgBox.setText("rt_nitrate_m results were exported successfully!") msgBox.exec_()
def __init__(self, iface, parent=None): super(ResampleImageToBlockDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- self.messageBar = QgsMessageBar(self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout(self) # new layout to gui if isinstance(self.layout(), (QtWidgets.QFormLayout, QtWidgets.QGridLayout)): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget(0, self.messageBar) # for use with Vertical/horizontal layout box # GUI Runtime Customisation ----------------------------------------------- self.mcboPolygonLayer.setFilters(QgsMapLayerProxyModel.PolygonLayer) self.mcboPolygonLayer.setExcludedProviders(['wms']) self.mcboPolygonLayer.setLayer(None) self.mcboRasterLayer.setFilters(QgsMapLayerProxyModel.RasterLayer) self.mcboRasterLayer.setExcludedProviders(['wms']) self.updateRaster() #https://stackoverflow.com/questions/13422995/set-qlineedit-to-accept-only-numbers #https://stackoverflow.com/questions/12643009/regular-expression-for-floating-point-numbers regex_validator = QtGui.QRegExpValidator(QtCore.QRegExp("[-+]?([0-9]*[.])?[0-9]+([eE][-+]?\d+)?")) self.lneNoDataVal.setValidator(regex_validator) self.setWindowIcon(QtGui.QIcon(':/plugins/pat/icons/icon_resampleToBlock.svg'))
def __init__(self, iface, parent=None): super(StripTrialPointsDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- self.messageBar = QgsMessageBar( self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout( self) # new layout to gui if isinstance(self.layout(), (QtWidgets.QFormLayout, QtWidgets.QGridLayout)): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget( 0, self.messageBar) # for use with Vertical/horizontal layout box # GUI Runtime Customisation ----------------------------------------------- self.mcboLineLayer.setFilters(QgsMapLayerProxyModel.LineLayer) self.mcboLineLayer.setExcludedProviders(['wms']) if self.mcboLineLayer.count() > 0: self.mcboLineLayer.setCurrentIndex(0) self.setWindowIcon( QtGui.QIcon(':/plugins/pat/icons/icon_stripTrialPoints.svg')) self.chkUseSelected.setChecked(False) self.chkUseSelected.hide()
def addAboutMenu(menuName, parentMenuFunction=None): ''' Adds an 'about...' menu to the plugin menu. This method should be called from the initGui() method of the plugin :param menuName: The name of the plugin menu in which the about menu is to be added ''' parentMenuFunction = parentMenuFunction or iface.addPluginToMenu namespace = _callerName().split(".")[0] icon = QtGui.QIcon( os.path.join(os.path.dirname(os.path.dirname(__file__)), "icons", "help.png")) aboutAction = QtWidgets.QAction(icon, "About...", iface.mainWindow()) aboutAction.setObjectName(namespace + "about") aboutAction.triggered.connect(lambda: openAboutDialog(namespace)) parentMenuFunction(menuName, aboutAction) global _aboutActions _aboutActions[menuName] = aboutAction
def __init__(self, parent=None, message=None): """Constructor for the dialog. :param message: An optional message object to display in the dialog. :type message: Message.Message :param parent: Parent widget of this dialog :type parent: QWidget """ QtWidgets.QDialog.__init__( self, parent, flags=Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint) self.setupUi(self) self.parent = parent icon = resources_path('img', 'icons', 'show-inasafe-help.svg') self.setWindowIcon(QtGui.QIcon(icon)) self.help_web_view.setHtml(get_help_html(message))
def _initialize_ui(self): self.title_la.setText(f"<h3>{self.brief_dataset.title}</h3>") self.resource_type_la.setText( self.brief_dataset.dataset_sub_type.value) self.description_la.setText(self.brief_dataset.abstract) if self.brief_dataset.detail_url: self.browser_btn.setIcon( QtGui.QIcon(":/plugins/qgis_geonode/mIconGeonode.svg")) self.browser_btn.clicked.connect(self.open_resource_page) else: self.browser_btn.setEnabled(False) if (self.brief_dataset.dataset_sub_type == models.GeonodeResourceType.VECTOR_LAYER): self._initialize_ui_for_vector_dataset() elif (self.brief_dataset.dataset_sub_type == models.GeonodeResourceType.RASTER_LAYER): self._initialize_ui_for_raster_dataset() else: pass
def create_MF_shps(self): self.progressBar_mf.setValue(0) self.create_MF_grid() self.progressBar_mf.setValue(30) QCoreApplication.processEvents( ) # it works as F5 !! Be careful to use this for long geoprocessing # Create grid_id self.create_grid_id_ii() self.progressBar_mf.setValue(40) QCoreApplication.processEvents() # Extract elevation self.getElevfromDem() self.progressBar_mf.setValue(50) QCoreApplication.processEvents() # Extract elevation self.create_row_col_elev_mf_ii() self.progressBar_mf.setValue(60) QCoreApplication.processEvents() # Get active cells self.create_mf_act_grid() self.progressBar_mf.setValue(70) QCoreApplication.processEvents() self.mf_act_grid_delete_NULL() QCoreApplication.processEvents() self.cvtElevToR() QCoreApplication.processEvents() time = datetime.now().strftime('[%m/%d/%y %H:%M:%S]') self.textEdit_mf_log.append(time + ' -> ' + 'Done!') self.progressBar_mf.setValue(100) QCoreApplication.processEvents() msgBox = QMessageBox() msgBox.setWindowIcon(QtGui.QIcon(':/QSWATMOD2/pics/sm_icon.png')) msgBox.setWindowTitle("Created!") msgBox.setText("MODFLOW grids and rasters were created!") msgBox.exec_()