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


Python QTextCodec.codecForName方法代码示例

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


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

示例1: aboutToShowSaveAsMenu

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForName [as 别名]
    def aboutToShowSaveAsMenu(self):
        currentText = self.textEdit.toPlainText()

        for action in self.saveAsActs:
            codecName = action.data()
            codec = QTextCodec.codecForName(codecName)
            action.setVisible(codec and codec.canEncode(currentText))
开发者ID:Axel-Erfurt,项目名称:pyqt5,代码行数:9,代码来源:codecs.py

示例2: __init__

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForName [as 别名]
 def __init__(self):
     # Create a byte array that stays in scope as long as we do
     self.buffer = QByteArray()
     # Initialize the "real" QTextStream with a ByteArray buffer.
     super().__init__(self.buffer, QIODevice.ReadWrite)
     # The default codec is codecForLocale, which might vary with
     # the platform, so set a codec here for consistency. UTF-16
     # should entail minimal or no conversion on input or output.
     self.setCodec( QTextCodec.codecForName('UTF-16') )
开发者ID:tallforasmurf,项目名称:PPQT2,代码行数:11,代码来源:utilities.py

示例3: showEncodingDialog

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForName [as 别名]
	def showEncodingDialog(self):
		if not self.maybeSave(self.ind):
			return
		codecsSet = set(bytes(QTextCodec.codecForName(alias).name())
		                for alias in QTextCodec.availableCodecs())
		encoding, ok = QInputDialog.getItem(self, '',
			self.tr('Select file encoding from the list:'),
			[bytes(b).decode() for b in sorted(codecsSet)],
			0, False)
		if ok:
			self.currentTab.readTextFromFile(None, encoding)
开发者ID:retext-project,项目名称:retext,代码行数:13,代码来源:window.py

示例4: read_file

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForName [as 别名]
    def read_file(self, path):
        """Read in a file
        """
        file = QFile(path)
        fileinfo = QFileInfo(file)

        file.open(QIODevice.ReadOnly)
        data = file.readAll()
        codec = QTextCodec.codecForName("UTF-8")

        self.contents = codec.toUnicode(data).rstrip("\n")

        self.filename = fileinfo.fileName()
开发者ID:mbarbon,项目名称:pugdebug,代码行数:15,代码来源:document.py

示例5: loadTranslators

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForName [as 别名]
def loadTranslators(qtTransDir, app, translationFiles=()):
    """
    Module function to load all required translations.
    
    @param qtTransDir directory of the Qt translations files (string)
    @param app reference to the application object (QApplication)
    @param translationFiles tuple of additional translations to
        be loaded (tuple of strings)
    @return the requested locale (string)
    """
    import Preferences
    
    global loaded_translators
    
    if qVersion() < "5.0.0":
        # set the default encoding for tr()
        QTextCodec.setCodecForTr(QTextCodec.codecForName("utf-8"))
    
    translations = ("qt", "eric6") + translationFiles
    loc = Preferences.getUILanguage()
    if loc is None:
        return

    if loc == "System":
        loc = QLocale.system().name()
    if loc != "C":
        dirs = [getConfig('ericTranslationsDir'), Globals.getConfigDir()]
        if qtTransDir is not None:
            dirs.append(qtTransDir)

        loca = loc
        for tf in ["{0}_{1}".format(tr, loc) for tr in translations]:
            translator, ok = loadTranslatorForLocale(dirs, tf)
            loaded_translators[tf] = translator
            if ok:
                app.installTranslator(translator)
            else:
                if tf.startswith("eric6"):
                    loca = None
        loc = loca
    else:
        loc = None
    return loc
开发者ID:pycom,项目名称:EricShort,代码行数:45,代码来源:Startup.py

