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


Python QTextCodec.setCodecForTr方法代码示例

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


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

示例1: main

# 需要导入模块: from PyQt4.QtCore import QTextCodec [as 别名]
# 或者: from PyQt4.QtCore.QTextCodec import setCodecForTr [as 别名]
def main():
    qapp = QApplication(sys.argv)
    tc = QTextCodec.codecForName('utf-8')
    QTextCodec.setCodecForCStrings(tc)
    QTextCodec.setCodecForLocale(tc)
    QTextCodec.setCodecForTr(tc)
    app.g_pwd = os.getcwd()
    print app.g_pwd

    #遍历目录
    tmpdirs = os.listdir(app.g_pwd + os.sep + 'templates')
    for tmpdir in tmpdirs:
        currentdir = app.g_pwd + os.sep + 'templates' + os.sep + tmpdir
        if os.path.isdir(currentdir) and os.path.exists(currentdir + os.sep + 'config.json'):
            app.g_templates.append(tmpdir)

    m = mainwindow.mainwindow()
    m.show()
    qapp.exec_()
开发者ID:384782946,项目名称:ProjectWizard,代码行数:21,代码来源:main.py

示例2: __init__

# 需要导入模块: from PyQt4.QtCore import QTextCodec [as 别名]
# 或者: from PyQt4.QtCore.QTextCodec import setCodecForTr [as 别名]
    def __init__(self, page, parent=None):
        super(HelpForm, self).__init__(parent)
        QTextCodec.setCodecForTr(QTextCodec.codecForName("system"))
        QTextCodec.setCodecForCStrings(QTextCodec.codecForName("system"))
        QTextCodec.setCodecForLocale(QTextCodec.codecForName("system"))
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setAttribute(Qt.WA_GroupLeader)

        backAction = QAction(QIcon(":/back.png"), "&Back", self)
        backAction.setShortcut(QKeySequence.Back)
        homeAction = QAction(QIcon(":/home.png"), "&Home", self)
        homeAction.setShortcut("Home")
        self.pageLabel = QLabel()

        toolBar = QToolBar()
        toolBar.addAction(backAction)
        toolBar.addAction(homeAction)
        toolBar.addWidget(self.pageLabel)
        self.textBrowser = QTextBrowser()
        # self.textBrowser.

        layout = QVBoxLayout()
        layout.addWidget(toolBar)
        layout.addWidget(self.textBrowser, 1)
        self.setLayout(layout)

        self.connect(backAction, SIGNAL("triggered()"),
                     self.textBrowser, SLOT("backward()"))
        self.connect(homeAction, SIGNAL("triggered()"),
                     self.textBrowser, SLOT("home()"))
        self.connect(self.textBrowser, SIGNAL("sourceChanged(QUrl)"),
                     self.updatePageTitle)

        self.textBrowser.setSearchPaths([":/help"])
        self.textBrowser.setSource(QUrl(page))
        self.resize(400, 600)
        self.setWindowTitle("%s Help" % QApplication.applicationName())
开发者ID:bindx,项目名称:EE-Book,代码行数:39,代码来源:helpform.py

示例3: __init__

# 需要导入模块: from PyQt4.QtCore import QTextCodec [as 别名]
# 或者: from PyQt4.QtCore.QTextCodec import setCodecForTr [as 别名]
 def __init__(self, shared):
     super(Backend, self).__init__()
     self.shared = shared
     self.sendto = lambda x: shared.udpsocket.sendto(
         x.encode('utf-8'),
         ('127.0.0.1', 50000)
         )
     self._app = QApplication([])
     translator = QTranslator(self._app)
     self._app.setQuitOnLastWindowClosed(False)
     translator.load(
         QLocale.system(), 'lang', '.', shared.path + sep + 'langs')
     self._app.installTranslator(translator)
     self.loadicons()
     QTextCodec.setCodecForTr(QTextCodec.codecForName("UTF-8"))
     self._tray = TrayIcon(self)
     self._tray.setIcon(_icons['wait'])
     self.signals = {
         'add': self.sAdd,
         'empty': lambda x: self._tray.emit(SIGNAL('empty()')),
         'start': self.sStart,
         'error': self.sDone,
         'done': self.sDone,
         }
