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


Python QgsMessageBar.pushWidget方法代码示例

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


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

示例1: BackupedImgUploaderWizard

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

#.........这里部分代码省略.........

                # 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',
            'Canceling upload...',
            level=QgsMessageBar.WARNING)

    def uploaderFinished(self, success):
        # clean up the uploader and thread
        try:
            self.uploader.deleteLater()
        except:
            QgsMessageLog.logMessage(
开发者ID:hotosm,项目名称:oam-qgis-plugin,代码行数:70,代码来源:backup_backup_img_uploader_wizard.py

示例2: S3Manager

# 需要导入模块: from qgis.gui import QgsMessageBar [as 别名]
# 或者: from qgis.gui.QgsMessageBar import pushWidget [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.pushWidget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。