示例6: __init__

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForName [as 别名]
 def __init__(self, debugServer, passive):
     """
     Constructor
     
     @param debugServer reference to the debug server (DebugServer)
     @param passive flag indicating passive connection mode (boolean)
     """
     super(DebuggerInterfacePython, self).__init__()
     
     self.__isNetworked = True
     self.__autoContinue = False
     
     self.debugServer = debugServer
     self.passive = passive
     self.process = None
     
     self.qsock = None
     self.queue = []
     
     # set default values for capabilities of clients
     self.clientCapabilities = ClientDefaultCapabilities
     
     # set translation function
     self.translate = self.__identityTranslation
     
     self.codec = QTextCodec.codecForName(
         Preferences.getSystem("StringEncoding"))
     
     self.__unicodeRe = re.compile(r"""\bu(["'])""")
     
     if passive:
         # set translation function
         if Preferences.getDebugger("PathTranslation"):
             self.translateRemote = \
                 Preferences.getDebugger("PathTranslationRemote")
             self.translateLocal = \
                 Preferences.getDebugger("PathTranslationLocal")
             self.translate = self.__remoteTranslation
         else:
             self.translate = self.__identityTranslation
     
     # attribute to remember the name of the executed script
     self.__scriptName = ""
开发者ID:chiamingyen,项目名称:kmol2016,代码行数:45,代码来源:DebuggerInterfacePython.py

示例7: __init__

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForName [as 别名]
 def __init__(self, debugServer, passive):
     """
     Constructor
     
     @param debugServer reference to the debug server (DebugServer)
     @param passive flag indicating passive connection mode (boolean)
     """
     super(DebuggerInterfaceRuby, self).__init__()
     
     self.__isNetworked = True
     self.__autoContinue = not passive
     
     self.debugServer = debugServer
     self.passive = passive
     self.process = None
     
     self.qsock = None
     self.queue = []
     
     # set default values for capabilities of clients
     self.clientCapabilities = ClientDefaultCapabilities
     
     # set translation function
     self.translate = self.__identityTranslation
     
     self.codec = QTextCodec.codecForName(
         str(Preferences.getSystem("StringEncoding")))
     
     if passive:
         # set translation function
         if Preferences.getDebugger("PathTranslation"):
             self.translateRemote = \
                 Preferences.getDebugger("PathTranslationRemote")
             self.translateLocal = \
                 Preferences.getDebugger("PathTranslationLocal")
             self.translate = self.__remoteTranslation
         else:
             self.translate = self.__identityTranslation
开发者ID:Darriall,项目名称:eric,代码行数:40,代码来源:DebuggerInterfaceRuby.py

示例8: __init__

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForName [as 别名]
 def __init__(self, conf = "qt.conf", parent = None):
     QSettings.__init__(self, conf, QSettings.IniFormat, parent)
     self.setIniCodec(QTextCodec.codecForName("utf-8"))
开发者ID:892768447,项目名称:BlogClient,代码行数:5,代码来源:settings.py

示例9: start

# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import codecForName [as 别名]
def start(filenames=None, projects_path=None,
          extra_plugins=None, linenos=None):
    app = QApplication(sys.argv)
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(resources.IMAGES['icon']))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES['splash'])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    if sys.platform != 'win32':
        app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    print("codec:", QTextCodec.codecForName('utf-8'))
    #QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    #qsettings = QSettings()
    qsettings = QSettings(resources.SETTINGS_PATH, QSettings.IniFormat)
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language',
        defaultValue=language, type='QString') + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    elif file_manager.file_exists(file_manager.create_path(
      resources.LANGS_DOWNLOAD, lang)):
        settings.LANGUAGE = file_manager.create_path(
            resources.LANGS_DOWNLOAD, lang)
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

        qtTranslator = QTranslator()
        qtTranslator.load("qt_" + language,
            QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtTranslator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
        Qt.black)
    settings.load_settings()

    #Set Stylesheet
    style_applied = False
    if settings.NINJA_SKIN not in ('Default', 'Classic Theme'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as f:
                qss = f.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as f:
                qss = f.read()
        else:
            with open(resources.NINJA__THEME_CLASSIC) as f:
                qss = f.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes",
        Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = qsettings.value('preferences/editor/scheme', "default",
        type='QString')
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
            scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
#.........这里部分代码省略.........
开发者ID:Salmista-94,项目名称:Ninja_PyQt5,代码行数:103,代码来源:ide.py


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