开发者ID:Nikiforius,项目名称:O4erednik,代码行数:26,代码来源:gui_qt4.py

示例4: DownloadDialog

# 需要导入模块: from PyQt4.QtCore import QTextCodec [as 别名]
# 或者: from PyQt4.QtCore.QTextCodec import setCodecForTr [as 别名]
from src.gui.library import insert_library
from src.tools.config import Config
from PyQt4.Qt import QDialog, pyqtSignal, QProgressDialog
from PyQt4 import QtCore, QtGui

from PyQt4.QtCore import Qt, QThread, QTextCodec, QSettings, QVariant, QSize, QPoint
from src.gui.dialogs.ui_download import Ui_Dialog
from src.web.feeds.recipes.model import RecipeModel

from src.tools.path import Path
from src.login import Login
from src.main import EEBook
from src.constants import EPUBSTOR_DIR, LIBRARY_DIR, ISOTIMEFORMAT


QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8"))


class DownloadDialog(QDialog, Ui_Dialog):
    download = pyqtSignal(object)

    def __init__(self, recipe_model, book_view, parent=None):
        QDialog.__init__(self, parent)
        self.now_url = ''
        self.book_view = book_view

        self.setAttribute(Qt.WA_DeleteOnClose)      # 每次关闭对话框删除对话框所占的内存
        self.setupUi(self)
        self.recipe_model = recipe_model
        self.recipe_model.showing_count = 3     # TODO, 改掉这里的硬编码
        self.count_label.setText(
开发者ID:bindx,项目名称:EE-Book,代码行数:33,代码来源:download.py

示例5: __init__

# 需要导入模块: from PyQt4.QtCore import QTextCodec [as 别名]
# 或者: from PyQt4.QtCore.QTextCodec import setCodecForTr [as 别名]
    def __init__(self, config):
        super(FreeseerApp, self).__init__()
        self.config = config
        self.icon = QIcon()
        self.icon.addPixmap(QPixmap(_fromUtf8(":/freeseer/logo.png")), QIcon.Normal, QIcon.Off)
        self.setWindowIcon(self.icon)

        self.aboutDialog = AboutDialog()
        self.aboutDialog.setModal(True)

        self.logDialog = LogDialog()

        #
        # Translator
        #
        self.app = QApplication.instance()
        self.current_language = None
        self.uiTranslator = QTranslator()
        self.uiTranslator.load(":/languages/tr_en_US.qm")
        self.app.installTranslator(self.uiTranslator)
        self.langActionGroup = QActionGroup(self)
        self.langActionGroup.setExclusive(True)
        QTextCodec.setCodecForTr(QTextCodec.codecForName('utf-8'))
        self.connect(self.langActionGroup, SIGNAL('triggered(QAction *)'), self.translate)
        # --- Translator

        #
        # Setup Menubar
        #
        self.menubar = self.menuBar()

        self.menubar.setGeometry(self.qrect_with_dpi(0, 0, 500, 50))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        self.menuFile = QMenu(self.menubar)
        self.menuFile.setObjectName(_fromUtf8("menuFile"))
        self.menuLanguage = QMenu(self.menubar)
        self.menuLanguage.setObjectName(_fromUtf8("menuLanguage"))
        self.menuHelp = QMenu(self.menubar)
        self.menuHelp.setObjectName(_fromUtf8("menuHelp"))

        exitIcon = QIcon.fromTheme("application-exit")
        self.actionExit = QAction(self)
        self.actionExit.setShortcut("Ctrl+Q")
        self.actionExit.setObjectName(_fromUtf8("actionExit"))
        self.actionExit.setIcon(exitIcon)

        helpIcon = QIcon.fromTheme("help-contents")
        self.actionOnlineHelp = QAction(self)
        self.actionOnlineHelp.setObjectName(_fromUtf8("actionOnlineHelp"))
        self.actionOnlineHelp.setIcon(helpIcon)

        self.actionAbout = QAction(self)
        self.actionAbout.setObjectName(_fromUtf8("actionAbout"))
        self.actionAbout.setIcon(self.icon)

        self.actionLog = QAction(self)
        self.actionLog.setObjectName(_fromUtf8("actionLog"))
        self.actionLog.setShortcut("Ctrl+L")

        # Actions
        self.menuFile.addAction(self.actionExit)
        self.menuHelp.addAction(self.actionAbout)
        self.menuHelp.addAction(self.actionLog)
        self.menuHelp.addAction(self.actionOnlineHelp)
        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addAction(self.menuLanguage.menuAction())
        self.menubar.addAction(self.menuHelp.menuAction())

        self.setupLanguageMenu()
        # --- End Menubar

        self.connect(self.actionExit, SIGNAL('triggered()'), self.close)
        self.connect(self.actionAbout, SIGNAL('triggered()'), self.aboutDialog.show)
        self.connect(self.actionLog, SIGNAL('triggered()'), self.logDialog.show)
        self.connect(self.actionOnlineHelp, SIGNAL('triggered()'), self.openOnlineHelp)

        self.retranslateFreeseerApp()
        self.aboutDialog.aboutWidget.retranslate("en_US")
开发者ID:Blakstar26,项目名称:freeseer,代码行数:80,代码来源:FreeseerApp.py

示例6: OpenOffice

# 需要导入模块: from PyQt4.QtCore import QTextCodec [as 别名]
# 或者: from PyQt4.QtCore.QTextCodec import setCodecForTr [as 别名]
# coding:UTF-8

from OpenOffice import OpenOffice
from PyQt4.QtGui import QTextListFormat
from PyQt4.QtGui import QTextFrameFormat
from PyQt4.QtGui import QColor
from PyQt4.QtCore import QTextCodec

QTextCodec.setCodecForTr(QTextCodec.codecForName("UTF-8"))
QTextCodec.setCodecForCStrings(QTextCodec.codecForName("UTF-8"));
QTextCodec.setCodecForLocale(QTextCodec.codecForName("UTF-8"));

office = OpenOffice('走你.odt')

# Insert some text
office.setListFormat(QTextListFormat.ListUpperAlpha)

office.insertImage("./123.png", 50, 200, QTextFrameFormat.FloatRight)




office.insertList()

office.insertText("中文\n")
office.insertText("two\n")
office.insertText("three\n")
office.insertText("\n")
office.insertText("\n")
office.insertText("\n")
开发者ID:ssx86,项目名称:soffice,代码行数:32,代码来源:test.py

示例7: MainWindow

# 需要导入模块: from PyQt4.QtCore import QTextCodec [as 别名]
# 或者: from PyQt4.QtCore.QTextCodec import setCodecForTr [as 别名]
#! /usr/bin/env python
#coding: u8

import sys

from PyQt4.QtGui import QMainWindow, QApplication
from PyQt4.QtCore import QTextCodec, Qt, QFile, QLatin1String, SIGNAL, pyqtSlot


QTextCodec.setCodecForTr(QTextCodec.codecForName('u8'))


import settings
if settings.DEBUG:
    # 调试的时候每次都转换一下qrc和ui文件
    import gen
    gen.run()

    # 开启js调试[相当于chrome的审查元素]
    from PyQt4 import QtWebKit
    s = QtWebKit.QWebSettings
    s.globalSettings().setAttribute(s.DeveloperExtrasEnabled, True)


import window


class MainWindow(QMainWindow, window.Ui_main_window):
    def __init__(self, app, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
开发者ID:buptlsp,项目名称:coco,代码行数:33,代码来源:main.py


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