本文整理汇总了Python中qgis.PyQt.QtWidgets.QPushButton类的典型用法代码示例。如果您正苦于以下问题:Python QPushButton类的具体用法?Python QPushButton怎么用?Python QPushButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QPushButton类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
super(HistoryDialog, self).__init__(None)
self.setupUi(self)
QgsGui.instance().enableAutoGeometryRestore(self)
self.groupIcon = QgsApplication.getThemeIcon('mIconFolder.svg')
self.keyIcon = self.style().standardIcon(QStyle.SP_FileIcon)
self.clearButton = QPushButton(self.tr('Clear'))
self.clearButton.setToolTip(self.tr('Clear history'))
self.buttonBox.addButton(self.clearButton, QDialogButtonBox.ActionRole)
self.saveButton = QPushButton(QCoreApplication.translate('HistoryDialog', 'Save As…'))
self.saveButton.setToolTip(self.tr('Save history'))
self.buttonBox.addButton(self.saveButton, QDialogButtonBox.ActionRole)
self.tree.doubleClicked.connect(self.executeAlgorithm)
self.tree.currentItemChanged.connect(self.changeText)
self.clearButton.clicked.connect(self.clearLog)
self.saveButton.clicked.connect(self.saveLog)
self.tree.setContextMenuPolicy(Qt.CustomContextMenu)
self.tree.customContextMenuRequested.connect(self.showPopupMenu)
self.fillTree()
开发者ID:alexbruy,项目名称:QGIS,代码行数:27,代码来源:HistoryDialog.py
示例2: setupUi
def setupUi(self):
self.resize(500, 350)
self.setWindowTitle("Remote connections manager")
self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0)
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Vertical)
self.buttonBox.setStandardButtons(QDialogButtonBox.Close)
self.table = QTableWidget()
self.table.verticalHeader().setVisible(False)
self.table.setSelectionMode(QAbstractItemView.SingleSelection)
self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
self.addRowButton = QPushButton()
self.addRowButton.setText("Add connection")
self.editRowButton = QPushButton()
self.editRowButton.setText("Edit connection")
self.removeRowButton = QPushButton()
self.removeRowButton.setText("Remove connection")
self.buttonBox.addButton(self.addRowButton, QDialogButtonBox.ActionRole)
self.buttonBox.addButton(self.editRowButton, QDialogButtonBox.ActionRole)
self.buttonBox.addButton(self.removeRowButton, QDialogButtonBox.ActionRole)
self.setTableContent()
self.horizontalLayout.addWidget(self.table)
self.horizontalLayout.addWidget(self.buttonBox)
self.setLayout(self.horizontalLayout)
self.buttonBox.rejected.connect(self.close)
self.editRowButton.clicked.connect(self.editRow)
self.addRowButton.clicked.connect(self.addRow)
self.removeRowButton.clicked.connect(self.removeRow)
QMetaObject.connectSlotsByName(self)
self.editRowButton.setEnabled(False)
self.removeRowButton.setEnabled(False)
开发者ID:boundlessgeo,项目名称:qgis-geogiglight-plugin,代码行数:35,代码来源:remotesdialog.py
示例3: __init__
def __init__(self):
super(HistoryDialog, self).__init__(None)
self.setupUi(self)
self.groupIcon = QIcon()
self.groupIcon.addPixmap(self.style().standardPixmap(
QStyle.SP_DirClosedIcon), QIcon.Normal, QIcon.Off)
self.groupIcon.addPixmap(self.style().standardPixmap(
QStyle.SP_DirOpenIcon), QIcon.Normal, QIcon.On)
self.keyIcon = QIcon()
self.keyIcon.addPixmap(self.style().standardPixmap(QStyle.SP_FileIcon))
self.clearButton = QPushButton(self.tr('Clear'))
self.clearButton.setToolTip(self.tr('Clear history'))
self.buttonBox.addButton(self.clearButton, QDialogButtonBox.ActionRole)
self.saveButton = QPushButton(self.tr('Save As...'))
self.saveButton.setToolTip(self.tr('Save history'))
self.buttonBox.addButton(self.saveButton, QDialogButtonBox.ActionRole)
self.tree.doubleClicked.connect(self.executeAlgorithm)
self.tree.currentItemChanged.connect(self.changeText)
self.clearButton.clicked.connect(self.clearLog)
self.saveButton.clicked.connect(self.saveLog)
self.tree.setContextMenuPolicy(Qt.CustomContextMenu)
self.tree.customContextMenuRequested.connect(self.showPopupMenu)
self.fillTree()
开发者ID:GeoCat,项目名称:QGIS,代码行数:30,代码来源:HistoryDialog.py
示例4: __init__
def __init__(self, text):
QPushButton.__init__(self)
self.setText(text)
buttons_size_policy = QSizePolicy(
QSizePolicy.Fixed, QSizePolicy.Fixed)
self.setSizePolicy(buttons_size_policy)
self.setMaximumSize(QSize(30, 30))
开发者ID:jonnyforestGIS,项目名称:QGIS,代码行数:7,代码来源:ListMultiselectWidget.py
示例5: treeItemClicked
def treeItemClicked(self, item):
if item.childCount():
return
color = {"MODIFIED": QColor(255, 170, 0), "ADDED":Qt.green,
"REMOVED":Qt.red , "NO_CHANGE":Qt.white}
changeTypeName = ["", "ADDED", "MODIFIED", "REMOVED"]
path = item.text(0)
if path not in self.changes:
return
oldfeature = self.changes[path].oldfeature
newfeature = self.changes[path].newfeature
changetype = self.changes[path].changetype
self.attributesTable.clear()
self.attributesTable.verticalHeader().show()
self.attributesTable.horizontalHeader().show()
self.attributesTable.setRowCount(len(newfeature))
self.attributesTable.setVerticalHeaderLabels([a for a in newfeature])
self.attributesTable.setHorizontalHeaderLabels(["Old value", "New value", "Change type"])
for i, attrib in enumerate(newfeature):
self.attributesTable.setItem(i, 0, DiffItem(oldfeature.get(attrib, None)))
self.attributesTable.setItem(i, 1, DiffItem(newfeature.get(attrib, None)))
attribChangeType = changeTypeName[changetype]
isChangedGeom = False
if changetype == LOCAL_FEATURE_MODIFIED:
oldvalue = oldfeature.get(attrib, None)
newvalue = newfeature.get(attrib, None)
try:# to avoid false change detection due to different precisions
oldvalue = QgsGeometry.fromWkt(oldvalue).exportToWkt(7)
newvalue = QgsGeometry.fromWkt(newvalue).exportToWkt(7)
if oldvalue != newvalue and None not in [oldvalue, newvalue]:
widget = QWidget()
btn = QPushButton()
btn.setText("View detail")
g1 = QgsGeometry.fromWkt(oldvalue)
g2 = QgsGeometry.fromWkt(newvalue)
btn.clicked.connect(lambda: self.viewGeometryChanges(g1, g2))
label = QLabel()
label.setText(attribChangeType)
layout = QHBoxLayout(widget)
layout.addWidget(label);
layout.addWidget(btn);
layout.setContentsMargins(0, 0, 0, 0)
widget.setLayout(layout)
self.attributesTable.setItem(i, 2, QTableWidgetItem(""))
self.attributesTable.setCellWidget(i, 2, widget)
isChangedGeom = True
except:
pass
if oldvalue == newvalue:
attribChangeType = "NO_CHANGE"
if not isChangedGeom:
self.attributesTable.setItem(i, 2, QTableWidgetItem(attribChangeType))
for col in range(3):
self.attributesTable.item(i, col).setBackgroundColor(color[attribChangeType]);
self.attributesTable.resizeColumnsToContents()
self.attributesTable.horizontalHeader().setResizeMode(QHeaderView.Stretch)
开发者ID:boundlessgeo,项目名称:qgis-geogiglight-plugin,代码行数:56,代码来源:localdiffviewerdialog.py
示例6: _reverseAdresCallback
def _reverseAdresCallback(self, point):
self._addMarker( point )
lam72 = QgsCoordinateReferenceSystem(31370)
mapCrs = self.gh.getGetMapCrs(self.iface)
xform = QgsCoordinateTransform(mapCrs, lam72, QgsProject.instance())
lam72clickt = xform.transform(point)
#to clear or not clear that is the question
self.iface.messageBar().clearWidgets()
#fetch Location from geopunt
adres = self.gp.fetchLocation( str( lam72clickt.x() ) + "," + str( lam72clickt.y() ), 1)
Timer( 3, self._clearGraphicLayer, ()).start()
if len(adres) and type( adres ) is list:
#only one result in list, was set in request
FormattedAddress = adres[0]["FormattedAddress"]
#add a button to the messageBar widget
xlam72, ylam72 = adres[0]["Location"]["X_Lambert72"], adres[0]["Location"]["Y_Lambert72"]
diff = int(((xlam72 - lam72clickt.x())**2 +(ylam72 - lam72clickt.y())**2 )**(0.5))
widget = self.iface.messageBar().createMessage(QCoreApplication.translate(
"geopunt4Qgis", "Resultaat: "), "{0} (verschil: {1}m)".format(FormattedAddress, diff))
xy = self.gh.prjPtToMapCrs([xlam72, ylam72], 31370)
self._addMarker( xy, QColor(0,255,200))
button = QPushButton(widget)
button.clicked.connect(lambda: self._addReverse(adres[0]))
button.setText(QCoreApplication.translate("geopunt4Qgis" ,"Voeg toe"))
widget.layout().addWidget(button)
self.iface.messageBar().clearWidgets()
self.iface.messageBar().pushWidget(widget, level=Qgis.Info)
elif len(adres) == 0:
self.iface.messageBar().pushMessage(QCoreApplication.translate("geopunt4Qgis","Waarschuwing"),
QCoreApplication.translate("geopunt4Qgis", "Geen resultaten gevonden"),
level=QgsMessageBar.INFO, duration=3)
elif type( adres ) is str:
self.iface.messageBar().pushMessage(QCoreApplication.translate("geopunt4Qgis", "Waarschuwing"),
adres, level=QgsMessageBar.WARNING)
else:
self.iface.messageBar().pushMessage("Error",
QCoreApplication.translate("geopunt4Qgis","onbekende fout"), level=Qgis.Critical)
开发者ID:warrieka,项目名称:geopunt4Qgis,代码行数:49,代码来源:geopunt4qgis.py
示例7: parseresponse
def parseresponse(self, response):
# Trim callback
result = response[len(self.config['callback']) + 1: -1]
try:
obj = json.loads(result)
except:
QgsApplication.messageLog().logMessage(
'Invalid JSON response from server: ' + result, __package__
)
# Check if we have an auth error
if "User not authorized" in response:
title = self.tr(u'Afvist af Kortforsyningen')
message = self.tr(u'Manglende eller ukorrekt token til Kortforsyningen.')
button_text = self.tr(u'Åbn settings')
widget = self.qgisIface.messageBar().createMessage(title, message)
button = QPushButton(widget)
button.setText(button_text)
button.pressed.connect(lambda : self.qgisIface.showOptionsDialog(currentPage='geosearchOptions'))
widget.layout().addWidget(button)
self.qgisIface.messageBar().pushWidget(widget, level=Qgis.Warning, duration=15)
return None
if 'status' not in obj:
QgsApplication.messageLog().logMessage(
'Unexpected result from server: ' + result, __package__
)
return None
if not obj['status'] == 'OK':
QgsApplication.messageLog().logMessage(
'Server reported an error: ' + obj['message'], __package__
)
return None
if "data" not in obj:
return None
data = obj['data']
if not data:
return [(self.tr("Ingen resultater"),None)]
# Make tuple with ("text", object) for each result
return [(e['presentationString'], e) for e in data]
开发者ID:Septima,项目名称:qgis-geosearch,代码行数:42,代码来源:searchbox.py
示例8: __init__
def __init__(self, param, table):
"""
Constructor for FixedTableDialog
:param param: linked processing parameter
:param table: initial table contents - squashed to 1-dimensional!
"""
super().__init__(None)
self.setupUi(self)
QgsGui.instance().enableAutoGeometryRestore(self)
self.tblView.setSelectionBehavior(QAbstractItemView.SelectRows)
self.tblView.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.param = param
self.rettable = None
# Additional buttons
self.btnAdd = QPushButton(self.tr('Add row'))
self.buttonBox.addButton(self.btnAdd,
QDialogButtonBox.ActionRole)
self.btnRemove = QPushButton(self.tr('Remove row(s)'))
self.buttonBox.addButton(self.btnRemove,
QDialogButtonBox.ActionRole)
self.btnRemoveAll = QPushButton(self.tr('Remove all'))
self.buttonBox.addButton(self.btnRemoveAll,
QDialogButtonBox.ActionRole)
self.btnAdd.clicked.connect(self.addRow)
self.btnRemove.clicked.connect(lambda: self.removeRows())
self.btnRemoveAll.clicked.connect(lambda: self.removeRows(True))
if self.param.hasFixedNumberRows():
self.btnAdd.setEnabled(False)
self.btnRemove.setEnabled(False)
self.btnRemoveAll.setEnabled(False)
self.populateTable(table)
开发者ID:rldhont,项目名称:Quantum-GIS,代码行数:39,代码来源:FixedTableDialog.py
示例9: __init__
def __init__(self, iface):
QDialog.__init__(self, iface.mainWindow())
self.workerThread = None
self.state = False
self.outputLoc = None
self.resultStatus = None
self.reRun = False
self.savedProj = None
# Build GUI Elements
self.setWindowTitle("SEILAPLAN wird ausgeführt")
self.resize(500, 100)
self.container = QVBoxLayout()
self.progressBar = QProgressBar(self)
self.progressBar.setMinimumWidth(500)
self.statusLabel = QLabel(self)
self.hbox = QHBoxLayout()
self.cancelButton = QDialogButtonBox()
self.closeButton = QDialogButtonBox()
self.resultLabel = ClickLabel(self)
self.resultLabel.setMaximumWidth(500)
self.resultLabel.setSizePolicy(
QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding))
self.resultLabel.setWordWrap(True)
self.rerunButton = QPushButton("Berechnungen wiederholen")
self.rerunButton.setVisible(False)
spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
QSizePolicy.Minimum)
self.cancelButton.setStandardButtons(QDialogButtonBox.Cancel)
self.cancelButton.clicked.connect(self.onAbort)
self.closeButton.setStandardButtons(QDialogButtonBox.Close)
self.closeButton.clicked.connect(self.onClose)
self.hbox.addWidget(self.rerunButton)
self.hbox.addItem(spacer)
self.hbox.addWidget(self.cancelButton)
self.hbox.setAlignment(self.cancelButton, Qt.AlignHCenter)
self.hbox.addWidget(self.closeButton)
self.hbox.setAlignment(self.closeButton, Qt.AlignHCenter)
self.closeButton.hide()
self.container.addWidget(self.progressBar)
self.container.addWidget(self.statusLabel)
self.container.addWidget(self.resultLabel)
self.container.addLayout(self.hbox)
self.container.setSizeConstraint(QLayout.SetFixedSize)
self.setLayout(self.container)
开发者ID:piMoll,项目名称:SEILAPLAN,代码行数:47,代码来源:progressDialog.py
示例10: __init__
def __init__(self, param, row, col, panel):
super(BatchInputSelectionPanel, self).__init__(None)
self.param = param
self.panel = panel
self.table = self.panel.tblParameters
self.row = row
self.col = col
self.horizontalLayout = QHBoxLayout(self)
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setMargin(0)
self.text = QLineEdit()
self.text.setMinimumWidth(300)
self.text.setText('')
self.text.setSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.text)
self.pushButton = QPushButton()
self.pushButton.setText('...')
self.pushButton.clicked.connect(self.showPopupMenu)
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)
开发者ID:fritsvanveen,项目名称:QGIS,代码行数:21,代码来源:BatchInputSelectionPanel.py
示例11: __init__
def __init__(self, param, row, col, dialog):
super(BatchInputSelectionPanel, self).__init__(None)
self.param = param
self.dialog = dialog
self.row = row
self.col = col
self.horizontalLayout = QHBoxLayout(self)
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setMargin(0)
self.text = QLineEdit()
self.text.setObjectName("text")
self.text.setMinimumWidth(300)
self.setValue("")
self.text.editingFinished.connect(self.textEditingFinished)
self.text.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.text)
self.pushButton = QPushButton()
self.pushButton.setText("...")
self.pushButton.clicked.connect(self.showPopupMenu)
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)
开发者ID:borysiasty,项目名称:QGIS,代码行数:21,代码来源:BatchInputSelectionPanel.py
示例12: __init__
def __init__(self, output, alg, row, col, panel):
super(BatchOutputSelectionPanel, self).__init__(None)
self.alg = alg
self.row = row
self.col = col
self.output = output
self.panel = panel
self.table = self.panel.tblParameters
self.horizontalLayout = QHBoxLayout(self)
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0)
self.text = QLineEdit()
self.text.setText('')
self.text.setMinimumWidth(300)
self.text.setSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.text)
self.pushButton = QPushButton()
self.pushButton.setText('…')
self.pushButton.clicked.connect(self.showSelectionDialog)
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)
开发者ID:blazek,项目名称:QGIS,代码行数:22,代码来源:BatchOutputSelectionPanel.py
示例13: FixedTableDialog
class FixedTableDialog(BASE, WIDGET):
def __init__(self, param, table):
"""
Constructor for FixedTableDialog
:param param: linked processing parameter
:param table: initial table contents - squashed to 1-dimensional!
"""
super().__init__(None)
self.setupUi(self)
QgsGui.instance().enableAutoGeometryRestore(self)
self.tblView.setSelectionBehavior(QAbstractItemView.SelectRows)
self.tblView.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.param = param
self.rettable = None
# Additional buttons
self.btnAdd = QPushButton(self.tr('Add row'))
self.buttonBox.addButton(self.btnAdd,
QDialogButtonBox.ActionRole)
self.btnRemove = QPushButton(self.tr('Remove row(s)'))
self.buttonBox.addButton(self.btnRemove,
QDialogButtonBox.ActionRole)
self.btnRemoveAll = QPushButton(self.tr('Remove all'))
self.buttonBox.addButton(self.btnRemoveAll,
QDialogButtonBox.ActionRole)
self.btnAdd.clicked.connect(self.addRow)
self.btnRemove.clicked.connect(lambda: self.removeRows())
self.btnRemoveAll.clicked.connect(lambda: self.removeRows(True))
if self.param.hasFixedNumberRows():
self.btnAdd.setEnabled(False)
self.btnRemove.setEnabled(False)
self.btnRemoveAll.setEnabled(False)
self.populateTable(table)
def populateTable(self, table):
cols = len(self.param.headers())
rows = len(table) // cols
model = QStandardItemModel(rows, cols)
# Set headers
model.setHorizontalHeaderLabels(self.param.headers())
# Populate table
for row in range(rows):
for col in range(cols):
item = QStandardItem(str(table[row * cols + col]))
model.setItem(row, col, item)
self.tblView.setModel(model)
def accept(self):
cols = self.tblView.model().columnCount()
rows = self.tblView.model().rowCount()
# Table MUST BE 1-dimensional to match core QgsProcessingParameterMatrix expectations
self.rettable = []
for row in range(rows):
for col in range(cols):
self.rettable.append(str(self.tblView.model().item(row, col).text()))
QDialog.accept(self)
def reject(self):
QDialog.reject(self)
def removeRows(self, removeAll=False):
if removeAll:
self.tblView.model().clear()
self.tblView.model().setHorizontalHeaderLabels(self.param.headers())
else:
indexes = sorted(self.tblView.selectionModel().selectedRows())
self.tblView.setUpdatesEnabled(False)
for i in reversed(indexes):
self.tblView.model().removeRows(i.row(), 1)
self.tblView.setUpdatesEnabled(True)
def addRow(self):
items = [QStandardItem('0') for i in range(self.tblView.model().columnCount())]
self.tblView.model().appendRow(items)
开发者ID:rldhont,项目名称:Quantum-GIS,代码行数:84,代码来源:FixedTableDialog.py
示例14: setupUi
def setupUi(self):
self.labels = {}
self.widgets = {}
self.checkBoxes = {}
self.showAdvanced = False
self.wrappers = {}
self.valueItems = {}
self.dependentItems = {}
self.resize(650, 450)
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok | QDialogButtonBox.Help)
self.setSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Expanding)
self.verticalLayout = QVBoxLayout()
self.verticalLayout.setSpacing(5)
self.verticalLayout.setMargin(20)
self.bar = QgsMessageBar()
self.bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
self.verticalLayout.addWidget(self.bar)
hLayout = QHBoxLayout()
hLayout.setSpacing(5)
hLayout.setMargin(0)
descriptionLabel = QLabel(self.tr("Description"))
self.descriptionBox = QLineEdit()
self.descriptionBox.setText(self._alg.displayName())
hLayout.addWidget(descriptionLabel)
hLayout.addWidget(self.descriptionBox)
self.verticalLayout.addLayout(hLayout)
line = QFrame()
line.setFrameShape(QFrame.HLine)
line.setFrameShadow(QFrame.Sunken)
self.verticalLayout.addWidget(line)
for param in self._alg.parameterDefinitions():
if param.flags() & QgsProcessingParameterDefinition.FlagAdvanced:
self.advancedButton = QPushButton()
self.advancedButton.setText(self.tr('Show advanced parameters'))
self.advancedButton.clicked.connect(
self.showAdvancedParametersClicked)
advancedButtonHLayout = QHBoxLayout()
advancedButtonHLayout.addWidget(self.advancedButton)
advancedButtonHLayout.addStretch()
self.verticalLayout.addLayout(advancedButtonHLayout)
break
for param in self._alg.parameterDefinitions():
if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
desc = param.description()
if isinstance(param, QgsProcessingParameterExtent):
desc += self.tr('(xmin, xmax, ymin, ymax)')
if isinstance(param, QgsProcessingParameterPoint):
desc += self.tr('(x, y)')
if param.flags() & QgsProcessingParameterDefinition.FlagOptional:
desc += self.tr(' [optional]')
label = QLabel(desc)
self.labels[param.name()] = label
wrapper = WidgetWrapperFactory.create_wrapper(param, self)
self.wrappers[param.name()] = wrapper
widget = wrapper.widget
if widget is not None:
self.valueItems[param.name()] = widget
tooltip = param.description()
label.setToolTip(tooltip)
widget.setToolTip(tooltip)
if param.flags() & QgsProcessingParameterDefinition.FlagAdvanced:
label.setVisible(self.showAdvanced)
widget.setVisible(self.showAdvanced)
self.widgets[param.name()] = widget
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(widget)
for dest in self._alg.destinationParameterDefinitions():
if dest.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
if isinstance(dest, (QgsProcessingParameterRasterDestination, QgsProcessingParameterVectorDestination,
QgsProcessingParameterFeatureSink, QgsProcessingParameterFileDestination, QgsProcessingParameterFolderDestination)):
label = QLabel(dest.description())
item = QgsFilterLineEdit()
if hasattr(item, 'setPlaceholderText'):
item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(item)
self.valueItems[dest.name()] = item
label = QLabel(' ')
self.verticalLayout.addWidget(label)
label = QLabel(self.tr('Parent algorithms'))
self.dependenciesPanel = self.getDependenciesPanel()
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(self.dependenciesPanel)
self.verticalLayout.addStretch(1000)
self.setPreviousValues()
self.setWindowTitle(self._alg.displayName())
#.........这里部分代码省略.........
开发者ID:Cracert,项目名称:Quantum-GIS,代码行数:101,代码来源:ModelerParametersDialog.py
示例15: BatchInputSelectionPanel
class BatchInputSelectionPanel(QWidget):
valueChanged = pyqtSignal()
def __init__(self, param, row, col, dialog):
super(BatchInputSelectionPanel, self).__init__(None)
self.param = param
self.dialog = dialog
self.row = row
self.col = col
self.horizontalLayout = QHBoxLayout(self)
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setMargin(0)
self.text = QLineEdit()
self.text.setObjectName('text')
self.text.setMinimumWidth(300)
self.setValue('')
self.text.editingFinished.connect(self.textEditingFinished)
self.text.setSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.text)
self.pushButton = QPushButton()
self.pushButton.setText('…')
self.pushButton.clicked.connect(self.showPopupMenu)
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)
def _panel(self):
return self.dialog.mainWidget()
def _table(self):
return self._panel().tblParameters
def showPopupMenu(self):
popupmenu = QMenu()
if not (isinstance(self.param, QgsProcessingParameterMultipleLayers) and
self.param.layerType == dataobjects.TYPE_FILE):
selectLayerAction = QAction(
QCoreApplication.translate('BatchInputSelectionPanel', 'Select from Open Layers…'), self.pushButton)
selectLayerAction.triggered.connect(self.showLayerSelectionDialog)
popupmenu.addAction(selectLayerAction)
selectFileAction = QAction(
QCoreApplication.translate('BatchInputSelectionPanel', 'Select from File System…'), self.pushButton)
selectFileAction.triggered.connect(self.showFileSelectionDialog)
popupmenu.addAction(selectFileAction)
popupmenu.exec_(QCursor.pos())
def showLayerSelectionDialog(self):
layers = []
if (isinstance(self.param, QgsProcessingParameterRasterLayer) or
(isinstance(self.param, QgsProcessingParameterMultipleLayers) and
self.param.layerType() == QgsProcessing.TypeRaster)):
layers = QgsProcessingUtils.compatibleRasterLayers(QgsProject.instance())
elif isinstance(self.param, QgsProcessingParameterVectorLayer):
layers = QgsProcessingUtils.compatibleVectorLayers(QgsProject.instance())
elif (isinstance(self.param, QgsProcessingParameterMeshLayer) or
(isinstance(self.param, QgsProcessingParameterMultipleLayers) and
self.param.layerType() == QgsProcessing.TypeMesh)):
layers = QgsProcessingUtils.compatibleMeshLayers(QgsProject.instance())
else:
datatypes = [QgsProcessing.TypeVectorAnyGeometry]
if isinstance(self.param, QgsProcessingParameterFeatureSource):
datatypes = self.param.dataTypes()
elif isinstance(self.param, QgsProcessingParameterMultipleLayers):
datatypes = [self.param.layerType()]
if QgsProcessing.TypeVectorAnyGeometry not in datatypes:
layers = QgsProcessingUtils.compatibleVectorLayers(QgsProject.instance(), datatypes)
else:
layers = QgsProcessingUtils.compatibleVectorLayers(QgsProject.instance())
dlg = MultipleInputDialog([layer.name() for layer in layers])
dlg.exec_()
def generate_layer_id(layer):
# prefer layer name if unique
if len([l for l in layers if l.name().lower() == layer.name().lower()]) == 1:
return layer.name()
else:
# otherwise fall back to layer id
return layer.id()
if dlg.selectedoptions is not None:
selected = dlg.selectedoptions
if len(selected) == 1:
self.setValue(generate_layer_id(layers[selected[0]]))
else:
if isinstance(self.param, QgsProcessingParameterMultipleLayers):
self.text.setText(';'.join(layers[idx].id() for idx in selected))
else:
rowdif = len(selected) - (self._table().rowCount() - self.row)
for i in range(rowdif):
self._panel().addRow()
for i, layeridx in enumerate(selected):
self._table().cellWidget(i + self.row,
self.col).setValue(generate_layer_id(layers[layeridx]))
#.........这里部分代码省略.........
开发者ID:mbernasocchi,项目名称:QGIS,代码行数:101,代码来源:BatchInputSelectionPanel.py
示例16: HistoryDialog
class HistoryDialog(BASE, WIDGET):
def __init__(self):
super(HistoryDialog, self).__init__(None)
self.setupUi(self)
self.groupIcon = QIcon()
self.groupIcon.addPixmap(self.style().standardPixmap(
QStyle.SP_DirClosedIcon), QIcon.Normal, QIcon.Off)
self.groupIcon.addPixmap(self.style().standardPixmap(
QStyle.SP_DirOpenIcon), QIcon.Normal, QIcon.On)
self.keyIcon = QIcon()
self.keyIcon.addPixmap(self.style().standardPixmap(QStyle.SP_FileIcon))
self.clearButton = QPushButton(self.tr('Clear'))
self.clearButton.setToolTip(self.tr('Clear history'))
self.buttonBox.addButton(self.clearButton, QDialogButtonBox.ActionRole)
self.saveButton = QPushButton(self.tr('Save As...'))
self.saveButton.setToolTip(self.tr('Save history'))
self.buttonBox.addButton(self.saveButton, QDialogButtonBox.ActionRole)
self.tree.doubleClicked.connect(self.executeAlgorithm)
self.tree.currentItemChanged.connect(self.changeText)
self.clearButton.clicked.connect(self.clearLog)
self.saveButton.clicked.connect(self.saveLog)
self.tree.setContextMenuPolicy(Qt.CustomContextMenu)
self.tree.customContextMenuRequested.connect(self.showPopupMenu)
self.fillTree()
def clearLog(self):
reply = QMessageBox.question(self,
self.tr('Confirmation'),
self.tr('Are you sure you want to clear the history?'),
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No
)
if reply == QMessageBox.Yes:
ProcessingLog.clearLog()
self.fillTree()
def saveLog(self):
fileName, filter = QFileDialog.getSaveFileName(self,
self.tr('Save file'), '.', self.tr('Log files (*.log *.LOG)'))
if fileName == '':
return
if not fileName.lower().endswith('.log'):
fileName += '.log'
ProcessingLog.saveLog(fileName)
def fillTree(self):
self.tree.clear()
entries = ProcessingLog.getLogEntries()
groupItem = QTreeWidgetItem()
groupItem.setText(0, 'ALGORITHM')
groupItem.setIcon(0, self.groupIcon)
for entry in entries:
item = TreeLogEntryItem(entry, True)
item.setIcon(0, self.keyIcon)
groupItem.insertChild(0, item)
self.tree.addTopLevelItem(groupItem)
def executeAlgorithm(self):
item = self.tree.currentItem()
if isinstance(item, TreeLogEntryItem):
if item.isAlg:
script = 'import processing\n'
script += 'from qgis.core import QgsProcessingOutputLayerDefinition, QgsProcessingFeatureSourceDefinition\n'
script += item.entry.text.replace('processing.run(', 'processing.runAndLoadResults(')
exec(script)
def changeText(self):
item = self.tree.currentItem()
if isinstance(item, TreeLogEntryItem):
self.text.setText(item.entry.text.replace('|', '\n'))
def createTest(self):
item = self.tree.currentItem()
if isinstance(item, TreeLogEntryItem):
if item.isAlg:
TestTools.createTest(item.entry.text)
def showPopupMenu(self, point):
item = self.tree.currentItem()
if isinstance(item, TreeLogEntryItem):
if item.isAlg:
popupmenu = QMenu()
createTestAction = QAction(self.tr('Create test'), self.tree)
createTestAction.triggered.connect(self.createTest)
popupmenu.addAction(createTestAction)
popupmenu.exec_(self.tree.mapToGlobal(point))
开发者ID:GeoCat,项目名称:QGIS,代码行数:97,代码来源:HistoryDialog.py
示例17: __init__
def __init__(self, iface, parent=None, qsetting=''):
"""Constructor for the dialog.
:param iface: A Quantum GIS QgisAppInterface instance.
:type iface: QgisAppInterface
:param parent: Parent widget of this dialog
:type parent: QWidget
:param qsetting: String to specify the QSettings. By default,
use empty string.
:type qsetting: str
"""
QDialog.__init__(self, parent)
self.setupUi(self)
icon = resources_path('img', 'icons', 'configure-inasafe.svg')
self.setWindowIcon(QIcon(icon))
self.setWindowTitle(self.tr('InaSAFE %s Options' % get_version()))
# Save reference to the QGIS interface and parent
self.iface = iface
self.parent = parent
if qsetting:
self.settings = QSettings(qsetting)
else:
self.settings = QSettings()
# InaSAFE default values
self.default_value_parameters = []
self.default_value_parameter_containers = []
# Flag for restore default values
self.is_restore_default = False
# List of setting key and control
self.boolean_settings = {
'visibleLayersOnlyFlag': self.cbxVisibleLayersOnly,
'set_layer_from_title_flag': self.cbxSetLayerNameFromTitle,
'setZoomToImpactFlag': self.cbxZoomToImpact,
'set_show_only_impact_on_report': self.cbx_show_only_impact,
'print_atlas_report': self.cbx_print_atlas_report,
'setHideExposureFlag': self.cbxHideExposure,
'useSelectedFeaturesOnly': self.cbxUseSelectedFeaturesOnly,
'useSentry': self.cbxUseSentry,
'template_warning_verbose': self.template_warning_checkbox,
'showOrganisationLogoInDockFlag':
self.organisation_on_dock_checkbox,
'developer_mode': self.cbxDevMode,
'generate_report': self.checkbox_generate_reports,
'memory_profile': self.check_box_memory,
'always_show_welcome_message': self.welcome_message_check_box
}
self.text_settings = {
'keywordCachePath': self.leKeywordCachePath,
'ISO19115_ORGANIZATION': self.organisation_line_edit,
'ISO19115_URL': self.website_line_edit,
'ISO19115_EMAIL': self.email_line_edit,
'ISO19115_LICENSE': self.license_line_edit,
}
# Export and Import button
# Export button
self.export_button = QPushButton(tr('Export'))
# noinspection PyUnresolvedReferences
self.export_button.clicked.connect(self.export_setting)
self.button_box.addButton(
self.export_button, QDialogButtonBox.ActionRole)
# Import button
self.import_button = QPushButton(tr('Import'))
# noinspection PyUnresolvedReferences
self.import_button.clicked.connect(self.import_setting)
self.button_box.addButton(
self.import_button, QDialogButtonBox.ActionRole)
# Set up things for context help
self.help_button = self.button_box.button(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)
# Always set first tab to be open, 0-th index
self.tabWidget.setCurrentIndex(0)
# Hide not implemented group
self.grpNotImplemented.hide()
self.adjustSize()
# Population parameter Tab
# Label
self.preference_label = QLabel()
self.preference_label.setText(tr(
'Please set parameters for each hazard class below. Affected '
'status and displacement rates selected on this tab are only '
'applied to exposed populations. '
))
self.preference_layout.addWidget(self.preference_label)
# Profile preference widget
self.profile_widget = ProfileWidget()
self.preference_layout.addWidget(self.profile_widget)
#.........这里部分代码省略.........
开发者ID:inasafe,项目名称:inasafe,代码行数:101,代码来源:options_dialog.py
示例18: startWorker
def startWorker(self):
"""Initialises and starts the worker thread."""
try:
layerindex = self.inputRaster.currentIndex()
layerId = self.inputRaster.itemData(layerindex)
inputlayer = QgsProject.instance().mapLayer(layerId)
#inputlayer = QgsMapLayerRegistry.instance().mapLayer(layerId)
if inputlayer is None:
self.showError(self.tr('No input layer defined'))
return
# create a reference to the layer that is being processed
# (for use when creating the resulting raster layer)
self.thinninglayer = inputlayer
self.levels = []
#self.levelsListView.selectAll()
#selected = self.levelsListView.selectedIndexes()
if self.levelsListView.model().rowCount() ==
|
请发表评论