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


Python QObject.trUtf8方法代码示例

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


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

示例1: testTrUtf8AsInstanceMethod

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import trUtf8 [as 别名]
 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,代码行数:9,代码来源:qobject_tr_as_instance_test.py

示例2: testUtf8

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import trUtf8 [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.trUtf8('Hello World!'))
        self.assertEqual(obj.objectName(), py3k.unicode_('привет мир!'))
开发者ID:linzhun,项目名称:pyside2,代码行数:10,代码来源:translation_test.py

示例3: QObjectTrTest

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import trUtf8 [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.trUtf8方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。