Debian Codegraph @

lib_pypy/_tkinter/__init__.py

raw symbols SCIP
1 # _tkinter package -- low-level interface to libtk and libtcl.
2 #
3 # This is an internal module, applications should "import Tkinter" instead.
4 #
5 # This version is based on cffi, and is a translation of _tkinter.c
6 # from CPython, version 2.7.4.
7
8 import os
9 import sys
10
11 class TclError(Exception):
12 pass
13
14 from .tklib_cffi import ffi as tkffi, lib as tklib
15
16 from .app import TkApp
17 from .tclobj import Tcl_Obj
18
19 TK_VERSION = tkffi.string(tklib.get_tk_version()).decode('utf-8')
20 TCL_VERSION = tkffi.string(tklib.get_tcl_version()).decode('utf-8')
21 TK_PATCH_LEVEL = tkffi.string(tklib.get_tk_patch_level()).decode('utf-8')
22 TCL_PATCH_LEVEL = tkffi.string(tklib.get_tcl_patch_level()).decode('utf-8')
23
24 READABLE = tklib.TCL_READABLE
25 WRITABLE = tklib.TCL_WRITABLE
26 EXCEPTION = tklib.TCL_EXCEPTION
27 DONT_WAIT = tklib.TCL_DONT_WAIT
28
29 def create(screenName=None, baseName=None, className=None,
30 interactive=False, wantobjects=False, wantTk=True,
31 sync=False, use=None):
32 return TkApp(screenName, className,
33 interactive, wantobjects, wantTk, sync, use)
34
35 def dooneevent(flags=0):
36 return tklib.Tcl_DoOneEvent(flags)
37
38
39 def _flatten(item):
40 def _flatten1(output, item, depth):
41 if depth > 1000:
42 raise ValueError("nesting too deep in _flatten")
43 if not isinstance(item, (list, tuple)):
44 raise TypeError("argument must be sequence")
45 # copy items to output tuple
46 for o in item:
47 if isinstance(o, (list, tuple)):
48 _flatten1(output, o, depth + 1)
49 elif o is not None:
50 output.append(o)
51
52 result = []
53 _flatten1(result, item, 0)
54 return tuple(result)
55
56
57 tklib.Tcl_FindExecutable(os.fsencode(sys.executable))