当前位置: 首页>>代码示例>>Python>>正文


Python QPlainTextEdit.toPlainText方法代码示例

本文整理汇总了Python中qgis.PyQt.QtWidgets.QPlainTextEdit.toPlainText方法的典型用法代码示例。如果您正苦于以下问题:Python QPlainTextEdit.toPlainText方法的具体用法?Python QPlainTextEdit.toPlainText怎么用?Python QPlainTextEdit.toPlainText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qgis.PyQt.QtWidgets.QPlainTextEdit的用法示例。


在下文中一共展示了QPlainTextEdit.toPlainText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ErrorReportDialog

# 需要导入模块: from qgis.PyQt.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class ErrorReportDialog(QDialog):
    def __init__(self, title, message, errors, username, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle(title)

        self.verticalLayout = QVBoxLayout(self)

        self.label = QLabel(message, self)
        self.verticalLayout.addWidget(self.label)

        self.plainTextEdit = QPlainTextEdit(self)
        self.plainTextEdit.setPlainText(errors)
        self.plainTextEdit.setReadOnly(True)
        self.verticalLayout.addWidget(self.plainTextEdit)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Close)
        self.verticalLayout.addWidget(self.buttonBox)
        self.reportButton = self.buttonBox.addButton(self.tr("Report error"), QDialogButtonBox.ActionRole)

        self.reportButton.clicked.connect(self.__reportError)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)

        self.username = username
        self.metadata = MetaData()

    def __reportError(self):
        body = ("Please provide any additional information here:\n\n\n"
                "If you encountered an upload error, if possible please attach a zip file containing a minimal extract of the dataset, as well as the QGIS project file.\n\n\n"
                "Technical information:\n%s\n\n"
                "Versions:\n"
                " QGIS: %s\n"
                " Python: %s\n"
                " OS: %s\n"
                " QGIS Cloud Plugin: %s\n\n"
                "Username: %s\n") % (
                    self.plainTextEdit.toPlainText(),
                    Qgis.QGIS_VERSION,
                    sys.version.replace("\n", " "),
                    platform.platform(),
                    self.metadata.version(),
                    self.username)
        url = QUrl()
        url.toEncoded("mailto:[email protected]?subject=%s&body=%s" % (
                urllib.parse.quote(self.windowTitle()),
                urllib.parse.quote(body)),
        )
        QDesktopServices.openUrl(url)
开发者ID:qgiscloud,项目名称:qgis-cloud-plugin,代码行数:52,代码来源:error_report_dialog.py

示例2: MultilineTextPanel

# 需要导入模块: from qgis.PyQt.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class MultilineTextPanel(QWidget):

    USE_TEXT = 0

    def __init__(self, options, parent=None):
        super(MultilineTextPanel, self).__init__(parent)
        self.options = options
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setSpacing(2)
        self.verticalLayout.setMargin(0)
        self.combo = QComboBox()
        self.combo.addItem(self.tr('[Use text below]'))
        for option in options:
            self.combo.addItem(option[0], option[1])
        self.combo.setSizePolicy(QSizePolicy.Expanding,
                                 QSizePolicy.Expanding)
        self.verticalLayout.addWidget(self.combo)
        self.textBox = QPlainTextEdit()
        self.verticalLayout.addWidget(self.textBox)
        self.setLayout(self.verticalLayout)

    def setText(self, text):
        self.textBox.setPlainText(text)

    def getOption(self):
        return self.combo.currentIndex()

    def getValue(self):
        if self.combo.currentIndex() == 0:
            return str(self.textBox.toPlainText())
        else:
            return self.combo.currentData()

    def setValue(self, value):
        items = [self.combo.itemData(i) for i in range(1, self.combo.count())]
        for idx, item in enumerate(items):
            if item == value:
                self.combo.setCurrentIndex(idx)
                return
        self.combo.setCurrentIndex(0)
        if value:
            self.textBox.setPlainText(value)
开发者ID:dbaston,项目名称:QGIS,代码行数:44,代码来源:MultilineTextPanel.py

示例3: ImportDialog

