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


Python QObject.tr方法代码示例

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


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

示例1: testTrAsInstanceMethod

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import tr [as 别名]
 def testTrAsInstanceMethod(self):
     #Test QObject.tr as instance
     invar1 = 'test1'
     outvar1 = QObject.tr(self.obj, invar1)
     invar2 = 'test2'
     outvar2 = QObject.tr(self.obj, invar2, 'test comment')
     self.assertEqual((invar1, invar2), (outvar1, outvar2))
开发者ID:BadSingleton,项目名称:pyside2,代码行数:9,代码来源:qobject_tr_as_instance_test.py

示例2: testUtf8

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import tr [as 别名]
    def testUtf8(self):
        translator = QTranslator()
        translator.load(os.path.join(self.trdir, 'trans_russian.qm'))
        self.app.installTranslator(translator)

        obj = QObject()
        obj.setObjectName(obj.tr('Hello World!'))
        self.assertEqual(obj.objectName(), py3k.unicode_('привет мир!'))
开发者ID:BadSingleton,项目名称:pyside2,代码行数:10,代码来源:translation_test.py

示例3: testLatin

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import tr [as 别名]
    def testLatin(self):
        #Set string value to Latin
        translator = QTranslator()
        translator.load(os.path.join(self.trdir, 'trans_latin.qm'))
        self.app.installTranslator(translator)

        obj = QObject()
        obj.setObjectName(obj.tr('Hello World!'))
        self.assertEqual(obj.objectName(), py3k.unicode_('Orbis, te saluto!'))
开发者ID:BadSingleton,项目名称:pyside2,代码行数:11,代码来源:translation_test.py

示例4: QObjectTrTest

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import tr [as 别名]
class QObjectTrTest(unittest.TestCase):
    '''Test case to check if QObject tr and trUtf8 static methods could be treated as instance methods.'''

    def setUp(self):
        self.obj = QObject()

    def tearDown(self):
        del self.obj

    def testTrCommonCase(self):
        #Test common case for QObject.tr
        invar1 = 'test1'
        outvar1 = self.obj.tr(invar1)
        invar2 = 'test2'
        outvar2 = self.obj.tr(invar2, 'test comment')
        self.assertEqual((invar1, invar2), (outvar1, outvar2))

    def testTrAsInstanceMethod(self):
        #Test QObject.tr as instance
        invar1 = 'test1'
        outvar1 = QObject.tr(self.obj, invar1)
        invar2 = 'test2'
        outvar2 = QObject.tr(self.obj, invar2, 'test comment')
        self.assertEqual((invar1, invar2), (outvar1, outvar2))

    def testTrUtf8CommonCase(self):
        #Test common case for QObject.trUtf8
        invar1 = 'test1'
        outvar1 = self.obj.trUtf8(invar1)
        invar2 = 'test2'
        outvar2 = self.obj.trUtf8(invar2, 'test comment')
        self.assertEqual((invar1, invar2), (outvar1, outvar2))

    def testTrUtf8AsInstanceMethod(self):
        #Test QObject.trUtf8 as instance
        invar1 = 'test1'
        outvar1 = QObject.trUtf8(self.obj, invar1)
        invar2 = 'test2'
        outvar2 = QObject.trUtf8(self.obj, invar2, 'test comment')
        self.assertEqual((invar1, invar2), (outvar1, outvar2))
开发者ID:BadSingleton,项目名称:pyside2,代码行数:42,代码来源:qobject_tr_as_instance_test.py


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