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


Python QgsMessageBar.createMessage方法代码示例

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


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

示例1: toggle_select_features_widget

# 需要导入模块: from qgis.gui import QgsMessageBar [as 别名]
# 或者: from qgis.gui.QgsMessageBar import createMessage [as 别名]
def toggle_select_features_widget(title, text, button_text, layer,
                                  new_feature_ids, old_feature_ids):
    """
    Create a widget for QgsMessageBar to switch between two sets.

    :param title: The title
    :type title: str
    :param text: The text message
    :type text: str
    :param button_text: The text on the toggle button
    :type button_text: str
    :param layer: The QgsVectorLayer where the selection is applied
    :type layer: QgsVectorLayer
    :param new_feature_ids: The list to select if use_new is true
    :type new_feature_ids: QgsFeatureIds
    :param old_feature_ids: The list to select if use_new is false
    :type old_feature_ids: QgsFeatureIds
    """
    widget = QgsMessageBar.createMessage(title, text)
    button = QToolButton(widget)
    button.setCheckable(True)
    button.setText(button_text)
    button.toggled.connect(
        lambda on,
        layer=layer,
        new_feature_ids=new_feature_ids,
        old_feature_ids=old_feature_ids:
        toggle_select_features(layer,
                               on,
                               new_feature_ids,
                               old_feature_ids))
    widget.layout().addWidget(button)
    return widget
开发者ID:preinh,项目名称:qt-experiments,代码行数:35,代码来源:utils.py

示例2: activate

# 需要导入模块: from qgis.gui import QgsMessageBar [as 别名]
# 或者: from qgis.gui.QgsMessageBar import createMessage [as 别名]
 def activate(self):
     """
     Map tool is activated
     """
     QgsMapTool.activate(self)
     self.canvas.setCursor(QCursor(Qt.CrossCursor))
     msgtitle = self.tr('Digitizing Drainage Channel')
     msg = self.tr('Digitize start and end point. Rightclick to abort.')
     self.messageBarItem = QgsMessageBar.createMessage(msgtitle,
                                                       msg)
     self.iface.messageBar().pushItem(self.messageBarItem)
开发者ID:tudorbarascu,项目名称:qgepplugin,代码行数:13,代码来源:qgepmaptooladdfeature.py

示例3: BackupedImgUploaderWizard

# 需要导入模块: from qgis.gui import QgsMessageBar [as 别名]
# 或者: from qgis.gui.QgsMessageBar import createMessage [as 别名]

