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


Python _tkinter.TclError方法代码示例

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


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

示例1: test_getint

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def test_getint(self):
        tcl = self.interp.tk
        for i in self.get_integers():
            result = tcl.getint(' %d ' % i)
            self.assertEqual(result, i)
            self.assertIsInstance(result, type(int(result)))
            if tcl_version >= (8, 5):
                self.assertEqual(tcl.getint(' {:#o} '.format(i)), i)
            self.assertEqual(tcl.getint(' %#o ' % i), i)
            self.assertEqual(tcl.getint(' %#x ' % i), i)
        if tcl_version < (8, 5):  # bignum was added in Tcl 8.5
            self.assertRaises(TclError, tcl.getint, str(2**1000))
        self.assertEqual(tcl.getint(42), 42)
        self.assertRaises(TypeError, tcl.getint)
        self.assertRaises(TypeError, tcl.getint, '42', '10')
        self.assertRaises(TypeError, tcl.getint, 42.0)
        self.assertRaises(TclError, tcl.getint, 'a')
        self.assertRaises((TypeError, ValueError, TclError),
                          tcl.getint, '42\0')
        if test_support.have_unicode:
            self.assertEqual(tcl.getint(unicode('42')), 42)
            self.assertRaises((UnicodeEncodeError, ValueError, TclError),
                              tcl.getint, '42' + unichr(0xd800)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_tcl.py

示例2: test_getboolean

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def test_getboolean(self):
        tcl = self.interp.tk
        self.assertIs(tcl.getboolean('on'), True)
        self.assertIs(tcl.getboolean('1'), True)
        self.assertIs(tcl.getboolean(u'on'), True)
        self.assertIs(tcl.getboolean(u'1'), True)
        self.assertIs(tcl.getboolean(42), True)
        self.assertIs(tcl.getboolean(0), False)
        self.assertIs(tcl.getboolean(42L), True)
        self.assertIs(tcl.getboolean(0L), False)
        self.assertRaises(TypeError, tcl.getboolean)
        self.assertRaises(TypeError, tcl.getboolean, 'on', '1')
        self.assertRaises(TypeError, tcl.getboolean, 1.0)
        self.assertRaises(TclError, tcl.getboolean, 'a')
        self.assertRaises((TypeError, ValueError, TclError),
                          tcl.getboolean, 'on\0')
        if test_support.have_unicode:
            self.assertIs(tcl.getboolean(unicode('on')), True)
            self.assertRaises((UnicodeEncodeError, ValueError, TclError),
                              tcl.getboolean, 'on' + unichr(0xd800)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_tcl.py

示例3: test_compare

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def test_compare(self):
        compare = self.text.compare
        Equal = self.assertEqual
        # need data so indexes not squished to 1,0
        self.text.insert('1.0', 'First\nSecond\nThird\n')

        self.assertRaises(TclError, compare, '2.2', 'op', '2.2')

        for op, less1, less0, equal, greater0, greater1 in (
                ('<', True, True, False, False, False),
                ('<=', True, True, True, False, False),
                ('>', False, False, False, True, True),
                ('>=', False, False, True, True, True),
                ('==', False, False, True, False, False),
                ('!=', True, True, False, True, True),
                ):
            Equal(compare('1.1', op, '2.2'), less1, op)
            Equal(compare('2.1', op, '2.2'), less0, op)
            Equal(compare('2.2', op, '2.2'), equal, op)
            Equal(compare('2.3', op, '2.2'), greater0, op)
            Equal(compare('3.3', op, '2.2'), greater1, op) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:23,代码来源:test_text.py

示例4: compare

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def compare(self, index1, op, index2):
        line1, char1 = self._decode(index1)
        line2, char2 = self._decode(index2)
        if op == '<':
            return line1 < line2 or line1 == line2 and char1 < char2
        elif op == '<=':
            return line1 < line2 or line1 == line2 and char1 <= char2
        elif op == '>':
            return line1 > line2 or line1 == line2 and char1 > char2
        elif op == '>=':
            return line1 > line2 or line1 == line2 and char1 >= char2
        elif op == '==':
            return line1 == line2 and char1 == char2
        elif op == '!=':
            return line1 != line2 or  char1 != char2
        else:
            raise TclError('''bad comparison operator "%s":'''
                                  '''must be <, <=, ==, >=, >, or !=''' % op)

    # The following Text methods normally do something and return None.
    # Whether doing nothing is sufficient for a test will depend on the test. 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:23,代码来源:mock_tk.py

示例5: test_getint

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def test_getint(self):
        tcl = self.interp.tk
        for i in self.get_integers():
            self.assertEqual(tcl.getint(' %d ' % i), i)
            if tcl_version >= (8, 5):
                self.assertEqual(tcl.getint(' %#o ' % i), i)
            self.assertEqual(tcl.getint((' %#o ' % i).replace('o', '')), i)
            self.assertEqual(tcl.getint(' %#x ' % i), i)
        if tcl_version < (8, 5):  # bignum was added in Tcl 8.5
            self.assertRaises(TclError, tcl.getint, str(2**1000))
        self.assertEqual(tcl.getint(42), 42)
        self.assertRaises(TypeError, tcl.getint)
        self.assertRaises(TypeError, tcl.getint, '42', '10')
        self.assertRaises(TypeError, tcl.getint, b'42')
        self.assertRaises(TypeError, tcl.getint, 42.0)
        self.assertRaises(TclError, tcl.getint, 'a')
        self.assertRaises((TypeError, ValueError, TclError),
                          tcl.getint, '42\0')
        self.assertRaises((UnicodeEncodeError, ValueError, TclError),
                          tcl.getint, '42\ud800') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:22,代码来源:test_tcl.py

示例6: testEvalException

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def testEvalException(self):
        tcl = self.interp
        self.assertRaises(TclError,tcl.eval,'set a') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_tcl.py

示例7: testEvalException2

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def testEvalException2(self):
        tcl = self.interp
        self.assertRaises(TclError,tcl.eval,'this is wrong') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_tcl.py

示例8: testCallException

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def testCallException(self):
        tcl = self.interp
        self.assertRaises(TclError,tcl.call,'set','a') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_tcl.py

示例9: testCallException2

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def testCallException2(self):
        tcl = self.interp
        self.assertRaises(TclError,tcl.call,'this','is','wrong') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_tcl.py

示例10: testGetVarException

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def testGetVarException(self):
        tcl = self.interp
        self.assertRaises(TclError,tcl.getvar,'a') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_tcl.py

示例11: testUnsetVarException

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def testUnsetVarException(self):
        tcl = self.interp
        self.assertRaises(TclError,tcl.unsetvar,'a') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_tcl.py

示例12: test_getdouble

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def test_getdouble(self):
        tcl = self.interp.tk
        self.assertEqual(tcl.getdouble(' 42 '), 42.0)
        self.assertEqual(tcl.getdouble(' 42.5 '), 42.5)
        self.assertEqual(tcl.getdouble(42.5), 42.5)
        self.assertRaises(TypeError, tcl.getdouble)
        self.assertRaises(TypeError, tcl.getdouble, '42.5', '10')
        self.assertRaises(TypeError, tcl.getdouble, 42)
        self.assertRaises(TclError, tcl.getdouble, 'a')
        self.assertRaises((TypeError, ValueError, TclError),
                          tcl.getdouble, '42.5\0')
        if test_support.have_unicode:
            self.assertEqual(tcl.getdouble(unicode('42.5')), 42.5)
            self.assertRaises((UnicodeEncodeError, ValueError, TclError),
                              tcl.getdouble, '42.5' + unichr(0xd800)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_tcl.py

示例13: testPackageRequireException

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def testPackageRequireException(self):
        tcl = self.interp
        self.assertRaises(TclError,tcl.eval,'package require DNE') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_tcl.py

示例14: test_exprdouble

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def test_exprdouble(self):
        tcl = self.interp
        tcl.call('set', 'a', 3)
        tcl.call('set', 'b', 6)
        def check(expr, expected):
            result = tcl.exprdouble(expr)
            self.assertEqual(result, expected)
            self.assertIsInstance(result, float)

        self.assertRaises(TypeError, tcl.exprdouble)
        self.assertRaises(TypeError, tcl.exprdouble, '8.2', '+6')
        self.assertRaises(TclError, tcl.exprdouble, 'spam')
        check('', 0.0)
        check('8.2 + 6', 14.2)
        check('3.1 + $a', 6.1)
        check('2 + "$a.$b"', 5.6)
        check('4*[llength "6 2"]', 8.0)
        check('{word one} < "word $a"', 0.0)
        check('4*2 < 7', 0.0)
        check('hypot($a, 4)', 5.0)
        check('5 / 4', 1.0)
        check('5 / 4.0', 1.25)
        check('5 / ( [string length "abcd"] + 0.0 )', 1.25)
        check('20.0/5.0', 4.0)
        check('"0x03" > "2"', 1.0)
        check('[string length "a\xc2\xbd\xe2\x82\xac"]', 3.0)
        check(r'[string length "a\xbd\u20ac"]', 3.0)
        self.assertRaises(TclError, tcl.exprdouble, '"abc"')
        if tcl_version >= (8, 5):  # bignum was added in Tcl 8.5
            check('2**64', float(2**64)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:32,代码来源:test_tcl.py

示例15: test_exprlong

# 需要导入模块: import _tkinter [as 别名]
# 或者: from _tkinter import TclError [as 别名]
def test_exprlong(self):
        tcl = self.interp
        tcl.call('set', 'a', 3)
        tcl.call('set', 'b', 6)
        def check(expr, expected):
            result = tcl.exprlong(expr)
            self.assertEqual(result, expected)
            self.assertIsInstance(result, int)

        self.assertRaises(TypeError, tcl.exprlong)
        self.assertRaises(TypeError, tcl.exprlong, '8.2', '+6')
        self.assertRaises(TclError, tcl.exprlong, 'spam')
        check('', 0)
        check('8.2 + 6', 14)
        check('3.1 + $a', 6)
        check('2 + "$a.$b"', 5)
        check('4*[llength "6 2"]', 8)
        check('{word one} < "word $a"', 0)
        check('4*2 < 7', 0)
        check('hypot($a, 4)', 5)
        check('5 / 4', 1)
        check('5 / 4.0', 1)
        check('5 / ( [string length "abcd"] + 0.0 )', 1)
        check('20.0/5.0', 4)
        check('"0x03" > "2"', 1)
        check('[string length "a\xc2\xbd\xe2\x82\xac"]', 3)
        check(r'[string length "a\xbd\u20ac"]', 3)
        self.assertRaises(TclError, tcl.exprlong, '"abc"')
        if tcl_version >= (8, 5):  # bignum was added in Tcl 8.5
            self.assertRaises(TclError, tcl.exprlong, '2**64') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:32,代码来源:test_tcl.py


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