當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。