本文整理汇总了Python中PyQt.QtWidgets.QApplication类的典型用法代码示例。如果您正苦于以下问题:Python QApplication类的具体用法?Python QApplication怎么用?Python QApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: 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
示例3: 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
示例4: openScript
def openScript(self):
if self.hasChanged:
ret = QMessageBox.warning(self, self.tr('Unsaved changes'),
self.tr('There are unsaved changes in script. Continue?'),
QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
if ret == QMessageBox.No:
return
if self.algType == self.SCRIPT_PYTHON:
scriptDir = ScriptUtils.scriptsFolder()
filterName = self.tr('Python scripts (*.py)')
elif self.algType == self.SCRIPT_R:
scriptDir = RUtils.RScriptsFolder()
filterName = self.tr('Processing R script (*.rsx)')
self.filename = QFileDialog.getOpenFileName(
self, self.tr('Save script'), scriptDir, filterName)
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
with codecs.open(self.filename, 'r', encoding='utf-8') as f:
txt = f.read()
self.editor.setText(txt)
self.hasChanged = False
self.editor.setModified(False)
self.editor.recolor()
QApplication.restoreOverrideCursor()
示例5: 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
示例6: 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()
示例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
示例8: 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()
示例9: 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()
示例10: 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.webView.setHtml(self.HELP_TEXT)
示例11: 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"})
示例12: 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)
示例13: copy
def copy(self):
"""Copy text to clipboard... or keyboard interrupt"""
if self.hasSelectedText():
text = self.selectedText()
text = text.replace('>>> ', '').replace('... ', '').strip() # removing prompts
QApplication.clipboard().setText(text)
else:
raise KeyboardInterrupt
示例14: privilegesDetails
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)
示例15: __unicode__
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