# 需要导入模块: from qgis.PyQt.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class ImportDialog(QDialog):

    def __init__(self, parent, repo = None, layer = None):
        super(ImportDialog, self).__init__(parent)
        self.setObjectName("ImportDialog")
        self.repo = repo
        self.layer = layer
        self.ok = False
        self.initGui()

    def initGui(self):
        self.setWindowTitle('Import to GeoGig')
        verticalLayout = QVBoxLayout()

        if self.repo is None:
            repos = repository.repos
            layerLabel = QLabel('Repository')
            verticalLayout.addWidget(layerLabel)
            self.repoCombo = QComboBox()
            self.repoCombo.addItems(["%s - %s" % (r.group, r.title) for r in repos])
            self.repoCombo.currentIndexChanged.connect(self.updateBranches)
            verticalLayout.addWidget(self.repoCombo)
        if self.layer is None:
            layerLabel = QLabel('Layer')
            verticalLayout.addWidget(layerLabel)
            self.layerCombo = QComboBox()
            layerNames = [layer.name() for layer in vectorLayers()
                          if layer.source().lower().split("|")[0].split(".")[-1] in["gpkg", "geopkg"]
                          and not isRepoLayer(layer)]
            self.layerCombo.addItems(layerNames)
            verticalLayout.addWidget(self.layerCombo)

        self.branchLabel = QLabel("Branch")
        verticalLayout.addWidget(self.branchLabel)

        self.branchCombo = QComboBox()
        self.branches = self.repo.branches() if self.repo is not None else repos[0].branches()
        self.branchCombo.addItems(self.branches)
        verticalLayout.addWidget(self.branchCombo)

        messageLabel = QLabel('Message to describe this update')
        verticalLayout.addWidget(messageLabel)

        self.messageBox = QPlainTextEdit()
        verticalLayout.addWidget(self.messageBox)

        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Cancel)
        self.importButton = QPushButton("Add layer")
        self.importButton.clicked.connect(self.importClicked)
        self.buttonBox.addButton(self.importButton, QDialogButtonBox.ApplyRole)
        self.buttonBox.rejected.connect(self.cancelPressed)
        verticalLayout.addWidget(self.buttonBox)

        self.setLayout(verticalLayout)

        self.resize(600, 300)

        self.messageBox.setFocus()

    def updateBranches(self):
        self.branchCombo.clear()
        repo = repository.repos[self.repoCombo.currentIndex()]
        self.branches = repo.branches()
        self.branchCombo.addItems(self.branches)

    def importClicked(self):

        ret = QMessageBox.warning(config.iface.mainWindow(), 'Import warning',
                "Importing a layer will modify the original layer and might cause data loss.\n"
                "Make sure you have a backup copy of your layer before importing.\n"
                "Do you want to import the selected layer?",
                QMessageBox.Yes | QMessageBox.No)
        if ret == QMessageBox.No:
            return


        if self.repo is None:
            self.repo = repository.repos[self.repoCombo.currentIndex()]
        if self.layer is None:
            text = self.layerCombo.currentText()
            self.layer = layerFromName(text)

        user, email = config.getUserInfo()
        if user is None:
            self.close()
            return
        message = self.messageBox.toPlainText() or datetime.now().strftime("%Y-%m-%d %H_%M_%S")
        branch = self.branchCombo.currentText()
        try:
            self.repo.importgeopkg(self.layer, branch, message, user, email, False)
            filename, layername = namesFromLayer(self.layer)
            self.repo.checkoutlayer(filename, layername, ref = branch)
            self.layer.reload()
            self.layer.triggerRepaint()
        except GeoGigException as e:
            iface.messageBar().pushMessage("Error", str(e),
                                           level=QgsMessageBar.CRITICAL,
                                           duration=5)
            self.close()
            return
#.........这里部分代码省略.........
开发者ID:boundlessgeo,项目名称:qgis-geogiglight-plugin,代码行数:103,代码来源:importdialog.py

示例4: CommitDialog

# 需要导入模块: from qgis.PyQt.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class CommitDialog(QDialog):



    def __init__(self, repo, layername,  _message = "", parent = None):
        super(CommitDialog, self).__init__(parent)
        self.repo = repo
        self.branch = None
        self.layername = layername
        self._message = _message or suggestedMessage
        self.message = None
        self.initGui()

    def initGui(self):
        self.setObjectName("CommitDialog")
        self.resize(600, 250)
        self.setWindowTitle("Syncronize layer to repository branch")

        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setSpacing(2)
        self.verticalLayout.setMargin(5)

        self.branchLabel = QLabel("Branch")
        self.verticalLayout.addWidget(self.branchLabel)

        self.branchCombo = QComboBox()
        self.branches = []
        branches = self.repo.branches()
        for branch in branches:
            trees = self.repo.trees(branch)
            if self.layername in trees:
                self.branches.append(branch)
        self.branchCombo.addItems(self.branches)
        try:
            idx = self.branches.index("master")
        except:
            idx = 0
        self.branchCombo.setCurrentIndex(idx)
        self.verticalLayout.addWidget(self.branchCombo)

        self.msgLabel = QLabel("Message to describe this update")
        self.verticalLayout.addWidget(self.msgLabel)

        self.text = QPlainTextEdit()
        self.text.setPlainText(self._message)
        self.verticalLayout.addWidget(self.text)

        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)
        self.verticalLayout.addWidget(self.buttonBox)

        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(self.branches))

        self.setLayout(self.verticalLayout)
        self.buttonBox.accepted.connect(self.okPressed)

        self.text.setFocus()


    def okPressed(self):
        self.branch = self.branchCombo.currentText()
        self.message = self.text.toPlainText() or datetime.now().strftime("%Y-%m-%d %H_%M_%S")
        self.close()
开发者ID:boundlessgeo,项目名称:qgis-geogiglight-plugin,代码行数:64,代码来源:commitdialog.py


注:本文中的qgis.PyQt.QtWidgets.QPlainTextEdit.toPlainText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。