本文整理汇总了Python中qgis.PyQt.QtWidgets.QApplication.translate方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.translate方法的具体用法?Python QApplication.translate怎么用?Python QApplication.translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtWidgets.QApplication
的用法示例。
在下文中一共展示了QApplication.translate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __signal_checkBoxEnableMap_stateChanged
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
def __signal_checkBoxEnableMap_stateChanged(self, state):
enable = False
if state == Qt.Unchecked:
self.__marker.reset()
else:
if self.__canvas.layerCount() == 0:
QMessageBox.warning(self, QApplication.translate(
"OpenLayersOverviewWidget",
"OpenLayers Overview"), QApplication.translate(
"OpenLayersOverviewWidget",
"At least one layer in map canvas required"))
self.checkBoxEnableMap.setCheckState(Qt.Unchecked)
else:
enable = True
if not self.__initLayerOL:
self.__initLayerOL = True
self.__setWebViewMap(0)
else:
self.__refreshMapOL()
# GUI
if enable:
self.lbStatusRead.setVisible(False)
self.webViewMap.setVisible(True)
else:
self.lbStatusRead.setText("")
self.lbStatusRead.setVisible(True)
self.webViewMap.setVisible(False)
self.webViewMap.setEnabled(enable)
self.comboBoxTypeMap.setEnabled(enable)
self.pbRefresh.setEnabled(enable)
self.pbAddRaster.setEnabled(enable)
self.pbCopyKml.setEnabled(enable)
self.pbSaveImg.setEnabled(enable)
self.checkBoxHideCross.setEnabled(enable)
示例2: getSpatialInfo
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
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
示例3: connectionDetails
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
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)
示例4: _opendb
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
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
示例5: initGui
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
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)
示例6: spatialInfo
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
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
示例7: exportTxt
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
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()
示例8: addToLayout
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
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)
示例9: spatialInfo
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
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
示例10: __exportShp
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
def __exportShp(self, asPnt):
u = Util(self.iface)
if asPnt is True:
caption = QApplication.translate("code", "Punkt Shapefile exportieren")
else:
caption = QApplication.translate("code", "Linien Shapefile exportieren")
fileName, file_ext = u.getFileName(caption, [["shp", "shp"]], self.filePath)
if fileName == "":
return
fInfo = QFileInfo(fileName)
self.filePath = fInfo.path()
QgsSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
expShp = ExportShape(self.iface,
(self.ui.IDC_chkHekto.checkState() == Qt.Checked),
(self.ui.IDC_chkLineAttributes.checkState() == Qt.Checked),
self.__getDelimiter(),
self.__getDecimalDelimiter(),
fileName,
self.settings,
self.profiles
)
if asPnt is False:
expShp.exportLine()
else:
expShp.exportPoint()
示例11: runAction
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
def runAction(self, action):
action = str(action)
if action.startswith("spatialindex/"):
parts = action.split('/')
spatialIndex_action = parts[1]
msg = QApplication.translate("DBManagerPlugin", "Do you want to %s spatial index for field %s?") % (
spatialIndex_action, self.geomColumn)
QApplication.restoreOverrideCursor()
try:
if QMessageBox.question(None, QApplication.translate("DBManagerPlugin", "Spatial Index"), msg,
QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
return False
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
if spatialIndex_action == "create":
self.createSpatialIndex()
return True
elif spatialIndex_action == "delete":
self.deleteSpatialIndex()
return True
if action.startswith("extent/"):
if action == "extent/get":
self.refreshTableExtent()
return True
if action == "extent/estimated/get":
self.refreshTableEstimatedExtent()
return True
return Table.runAction(self, action)
示例12: constraintsDetails
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
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"})
示例13: __unicode__
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
def __unicode__(self):
if self.query is None:
return BaseError.__unicode__(self)
msg = QApplication.translate("DBManagerPlugin", "Error:\n%s") % BaseError.__unicode__(self)
if self.query:
msg += QApplication.translate("DBManagerPlugin", "\n\nQuery:\n%s") % self.query
return msg
示例14: __unicode__
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
def __unicode__(self):
if self.query is None:
return BaseError.__unicode__(self)
msg = QApplication.translate("DBManagerPlugin", "Error:\n{0}").format(BaseError.__unicode__(self))
if self.query:
msg += QApplication.translate("DBManagerPlugin", "\n\nQuery:\n{0}").format(self.query)
return msg
示例15: privilegesDetails
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import translate [as 别名]
def privilegesDetails(self):
details = self.schema.database().connector.getSchemaPrivileges(self.schema.name)
lst = []
if details[0]:
lst.append(QApplication.translate("DBManagerPlugin", "create new objects"))
if details[1]:
lst.append(QApplication.translate("DBManagerPlugin", "access objects"))
return HtmlList(lst)