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


Python QTextCodec.codecForLocale方法代码示例

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


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

示例1: run

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForLocale [as 别名]
    def run(self, argv, error_message, in_build_dir=False):
        """ Execute a command and capture the output. """

        if in_build_dir:
            project = self._project

            saved_cwd = os.getcwd()
            build_dir = project.path_from_user(project.build_dir)
            build_dir = QDir.toNativeSeparators(build_dir)
            os.chdir(build_dir)
            self._message_handler.verbose_message(
                    "{0} is now the current directory".format(build_dir))
        else:
            saved_cwd = None

        self._message_handler.verbose_message(
                "Running '{0}'".format(' '.join(argv)))

        QCoreApplication.processEvents()

        process = QProcess()

        process.readyReadStandardOutput.connect(
                lambda: self._message_handler.progress_message(
                        QTextCodec.codecForLocale().toUnicode(
                                process.readAllStandardOutput()).strip()))

        stderr_output = QByteArray()
        process.readyReadStandardError.connect(
                lambda: stderr_output.append(process.readAllStandardError()))

        process.start(argv[0], argv[1:])
        finished = process.waitForFinished()

        if saved_cwd is not None:
            os.chdir(saved_cwd)
            self._message_handler.verbose_message(
                    "{0} is now the current directory".format(saved_cwd))

        if not finished:
            raise UserException(error_message, process.errorString())

        if process.exitStatus() != QProcess.NormalExit or process.exitCode() != 0:
            raise UserException(error_message,
                    QTextCodec.codecForLocale().toUnicode(stderr_output).strip())
开发者ID:doudz,项目名称:pyqtdeploy,代码行数:47,代码来源:builder.py

示例2: read

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForLocale [as 别名]
    def read(self):
        """ Reads the file and returns the content """

        _file = QFile(self.filename)
        if not _file.open(QIODevice.ReadOnly | QIODevice.Text):
            raise Exception(_file.errorString())

        # Codec
        codec = QTextCodec.codecForLocale()
        stream = QTextStream(_file)
        stream.setCodec(codec)
        return stream.readAll()
开发者ID:centaurialpha,项目名称:pireal,代码行数:14,代码来源:pfile.py

示例3: __init__

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForLocale [as 别名]
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        # merge stderr channel into stdout channel
        self.setProcessChannelMode(QProcess.MergedChannels)

        # prepare decoding process' output to Unicode
        codec = QTextCodec.codecForLocale()
        self._decoder_stdout = codec.makeDecoder()
        # only necessary when stderr channel isn't merged into stdout:
        # self._decoder_stderr = codec.makeDecoder()

        self.readyReadStandardOutput.connect(self._ready_read_standard_output)
开发者ID:jcornford,项目名称:pyecog,代码行数:15,代码来源:pyqtgraph_playing.py

示例4: save

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForLocale [as 别名]
    def save(self, data, path=None):
        if path:
            self.filename = path
            self.is_new = False

        _file = QFile(self.filename)
        if not _file.open(QIODevice.WriteOnly | QIODevice.Truncate):
            raise Exception(_file.errorString())

        stream = QTextStream(_file)
        stream.setCodec(QTextCodec.codecForLocale())
        stream << data
        stream.flush()
        _file.close()
        # Emit the signal
        self.fileSaved.emit(self.filename)
开发者ID:centaurialpha,项目名称:pireal,代码行数:18,代码来源:pfile.py


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