#.........这里部分代码省略.........
        if self.startConnection():
            for index in xrange(self.sources_list_widget.count()):
                filename = str(self.sources_list_widget.item(index).data(Qt.UserRole))

                self.bar2.clearWidgets()
                self.bar2.pushMessage(
                    'INFO',
                    'Pre-upload image processing...',
                    level=QgsMessageBar.INFO)

                # Perfom reprojection
                if filename in self.reprojected:
                    filename = self.reproject(filename)
                    QgsMessageLog.logMessage(
                        'Created reprojected file: %s' % filename,
                        'OAM',
                        level=QgsMessageLog.INFO)

                # Convert file format
                if not (imghdr.what(filename) == 'tiff'):
                    filename = self.convert(filename)
                    QgsMessageLog.logMessage(
                        'Converted file to tiff: %s' % filename,
                        'OAM',
                        level=QgsMessageLog.INFO)

                # create a new uploader instance
                uploader = Uploader(filename,self.bucket,self.upload_options)
                QgsMessageLog.logMessage(
                    'Uploader started\n',
                    'OAM',
                    level=QgsMessageLog.INFO)
                # configure the QgsMessageBar
                messageBar = self.bar2.createMessage('INFO: Performing upload...', )
                progressBar = QProgressBar()
                progressBar.setAlignment(Qt.AlignLeft|Qt.AlignVCenter)
                messageBar.layout().addWidget(progressBar)
                cancelButton = QPushButton()
                cancelButton.setText('Cancel')
                cancelButton.clicked.connect(self.cancelUpload)
                messageBar.layout().addWidget(cancelButton)
                self.bar2.clearWidgets()
                self.bar2.pushWidget(messageBar, level=QgsMessageBar.INFO)
                self.messageBar = messageBar

                # start the worker in a new thread
                thread = QThread(self)
                uploader.moveToThread(thread)
                uploader.finished.connect(self.uploaderFinished)
                uploader.error.connect(self.uploaderError)
                uploader.progress.connect(progressBar.setValue)
                thread.started.connect(uploader.run)
                thread.start()
                self.thread = thread
                self.uploader = uploader
        else:
                QgsMessageLog.logMessage(
                    'No connection to the server\n',
                    'OAM',
                    level=QgsMessageLog.CRITICAL)

    def cancelUpload(self):
        self.uploader.kill()
        self.bar2.clearWidgets()
        self.bar2.pushMessage(
            'WARNING',
开发者ID:hotosm,项目名称:oam-qgis-plugin,代码行数:70,代码来源:backup_backup_img_uploader_wizard.py

示例4: exportGeorefRaster

# 需要导入模块: from qgis.gui import QgsMessageBar [as 别名]
# 或者: from qgis.gui.QgsMessageBar import createMessage [as 别名]
    def exportGeorefRaster(self, layer, rasterPath, isPutRotationInWorldFile):
        rasterFormat = rasterPath[-3:]

        try:
            originalWidth = layer.image.width()
            originalHeight = layer.image.height()
            radRotation = layer.rotation * math.pi / 180

            if isPutRotationInWorldFile:
                # keep the image as is and put all transformation params
                # in world file
                img = layer.image

                a = layer.xScale * math.cos(radRotation)
                # sin instead of -sin because angle in CW
                b = -layer.yScale * math.sin(radRotation)
                d = layer.xScale * -math.sin(radRotation)
                e = -layer.yScale * math.cos(radRotation)
                c = layer.center.x() - (a * (originalWidth - 1) / 2 +
                                        b * (originalHeight - 1) / 2)
                f = layer.center.y() - (d * (originalWidth - 1) / 2 +
                                        e * (originalHeight - 1) / 2)

            else:
                # transform the image with rotation and scaling between the
                # axes
                # maintain at least the original resolution of the raster
                ratio = layer.xScale / layer.yScale
                if ratio > 1:
                    # increase x
                    scaleX = ratio
                    scaleY = 1
                else:
                    # increase y
                    scaleX = 1
                    scaleY = 1. / ratio

                width = (abs(scaleX * originalWidth * math.cos(radRotation)) +
                         abs(scaleY * originalHeight * math.sin(radRotation)))
                height = (abs(scaleX * originalWidth * math.sin(radRotation)) +
                          abs(scaleY * originalHeight * math.cos(radRotation)))

                qDebug("wh %f,%f" % (width, height))

                img = QImage(QSize(math.ceil(width), math.ceil(height)),
                             QImage.Format_ARGB32)
                # transparent background
                img.fill(QColor(0, 0, 0, 0))

                painter = QPainter(img)
                painter.setRenderHint(QPainter.Antialiasing, True)

                rect = QRectF(QPointF(-layer.image.width() / 2.0,
                                      -layer.image.height() / 2.0),
                              QPointF(layer.image.width() / 2.0,
                                      layer.image.height() / 2.0))

                painter.translate(QPointF(width / 2.0, height / 2.0))
                painter.rotate(layer.rotation)
                painter.scale(scaleX, scaleY)
                painter.drawImage(rect, layer.image)
                painter.end()

                extent = layer.extent()
                a = extent.width() / width
                e = -extent.height() / height
                # 2nd term because (0,0) of world file is on center of upper
                # left pixel instead of upper left corner of that pixel
                c = extent.xMinimum() + a / 2
                f = extent.yMaximum() + e / 2
                b = d = 0.0

            img.save(rasterPath, rasterFormat)

            worldFilePath = rasterPath[:-3]
            if rasterFormat == "jpg":
                worldFilePath += "jgw"
            elif rasterFormat == "png":
                worldFilePath += "pgw"
            elif rasterFormat == "bmp":
                worldFilePath += "bpw"
            elif rasterFormat == "tif":
                worldFilePath += "tfw"

            with open(worldFilePath, "w") as writer:
                writer.write("%.13f\n%.13f\n%.13f\n%.13f\n%.13f\n%.13f" %
                             (a, b, d, e, c, f))

            crsFilePath = rasterPath + ".aux.xml"
            with open(crsFilePath, "w") as writer:
                writer.write(self.auxContent(
                    self.iface.mapCanvas().mapSettings().destinationCrs()))

            widget = QgsMessageBar.createMessage(
                "Raster Geoferencer", "Raster exported successfully.")
            self.iface.messageBar().pushWidget(widget,  Qgis.Info, 2)
        except Exception as ex:
            QgsMessageLog.logMessage(repr(ex))
            widget = QgsMessageBar.createMessage(
                "Raster Geoferencer",
#.........这里部分代码省略.........
开发者ID:gvellut,项目名称:FreehandRasterGeoreferencer,代码行数:103,代码来源:freehandrastergeoreferencer_commands.py

示例5: activate

# 需要导入模块: from qgis.gui import QgsMessageBar [as 别名]
# 或者: from qgis.gui.QgsMessageBar import createMessage [as 别名]
 def activate(self):
     QgsMapTool.activate( self )
     self.canvas.setCursor( QCursor( Qt.CrossCursor ) )
     self.messageBarItem = QgsMessageBar.createMessage( self.tr('Digitizing Drainage Channel'), self.tr('Digitize start and end point. Rightclick to abort.') )
     self.iface.messageBar().pushItem(self.messageBarItem)
     pass
开发者ID:proteasa,项目名称:QGEP,代码行数:8,代码来源:qgepmaptooladdfeature.py

示例6: S3Manager

# 需要导入模块: from qgis.gui import QgsMessageBar [as 别名]
# 或者: from qgis.gui.QgsMessageBar import createMessage [as 别名]
class S3Manager(S3Connection):

    def __init__(self,
                 access_key_id,
                 secret_access_key,
                 bucket_name,
                 filenames,
                 upload_options,
                 wizard_page,
                 parent=None):

        S3Connection.__init__(self, access_key_id, secret_access_key)
        self.upload_options = upload_options
        self.bucket_name = bucket_name
        self.bucket = None
        self.filenames = filenames
        self.s3Uploaders = []
        self.threads = []

        self.count_uploaded_images = 0
        self.num_uploading_images = 0

        #For GUI (messages and progress bars)
        self.wizard_page = wizard_page

        self.uploader_widget = QtGui.QWidget()
        self.uploader_widget.setWindowTitle("Upload Progress Bars")
        self.uploader_widget.setWindowFlags(Qt.WindowStaysOnTopHint)

        self.uploader_v_box = QtGui.QVBoxLayout()
        self.uploader_widget.setLayout(self.uploader_v_box)

        self.msg_bar_main = None
        self.msg_bar_main_content = None
        self.cancel_button_main = None

        self.msg_bars = []
        self.msg_bars_content = []
        self.progress_bars = []
        self.cancel_buttons = []

    def getBucket(self):

        for trial in xrange(3):
            if self.bucket: break
            try:
                self.bucket = super(S3Manager,self).get_bucket(self.bucket_name)
                QgsMessageLog.logMessage(
                    'Connection established' % trial,
                    'OAM',
                    level=QgsMessageLog.INFO)
            except:
                if trial == 2:
                   QgsMessageLog.logMessage(
                    'Failed to connect after 3 attempts',
                    'OAM',
                    level=QgsMessageLog.CRITICAL)

        return self.bucket

        """for testing purpose"""
        """
        rsKeys = []
        for key in self.bucket.list():
            rsKeys.append(repr(key))
        return rsKeys
        """

    #functions for threading purpose
    def uploadFiles(self):

        """ Testing purpose only """
        if "notify_oam" in self.upload_options:
            print "notify_oam"
        if "trigger_tiling" in self.upload_options:
            print "trigger_tiling"

        # configure the msg_bar_main (including Cancel button and its container)
        self.msg_bar_main = QgsMessageBar()
        self.msg_bar_main.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        self.wizard_page.layout().addWidget(self.msg_bar_main)

        self.msg_bar_main_content = self.msg_bar_main.createMessage('Performing upload...', )
        self.cancel_button_main = QPushButton()
        self.cancel_button_main.setText('Cancel')
        self.cancel_button_main.clicked.connect(self.cancelAllUploads)
        self.msg_bar_main_content.layout().addWidget(self.cancel_button_main)
        self.msg_bar_main.clearWidgets()
        self.msg_bar_main.pushWidget(self.msg_bar_main_content, level=QgsMessageBar.INFO)

        self.num_uploading_images = len(self.filenames)

        for i in range(0, self.num_uploading_images):
            filename = self.filenames[i]

            # create a new S3Uploader instance
            self.s3Uploaders.append(S3Uploader(filename, self.bucket, self.upload_options, i))

            try:
                # start the worker in a new thread
#.........这里部分代码省略.........
开发者ID:hotosm,项目名称:oam-qgis-plugin,代码行数:103,代码来源:backup_module_access_s3.py


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