Python PyQt5.QtCore.QCoreApplication.processEvents() Examples

The following are 14 code examples of PyQt5.QtCore.QCoreApplication.processEvents(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore.QCoreApplication , or try the search function .
Example #1
Source File: VersionUpgradeManager.py    From Uranium with GNU Lesser General Public License v3.0 6 votes vote down vote up
def upgrade(self) -> bool:
        """Performs the version upgrades of all configuration files to the most
        recent version.

        The upgrade plug-ins must all be loaded at this point, or no upgrades
        can be performed.

        :return: True if anything was upgraded, or False if it was already up to date.
        """
        start_time = time.time()
        Logger.log("i", "Looking for old configuration files to upgrade.")
        self._upgrade_tasks.extend(self._getUpgradeTasks())     # Get the initial files to upgrade.
        self._upgrade_routes = self._findShortestUpgradeRoutes()  # Pre-compute the upgrade routes.

        upgraded = False  # Did we upgrade something?
        while self._upgrade_tasks:
            upgrade_task = self._upgrade_tasks.popleft()
            self._upgradeFile(upgrade_task.storage_path, upgrade_task.file_name, upgrade_task.configuration_type)  # Upgrade this file.
            QCoreApplication.processEvents()  # Ensure that the GUI does not freeze.
        if upgraded:
            message = UM.Message.Message(text = catalogue.i18nc("@info:version-upgrade", "A configuration from an older version of {0} was imported.", Application.getInstance().getApplicationName()), title = catalogue.i18nc("@info:title", "Version Upgrade"))
            message.show()
        Logger.log("i", "Checking and performing updates took %s", time.time() - start_time)
        return upgraded 
Example #2
Source File: process.py    From idapkg with MIT License 6 votes vote down vote up
def system(cmd):
    """
    Wrapper around :py:meth:`os.system`, except that output will be redirected to messages window.

    :param cmd: Command to execute.
    :return: exit status.
    :rtype: int
    """
    process = Popen(cmd, shell=True)

    # call processEvents() to prevent hang
    timeout = 0.01
    while all(thread.is_alive() for thread in process.threads):
        for thread in process.threads:
            thread.join(timeout)
        QCoreApplication.processEvents()

    return process.wait() 
Example #3
Source File: lab6.py    From Computer-graphics with MIT License 5 votes vote down vote up
def delay():
    #QCoreApplication.processEvents(QEventLoop.AllEvents, 1)
    QtWidgets.QApplication.processEvents(QEventLoop.AllEvents, 1)
    #time.sleep(.005)

    """t = QTime.currentTime().addMSecs(1)
    while QTime.currentTime() < t:
        QCoreApplication.processEvents(QEventLoop.AllEvents, 1)""" 
Example #4
Source File: lab5.py    From Computer-graphics with MIT License 5 votes vote down vote up
def delay():
    #QCoreApplication.processEvents(QEventLoop.AllEvents, 1)
    QtWidgets.QApplication.processEvents(QEventLoop.AllEvents, 1)
    #time.sleep(.005)

    """t = QTime.currentTime().addMSecs(1)
    while QTime.currentTime() < t:
        QCoreApplication.processEvents(QEventLoop.AllEvents, 1)""" 
Example #5
Source File: NetworkedPrinterOutputDevice.py    From Cura with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _compressDataAndNotifyQt(self, data_to_append: str) -> bytes:
        compressed_data = gzip.compress(data_to_append.encode("utf-8"))
        self._progress_message.setProgress(-1)  # Tickle the message so that it's clear that it's still being used.
        QCoreApplication.processEvents()  # Ensure that the GUI does not freeze.

        # Pretend that this is a response, as zipping might take a bit of time.
        # If we don't do this, the device might trigger a timeout.
        self._last_response_time = time()
        return compressed_data 
Example #6
Source File: WorkspaceDialog.py    From Cura with GNU Lesser General Public License v3.0 5 votes vote down vote up
def waitForClose(self):
        """Block thread until the dialog is closed."""

        if self._visible:
            if threading.current_thread() != threading.main_thread():
                self._lock.acquire()
                self._lock.release()
            else:
                # If this is not run from a separate thread, we need to ensure that the events are still processed.
                while self._visible:
                    time.sleep(1 / 50)
                    QCoreApplication.processEvents()  # Ensure that the GUI does not freeze. 
Example #7
Source File: StartSliceJob.py    From Cura with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _cacheAllExtruderSettings(self):
        global_stack = cast(ContainerStack, CuraApplication.getInstance().getGlobalContainerStack())

        # NB: keys must be strings for the string formatter
        self._all_extruders_settings = {
            "-1": self._buildReplacementTokens(global_stack)
        }
        QCoreApplication.processEvents()  # Ensure that the GUI does not freeze.
        for extruder_stack in ExtruderManager.getInstance().getActiveExtruderStacks():
            extruder_nr = extruder_stack.getProperty("extruder_nr", "value")
            self._all_extruders_settings[str(extruder_nr)] = self._buildReplacementTokens(extruder_stack)
            QCoreApplication.processEvents()  # Ensure that the GUI does not freeze. 
Example #8
Source File: PluginRegistry.py    From Uranium with GNU Lesser General Public License v3.0 5 votes vote down vote up
def loadPlugins(self, metadata: Optional[Dict[str, Any]] = None) -> None:
        """Load all plugins matching a certain set of metadata

        :param metadata: The meta data that needs to be matched.
        NOTE: This is the method which kicks everything off at app launch.
        """

        start_time = time.time()
        # Get a list of all installed plugins:
        plugin_ids = self._findInstalledPlugins()
        for plugin_id in plugin_ids:
            # Get the plugin metadata:
            try:
                plugin_metadata = self.getMetaData(plugin_id)
            except TrustException:
                Logger.error("Plugin {} was not loaded because it could not be verified.", plugin_id)
                message_text = i18n_catalog.i18nc("@error:untrusted",
                                                  "Plugin {} was not loaded because it could not be verified.", plugin_id)
                Message(text = message_text).show()
                continue

            # Save all metadata to the metadata dictionary:
            self._metadata[plugin_id] = plugin_metadata
            if metadata is None or self._subsetInDict(self._metadata[plugin_id], metadata):
                #
                try:
                    self.loadPlugin(plugin_id)
                    QCoreApplication.processEvents()  # Ensure that the GUI does not freeze.
                    # Add the plugin to the list after actually load the plugin:
                    self._all_plugins.append(plugin_id)
                    self._plugins_installed.append(plugin_id)
                except PluginNotFoundError:
                    pass
        Logger.log("d", "Loading all plugins took %s seconds", time.time() - start_time)

    # Checks if the given plugin API version is compatible with the current version. 
Example #9
Source File: workspace_sharing_widget.py    From parsec-cloud with GNU Affero General Public License v3.0 5 votes vote down vote up
def _on_get_participants_success(self, job):
        participants = job.ret
        while self.scroll_content.layout().count() > 1:
            item = self.scroll_content.layout().takeAt(0)
            w = item.widget()
            self.scroll_content.layout().removeItem(item)
            w.setParent(None)
        QCoreApplication.processEvents()
        for user, (role, revoked_info) in participants.items():
            self.add_participant(
                user, user == self.core.device.user_id, role, is_revoked=revoked_info is not None
            )
        self.line_edit_share.setText("")
        self.button_share.setDisabled(True)
        self.button_apply.setDisabled(True) 
Example #10
Source File: util.py    From lxa5 with MIT License 5 votes vote down vote up
def process_all_gui_events():
    QCoreApplication.processEvents()


# ------------------------------------------------------------------------------

# configuration file 
Example #11
Source File: return.py    From Pythonic with GNU General Public License v3.0 5 votes vote down vote up
def execute(self, data):
        logging.info('execute() called at Item {} {}'.format(self.row, self.column))
        self.highlightStart()
        QCoreApplication.processEvents()
        sleep(1)
        self.highlightStop()
        QCoreApplication.processEvents()

        output = ('output from ExecOp')
        target = (self.row, self.column+1)
        return (target, output) 
Example #12
Source File: ITAslicer.py    From pySPM with Apache License 2.0 5 votes vote down vote up
def flatten(self):
        from scipy import optimize as opt
        self.ui.status.setText("Start the flattening...")
        self.level = np.zeros(self.volume.shape[:2])
        self.ui.pb.setMaximum(self.volume.shape[0])
        for y in range(self.volume.shape[0]):
            self.ui.pb.setValue(y)
            self.flatline(y)
            QCoreApplication.processEvents()
            self.ax.clear()
            self.ax.imshow(self.level)
            self.canvas.draw()
        self.ui.pb.setValue(0)
        self.ui.status.setText("Flattening finished")
        np.save(self.path+".level", self.level) 
Example #13
Source File: main_window.py    From parsec-cloud with GNU Affero General Public License v3.0 4 votes vote down vote up
def showMaximized(self, skip_dialogs=False):
        super().showMaximized()
        QCoreApplication.processEvents()

        # Used with the --diagnose option
        if skip_dialogs:
            return

        # At the very first launch
        if self.config.gui_first_launch:
            r = ask_question(
                self,
                _("TEXT_ERROR_REPORTING_TITLE"),
                _("TEXT_ERROR_REPORTING_INSTRUCTIONS"),
                [_("ACTION_ERROR_REPORTING_ACCEPT"), _("ACTION_NO")],
            )

            # Acknowledge the changes
            self.event_bus.send(
                CoreEvent.GUI_CONFIG_CHANGED,
                gui_first_launch=False,
                gui_last_version=PARSEC_VERSION,
                telemetry_enabled=r == _("ACTION_ERROR_REPORTING_ACCEPT"),
            )

        # For each parsec update
        if self.config.gui_last_version and self.config.gui_last_version != PARSEC_VERSION:

            # Update from parsec `<1.14` to `>=1.14`
            if LooseVersion(self.config.gui_last_version) < "1.14":

                # Revert the acrobat reader workaround
                if (
                    platform.system() == "Windows"
                    and win_registry.is_acrobat_reader_dc_present()
                    and not win_registry.get_acrobat_app_container_enabled()
                ):
                    win_registry.del_acrobat_app_container_enabled()

            # Acknowledge the changes
            self.event_bus.send(CoreEvent.GUI_CONFIG_CHANGED, gui_last_version=PARSEC_VERSION)

        telemetry.init(self.config)

        devices = list_available_devices(self.config.config_dir)
        if not len(devices):
            r = ask_question(
                self,
                _("TEXT_KICKSTART_PARSEC_WHAT_TO_DO_TITLE"),
                _("TEXT_KICKSTART_PARSEC_WHAT_TO_DO_INSTRUCTIONS"),
                [
                    _("ACTION_NO_DEVICE_CREATE_ORGANIZATION"),
                    _("ACTION_NO_DEVICE_JOIN_ORGANIZATION"),
                ],
                radio_mode=True,
            )
            if r == _("ACTION_NO_DEVICE_JOIN_ORGANIZATION"):
                self._on_join_org_clicked()
            elif r == _("ACTION_NO_DEVICE_CREATE_ORGANIZATION"):
                self._on_create_org_clicked() 
Example #14
Source File: gui.py    From lanzou-gui with MIT License 4 votes vote down vote up
def login_update_ui(self, success, msg, duration):
        """根据登录是否成功更新UI,并保持用户信息"""
        self.show_status(msg, duration)
        if success:
            self.update_lanzoucloud_settings()
            self._work_id = self._config.work_id  # 切换用户后刷新 根目录
            if self._user:
                if len(self._user) <= 6:
                    disk_tab = f"我的蓝奏<{self._user}>"
                else:
                    disk_tab = f"我的蓝奏<{self._user[:4]}..>"
            else:
                disk_tab = "我的蓝奏云"
            self.tabWidget.insertTab(1, self.disk_tab, disk_tab)
            self.tabWidget.insertTab(2, self.rec_tab, "回收站")
            self.disk_tab.setEnabled(True)
            self.rec_tab.setEnabled(True)
            # 更新快捷键与工具栏
            self.toolbar.addAction(self.logout)  # 添加登出工具栏
            self.toolbar.addAction(self.upload)  # 添加上传文件工具栏
            # 菜单栏槽
            self.logout.setEnabled(True)
            self.upload.setEnabled(True)
            self.upload.triggered.connect(self.show_upload_dialog_menus)
            # 设置当前显示 tab
            self.tabWidget.setCurrentIndex(self.tabWidget.indexOf(self.disk_tab))
            QCoreApplication.processEvents()  # 重绘界面
            self._config.update_user()  # 存储用户信息
            # 刷新文件列表
            # self.list_refresher.set_values(self._work_id)
        else:
            self.show_status(msg, duration)
            self.tabWidget.setCurrentIndex(0)
            self.tabWidget.removeTab(2)
            self.tabWidget.removeTab(1)
            self.disk_tab.setEnabled(False)
            self.rec_tab.setEnabled(False)
            # 更新快捷键与工具栏
            self.toolbar.removeAction(self.logout)  # 登出工具栏
            self.toolbar.removeAction(self.upload)  # 上传文件工具栏
            self.logout.setEnabled(False)
            self.upload.setEnabled(False)