本文整理汇总了Python中qgis.PyQt.QtWidgets.QApplication类的典型用法代码示例。如果您正苦于以下问题:Python QApplication类的具体用法?Python QApplication怎么用?Python QApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QApplication类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: constraintsDetails
def constraintsDetails(self):
if not self.table.constraints():
return None
tbl = []
# define the table header
header = (QApplication.translate("DBManagerPlugin", "Name"),
QApplication.translate("DBManagerPlugin", "Type"),
QApplication.translate("DBManagerPlugin", "Column"),
QApplication.translate("DBManagerPlugin", "Status"),
QApplication.translate("DBManagerPlugin", "Validated"),
QApplication.translate("DBManagerPlugin", "Generated"),
QApplication.translate("DBManagerPlugin", "Check condition"),
QApplication.translate("DBManagerPlugin", "Foreign Table"),
QApplication.translate("DBManagerPlugin", "Foreign column"),
QApplication.translate("DBManagerPlugin", "On Delete"))
tbl.append(HtmlTableHeader(header))
# add table contents
for con in self.table.constraints():
tbl.append((con.name, con.type2String(), con.column,
con.status, con.validated, con.generated,
con.checkSource, con.foreignTable,
con.foreignKey, con.foreignOnDelete))
return HtmlTable(tbl, {"class": "header"})
开发者ID:AM7000000,项目名称:QGIS,代码行数:27,代码来源:info_model.py
示例2: main
def main():
"""Main function to run the example."""
app = QApplication([])
default_value_parameter = DefaultValueParameter()
default_value_parameter.name = 'Value parameter'
default_value_parameter.help_text = 'Help text'
default_value_parameter.description = 'Description'
default_value_parameter.labels = [
'Setting', 'Do not report', 'Custom']
default_value_parameter.options = [0, 1, None]
parameters = [
default_value_parameter
]
extra_parameters = [
(DefaultValueParameter, DefaultValueParameterWidget)
]
parameter_container = ParameterContainer(
parameters, extra_parameters=extra_parameters)
parameter_container.setup_ui()
widget = QWidget()
layout = QGridLayout()
layout.addWidget(parameter_container)
widget.setLayout(layout)
widget.setGeometry(0, 0, 500, 500)
widget.show()
sys.exit(app.exec_())
开发者ID:inasafe,项目名称:inasafe,代码行数:34,代码来源:example.py
示例3: zip_db
def zip_db(self):
force_another_db = False
dbpath=None
if self.db:
use_current_db = utils.Askuser("YesNo",'Vill du göra backup av %s?'%self.db,'Which database?')
if use_current_db.result == 1:
dbpath = self.db
force_another_db = False
elif use_current_db.result == 0:
force_another_db = True
elif use_current_db.result == '':
return
if not self.db or force_another_db:
dbpath = QFileDialog.getOpenFileName(None, 'Ange db som du vill skapa backup utav','',"Spatialite (*.sqlite)")[0]
if dbpath:
QApplication.setOverrideCursor(Qt.WaitCursor)
connection = utils.dbconnection(dbpath)
connection.connect2db()
connection.conn.cursor().execute("begin immediate")
file_path = os.path.realpath(dbpath)
dir_path = os.path.dirname(file_path)
current_dir = dir_path.split(os.sep)[-1]
bkupname = dbpath + datetime.datetime.now().strftime('%Y%m%dT%H%M') + '.zip'
zf = zipfile.ZipFile(bkupname, mode='w')
zf.write(dbpath,os.path.basename(dbpath), compress_type=compression) #compression will depend on if zlib is found or not
zf.close()
connection.conn.rollback()
connection.closedb()
self.iface.messageBar().pushMessage("Information","Database backup was written to " + bkupname, 1,duration=15)
QApplication.restoreOverrideCursor()
开发者ID:jkall,项目名称:qgis_midv_tolkn_plugin,代码行数:33,代码来源:midv_tolkn.py
示例4: finish
def finish(self, result, context, feedback):
keepOpen = ProcessingConfig.getSetting(ProcessingConfig.KEEP_DIALOG_OPEN)
if self.iterateParam is None:
# add html results to results dock
for out in self.alg.outputDefinitions():
if isinstance(out, QgsProcessingOutputHtml) and out.name() in result and result[out.name()]:
resultsList.addResult(icon=self.alg.icon(), name=out.description(),
result=result[out.name()])
if not handleAlgorithmResults(self.alg, context, feedback, not keepOpen):
self.resetGUI()
return
self.executed = True
self.setInfo(self.tr('Algorithm \'{0}\' finished').format(self.alg.displayName()), escape_html=False)
QApplication.restoreOverrideCursor()
if not keepOpen:
self.close()
else:
self.resetGUI()
if self.alg.hasHtmlOutputs():
self.setInfo(
self.tr('HTML output has been generated by this algorithm.'
'\nOpen the results dialog to check it.'), escape_html=False)
开发者ID:ndavid,项目名称:QGIS,代码行数:27,代码来源:AlgorithmDialog.py
示例5: spatialInfo
def spatialInfo(self):
ret = []
info = self.db.connector.getSpatialInfo()
if not info:
return
tbl = [
(QApplication.translate("DBManagerPlugin", "Oracle\
Spatial:"),
info[0])
]
ret.append(HtmlTable(tbl))
if not self.db.connector.has_geometry_columns:
ret.append(
HtmlParagraph(
QApplication.translate(
"DBManagerPlugin",
(u"<warning> ALL_SDO_GEOM_METADATA"
u" view doesn't exist!\n"
u"This view is essential for many"
u"GIS applications for enumeration of tables."))))
return ret
开发者ID:AM7000000,项目名称:QGIS,代码行数:25,代码来源:info_model.py
示例6: connectionDetails
def connectionDetails(self):
tbl = [
(QApplication.translate("DBManagerPlugin", "Host:"), self.db.connector.host),
(QApplication.translate("DBManagerPlugin", "User:"), self.db.connector.user),
(QApplication.translate("DBManagerPlugin", "Database:"), self.db.connector.dbname)
]
return HtmlTable(tbl)
开发者ID:DelazJ,项目名称:QGIS,代码行数:7,代码来源:info_model.py
示例7: getSpatialInfo
def getSpatialInfo(self):
ret = []
info = self.db.connector.getSpatialInfo()
if info is None:
return
tbl = [
(QApplication.translate("DBManagerPlugin", "Library:"), info[0]),
(QApplication.translate("DBManagerPlugin", "Scripts:"), info[3]),
("GEOS:", info[1]),
("Proj:", info[2])
]
ret.append(HtmlTable(tbl))
if info[1] is not None and info[1] != info[2]:
ret.append(HtmlParagraph(QApplication.translate("DBManagerPlugin",
"<warning> Version of installed scripts doesn't match version of released scripts!\n"
"This is probably a result of incorrect PostGIS upgrade.")))
if not self.db.connector.has_geometry_columns:
ret.append(HtmlParagraph(
QApplication.translate("DBManagerPlugin", "<warning> geometry_columns table doesn't exist!\n"
"This table is essential for many GIS applications for enumeration of tables.")))
elif not self.db.connector.has_geometry_columns_access:
ret.append(HtmlParagraph(QApplication.translate("DBManagerPlugin",
"<warning> This user doesn't have privileges to read contents of geometry_columns table!\n"
"This table is essential for many GIS applications for enumeration of tables.")))
return ret
开发者ID:DelazJ,项目名称:QGIS,代码行数:30,代码来源:info_model.py
示例8: _opendb
def _opendb(self):
self.gdal_ds = None
if hasattr(gdal, 'OpenEx'):
# GDAL >= 2
self.gdal_ds = gdal.OpenEx(self.dbname, gdal.OF_UPDATE)
if self.gdal_ds is None:
self.gdal_ds = gdal.OpenEx(self.dbname)
if self.gdal_ds is None or self.gdal_ds.GetDriver().ShortName != 'GPKG':
raise ConnectionError(QApplication.translate("DBManagerPlugin", '"{0}" not found').format(self.dbname))
self.has_raster = self.gdal_ds.RasterCount != 0 or self.gdal_ds.GetMetadata('SUBDATASETS') is not None
self.connection = None
self.gdal2 = True
else:
# GDAL 1.X compat. To be removed at some point
self.gdal_ds = ogr.Open(self.dbname, update=1)
if self.gdal_ds is None:
self.gdal_ds = ogr.Open(self.dbname)
if self.gdal_ds is None or self.gdal_ds.GetDriver().GetName() != 'GPKG':
raise ConnectionError(QApplication.translate("DBManagerPlugin", '"{0}" not found').format(self.dbname))
# For GDAL 1.X, we cannot issue direct SQL SELECT to the OGR datasource
# so we need a direct sqlite connection
try:
self.connection = spatialite_connect(str(self.dbname))
except self.connection_error_types() as e:
raise ConnectionError(e)
self.gdal2 = False
开发者ID:GrokImageCompression,项目名称:QGIS,代码行数:27,代码来源:connector.py
示例9: initGui
def initGui(self):
self.action = QAction(
QIcon(":/db_manager/icon"), QApplication.translate("DBManagerPlugin", "DB Manager"), self.iface.mainWindow()
)
self.action.setObjectName("dbManager")
self.action.triggered.connect(self.run)
# Add toolbar button and menu item
if hasattr(self.iface, "addDatabaseToolBarIcon"):
self.iface.addDatabaseToolBarIcon(self.action)
else:
self.iface.addToolBarIcon(self.action)
if hasattr(self.iface, "addPluginToDatabaseMenu"):
self.iface.addPluginToDatabaseMenu(QApplication.translate("DBManagerPlugin", "DB Manager"), self.action)
else:
self.iface.addPluginToMenu(QApplication.translate("DBManagerPlugin", "DB Manager"), self.action)
self.layerAction = QAction(
QIcon(":/db_manager/icon"),
QApplication.translate("DBManagerPlugin", "Update Sql Layer"),
self.iface.mainWindow(),
)
self.layerAction.setObjectName("dbManagerUpdateSqlLayer")
self.layerAction.triggered.connect(self.onUpdateSqlLayer)
self.iface.legendInterface().addLegendLayerAction(
self.layerAction, "", "dbManagerUpdateSqlLayer", QgsMapLayer.VectorLayer, False
)
for l in QgsMapLayerRegistry.instance().mapLayers().values():
self.onLayerWasAdded(l)
QgsMapLayerRegistry.instance().layerWasAdded.connect(self.onLayerWasAdded)
开发者ID:CS-SI,项目名称:QGIS,代码行数:29,代码来源:db_manager_plugin.py
示例10: runAction
def runAction(self, action):
action = unicode(action)
if action.startswith("vacuumanalyze/"):
if action == "vacuumanalyze/run":
self.runVacuumAnalyze()
return True
elif action.startswith("rule/"):
parts = action.split('/')
rule_name = parts[1]
rule_action = parts[2]
msg = u"Do you want to %s rule %s?" % (rule_action, rule_name)
QApplication.restoreOverrideCursor()
try:
if QMessageBox.question(None, self.tr("Table rule"), msg,
QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
return False
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
if rule_action == "delete":
self.aboutToChange.emit()
self.database().connector.deleteTableRule(rule_name, (self.schemaName(), self.name))
self.refreshRules()
return True
return Table.runAction(self, action)
开发者ID:PeterTFS,项目名称:QGIS,代码行数:31,代码来源:plugin.py
示例11: addToLayout
def addToLayout(self):
mgr = QgsProject.instance().layoutManager()
layout = None
layouts = mgr.layouts()
if len(layouts) == 0:
QMessageBox.warning(self,
QApplication.translate("code", "Keine Layouts"),
QApplication.translate("code", "Zuerst ein Layout erstellen"))
return
elif len(layouts) == 1:
layout = layouts[0]
else:
d = VoGISProfilToolLayoutsDialog(self, layouts)
result = d.exec_()
if result == QDialog.Accepted:
layout = mgr.layoutByName(d.ui.cmbLayouts.currentText())
else:
return
u = Util(self.iface)
caption = QApplication.translate("code", "PNG Datei")
file_format = []
file_format.append(["PNG files", "png"])
fileName, fileExt = u.getFileName(caption, file_format, QgsProject.instance().homePath())
if fileName == "":
return
fInfo = QFileInfo(fileName)
self.filePath = fInfo.path()
figure = self.subplot.figure
figure.savefig(fileName, format="png")
image = QgsLayoutItemPicture(layout)
image.setPicturePath(fileName)
image.attemptResize(QgsLayoutSize(200, 200))
layout.addLayoutItem(image)
开发者ID:BergWerkGIS,项目名称:VoGIS-Profil-Tool,代码行数:35,代码来源:vogisprofiltoolplot.py
示例12: exportTxt
def exportTxt(self):
delimiter = self.__getDelimiter()
decimalDelimiter = self.__getDecimalDelimiter()
if delimiter == decimalDelimiter:
msg = QApplication.translate("code", "Gleiches Dezimal- und Spaltentrennzeichen gewählt!")
QMessageBox.warning(self.iface.mainWindow(), "VoGIS-Profiltool", msg)
return
u = Util(self.iface)
caption = QApplication.translate("code", "Textdatei exportieren")
fileName, file_ext = u.getFileName(caption, [["txt", "txt"]], self.filePath)
if fileName == "":
return
fInfo = QFileInfo(fileName)
self.filePath = fInfo.path()
QgsSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
hekto = (self.ui.IDC_chkHekto.checkState() == Qt.Checked)
attribs = (self.ui.IDC_chkLineAttributes.checkState() == Qt.Checked)
txt = open(fileName, "w")
txt.write(self.profiles[0].writeHeader(self.settings.mapData.rasters.selectedRasters(), hekto, attribs, delimiter))
for p in self.profiles:
#txt.write("=====Profil {0}======{1}".format(p.id, os.linesep))
#txt.write("Segments:{0}{1}".format(len(p.segments), os.linesep))
#for s in p.segments:
# txt.write("Vertices:{0}{1}".format(len(s.vertices), os.linesep))
txt.write(p.toString(hekto,
attribs,
delimiter,
decimalDelimiter
))
txt.close()
开发者ID:BergWerkGIS,项目名称:VoGIS-Profil-Tool,代码行数:32,代码来源:vogisprofiltoolplot.py
示例13: createGeomColumn
def createGeomColumn(self):
""" first check whether everything's fine """
if self.editName.text() == "":
QMessageBox.critical(self, self.tr("DB Manager"), self.tr("field name must not be empty"))
return
name = self.editName.text()
geom_type = self.GEOM_TYPES[self.cboType.currentIndex()]
dim = self.spinDim.value()
try:
srid = int(self.editSrid.text())
except ValueError:
srid = -1
createSpatialIndex = False
# now create the geometry column
QApplication.setOverrideCursor(Qt.WaitCursor)
try:
self.table.addGeometryColumn(name, geom_type, srid, dim, createSpatialIndex)
except DbError as e:
DlgDbError.showError(e, self)
return
finally:
QApplication.restoreOverrideCursor()
self.accept()
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:26,代码来源:dlg_add_geometry_column.py
示例14: spatialInfo
def spatialInfo(self):
ret = []
if self.table.geomType is None:
return ret
tbl = [
(QApplication.translate("DBManagerPlugin", "Column:"), self.table.geomColumn),
(QApplication.translate("DBManagerPlugin", "Geometry:"), self.table.geomType)
]
# only if we have info from geometry_columns
srid = self.table.srid if self.table.srid is not None else -1
sr_info = self.table.database().connector.getSpatialRefInfo(srid) if srid != -1 else QApplication.translate(
"DBManagerPlugin", "Undefined")
if sr_info:
tbl.append((QApplication.translate("DBManagerPlugin", "Spatial ref:"), u"%s (%d)" % (sr_info, srid)))
# extent
if self.table.extent is not None and self.table.extent[0] is not None:
extent_str = '%.5f, %.5f - %.5f, %.5f' % self.table.extent
else:
extent_str = QApplication.translate("DBManagerPlugin",
'(unknown) (<a href="action:extent/get">find out</a>)')
tbl.append((QApplication.translate("DBManagerPlugin", "Extent:"), extent_str))
ret.append(HtmlTable(tbl))
return ret
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:27,代码来源:info_model.py
示例15: setData
def setData(self, index, value, role):
if role != Qt.EditRole or index.column() != 0:
return False
item = index.internalPointer()
new_value = unicode(value)
if isinstance(item, SchemaItem) or isinstance(item, TableItem):
obj = item.getItemData()
# rename schema or table or view
if new_value == obj.name:
return False
QApplication.setOverrideCursor(Qt.WaitCursor)
try:
obj.rename(new_value)
self._onDataChanged(index)
except BaseError as e:
DlgDbError.showError(e, self.treeView)
return False
finally:
QApplication.restoreOverrideCursor()
return True
return False
开发者ID:NyakudyaA,项目名称:QGIS,代码行数:27,代码来源:db_model.py
示例16: canvasReleaseEvent
def canvasReleaseEvent(self, e):
point = self.iface.mapCanvas().getCoordinateTransform().toMapCoordinates(e.x(), e.y())
point = self.plugin.transform(point)
p = "POINT(%.3lf %.3lf)" % (point.x(), point.y())
try:
QApplication.setOverrideCursor(Qt.WaitCursor)
fs = self.plugin.retrieve(u"st_contains(wkb_geometry,st_geomfromtext('{}'::text,{}))".format(
p, self.plugin.getepsg()
))
if not self.plugin.logQuery("eigentuemerInfo", p, [i['flsnr'] for i in fs]):
QMessageBox.information(None, u"Hinweis", u"Flurstücke werden ohne Protokollierung nicht angezeigt.")
return
if len(fs) == 0:
QMessageBox.information(None, u"Hinweis", u"Kein Flurstück gefunden.")
return
fs = self.plugin.highlight(fs=fs, zoomTo=False)
finally:
QApplication.restoreOverrideCursor()
page = self.getPage(fs)
if page is not None:
Info.showInfo(self.plugin, page, fs[0]['gmlid'], self.iface.mainWindow())
开发者ID:norBIT,项目名称:alkisplugin,代码行数:29,代码来源:qgisclasses.py
示例17: deleteConstraint
def deleteConstraint(self):
""" delete a constraint """
index = self.currentConstraint()
if index == -1:
return
m = self.viewConstraints.model()
constr = m.getObject(index)
res = QMessageBox.question(self, self.tr("Are you sure"),
self.tr("really delete constraint '%s'?") % constr.name,
QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
return
QApplication.setOverrideCursor(Qt.WaitCursor)
self.aboutToChangeTable.emit()
try:
constr.delete()
self.populateViews()
except BaseError as e:
DlgDbError.showError(e, self)
return
finally:
QApplication.restoreOverrideCursor()
开发者ID:AM7000000,项目名称:QGIS,代码行数:26,代码来源:dlg_table_properties.py
示例18: resetGUI
def resetGUI(self):
QApplication.restoreOverrideCursor()
self.lblProgress.setText('')
self.progressBar.setMaximum(100)
self.progressBar.setValue(0)
self.btnRun.setEnabled(True)
self.btnClose.setEnabled(True)
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:7,代码来源:AlgorithmDialogBase.py
示例19: treeLoaded
def treeLoaded(self, reply):
"""
update the tree of scripts/models whenever
HTTP request is finished
"""
QApplication.restoreOverrideCursor()
if reply.error() != QNetworkReply.NoError:
self.popupError(reply.error(), reply.request().url().toString())
else:
resources = unicode(reply.readAll()).splitlines()
resources = [r.split(',') for r in resources]
self.resources = {f: (v, n) for f, v, n in resources}
for filename, version, name in sorted(resources, key=lambda kv: kv[2].lower()):
treeBranch = self.getTreeBranchForState(filename, float(version))
item = TreeItem(filename, name, self.icon)
treeBranch.addChild(item)
if treeBranch != self.notinstalledItem:
item.setCheckState(0, Qt.Checked)
reply.deleteLater()
self.tree.addTopLevelItem(self.toupdateItem)
self.tree.addTopLevelItem(self.notinstalledItem)
self.tree.addTopLevelItem(self.uptodateItem)
self.txtHelp.setHtml(self.HELP_TEXT)
开发者ID:DHI-GRAS,项目名称:ESA_Processing,代码行数:25,代码来源:GetScriptsAndModels.py
示例20: editColumn
def editColumn(self):
""" open dialog to change column info and alter table appropriately """
index = self.currentColumn()
if index == -1:
return
m = self.viewFields.model()
# get column in table
# (there can be missing number if someone deleted a column)
fld = m.getObject(index)
dlg = DlgFieldProperties(self, fld, self.table)
if not dlg.exec_():
return
new_fld = dlg.getField(True)
QApplication.setOverrideCursor(Qt.WaitCursor)
self.aboutToChangeTable.emit()
try:
fld.update(new_fld.name, new_fld.type2String(), new_fld.notNull, new_fld.default2String())
self.populateViews()
except BaseError as e:
DlgDbError.showError(e, self)
return
finally:
QApplication.restoreOverrideCursor()
开发者ID:AM7000000,项目名称:QGIS,代码行数:26,代码来源:dlg_table_properties.py
注:本文中的qgis.PyQt.QtWidgets.QApplication类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论