summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-03-17 16:21:33 (GMT)
committerGuido van Rossum <guido@python.org>1995-03-17 16:21:33 (GMT)
commit7e9394ab9722001789a35798ab8950e7a2b0a752 (patch)
tree88b5c6f8f4ba71e4cc65db6c04d802ddacb4eace /Lib
parent470be14c8aa23a35a1f4d1f1260a66a85d3f3cd9 (diff)
downloadcpython-7e9394ab9722001789a35798ab8950e7a2b0a752.zip
cpython-7e9394ab9722001789a35798ab8950e7a2b0a752.tar.gz
cpython-7e9394ab9722001789a35798ab8950e7a2b0a752.tar.bz2
add TkVersion,TclVersion; don't drop in debugger
Diffstat (limited to 'Lib')
-rw-r--r--Lib/lib-tk/Tkinter.py62
-rwxr-xr-xLib/tkinter/Tkinter.py62
2 files changed, 40 insertions, 84 deletions
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index 05e94e5..0af4bce 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -2,22 +2,20 @@
import tkinter
from tkinter import TclError
+from types import *
+CallableTypes = (FunctionType, MethodType,
+ BuiltinFunctionType, BuiltinMethodType,
+ ClassType, InstanceType)
-class _Dummy:
- def meth(self): return
-
-def _func():
- pass
-
-FunctionType = type(_func)
-ClassType = type(_Dummy)
-MethodType = type(_Dummy.meth)
-StringType = type('')
-TupleType = type(())
-ListType = type([])
-DictionaryType = type({})
-NoneType = type(None)
-CallableTypes = (FunctionType, MethodType)
+# Older versions of tkinter don't define these variables
+try:
+ TkVersion = eval(tkinter.TK_VERSION)
+except AttributeError:
+ TkVersion = 3.6
+try:
+ TclVersion = eval(tkinter.TCL_VERSION)
+except AttributeError:
+ TclVersion = 7.3
def _flatten(tuple):
res = ()
@@ -347,10 +345,10 @@ class Misc:
self.tk.quit()
def _getints(self, string):
if not string: return None
- res = ()
- for v in self.tk.splitlist(string):
- res = res + (self.tk.getint(v),)
- return res
+ return tuple(map(self.tk.getint, self.tk.splitlist(string)))
+ def _getdoubles(self, string):
+ if not string: return None
+ return tuple(map(self.tk.getdouble, self.tk.splitlist(string)))
def _getboolean(self, string):
if string:
return self.tk.getboolean(string)
@@ -438,29 +436,9 @@ class _CallSafely:
except SystemExit, msg:
raise SystemExit, msg
except:
- try:
- try:
- t = sys.exc_traceback
- while t:
- sys.stderr.write(
- ' %s, line %s\n' %
- (t.tb_frame.f_code,
- t.tb_lineno))
- t = t.tb_next
- finally:
- sys.stderr.write('%s: %s\n' %
- (sys.exc_type,
- sys.exc_value))
- (sys.last_type,
- sys.last_value,
- sys.last_traceback) = (sys.exc_type,
- sys.exc_value,
- sys.exc_traceback)
- import pdb
- pdb.pm()
- except:
- print '*** Error in error handling ***'
- print sys.exc_type, ':', sys.exc_value
+ import traceback
+ print "Exception in Tkinter callback"
+ traceback.print_exc()
class Wm:
def aspect(self,
diff --git a/Lib/tkinter/Tkinter.py b/Lib/tkinter/Tkinter.py
index 05e94e5..0af4bce 100755
--- a/Lib/tkinter/Tkinter.py
+++ b/Lib/tkinter/Tkinter.py
@@ -2,22 +2,20 @@
import tkinter
from tkinter import TclError
+from types import *
+CallableTypes = (FunctionType, MethodType,
+ BuiltinFunctionType, BuiltinMethodType,
+ ClassType, InstanceType)
-class _Dummy:
- def meth(self): return
-
-def _func():
- pass
-
-FunctionType = type(_func)
-ClassType = type(_Dummy)
-MethodType = type(_Dummy.meth)
-StringType = type('')
-TupleType = type(())
-ListType = type([])
-DictionaryType = type({})
-NoneType = type(None)
-CallableTypes = (FunctionType, MethodType)
+# Older versions of tkinter don't define these variables
+try:
+ TkVersion = eval(tkinter.TK_VERSION)
+except AttributeError:
+ TkVersion = 3.6
+try:
+ TclVersion = eval(tkinter.TCL_VERSION)
+except AttributeError:
+ TclVersion = 7.3
def _flatten(tuple):
res = ()
@@ -347,10 +345,10 @@ class Misc:
self.tk.quit()
def _getints(self, string):
if not string: return None
- res = ()
- for v in self.tk.splitlist(string):
- res = res + (self.tk.getint(v),)
- return res
+ return tuple(map(self.tk.getint, self.tk.splitlist(string)))
+ def _getdoubles(self, string):
+ if not string: return None
+ return tuple(map(self.tk.getdouble, self.tk.splitlist(string)))
def _getboolean(self, string):
if string:
return self.tk.getboolean(string)
@@ -438,29 +436,9 @@ class _CallSafely:
except SystemExit, msg:
raise SystemExit, msg
except:
- try:
- try:
- t = sys.exc_traceback
- while t:
- sys.stderr.write(
- ' %s, line %s\n' %
- (t.tb_frame.f_code,
- t.tb_lineno))
- t = t.tb_next
- finally:
- sys.stderr.write('%s: %s\n' %
- (sys.exc_type,
- sys.exc_value))
- (sys.last_type,
- sys.last_value,
- sys.last_traceback) = (sys.exc_type,
- sys.exc_value,
- sys.exc_traceback)
- import pdb
- pdb.pm()
- except:
- print '*** Error in error handling ***'
- print sys.exc_type, ':', sys.exc_value
+ import traceback
+ print "Exception in Tkinter callback"
+ traceback.print_exc()
class Wm:
def aspect(self,