本文整理汇总了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))
示例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_('привет мир!'))
示例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!'))
示例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))