Skip to content

Commit 32e62a0

Browse files
RachidaTanassathorakivo
authored andcommitted
Add support for tkinter
1 parent 4377f00 commit 32e62a0

File tree

4 files changed

+1130
-0
lines changed

4 files changed

+1130
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 PyPy which itself is based on cffi, and is a translation of _tkinter.c
6+
# from CPython, version 2.7.4.
7+
8+
import sys
9+
10+
class TclError(Exception):
11+
pass
12+
13+
from .tklib_cffi import ffi as tkffi, lib as tklib
14+
15+
from .app import TkApp
16+
from .tclobj import TclObject as Tcl_Obj
17+
from .app import FromTclString, ToTCLString
18+
19+
TK_VERSION = FromTclString(tkffi.string(tklib.get_tk_version()))
20+
TCL_VERSION = FromTclString(tkffi.string(tklib.get_tcl_version()))
21+
22+
READABLE = tklib.TCL_READABLE
23+
WRITABLE = tklib.TCL_WRITABLE
24+
EXCEPTION = tklib.TCL_EXCEPTION
25+
DONT_WAIT = tklib.TCL_DONT_WAIT
26+
27+
def create(screenName=None, baseName=None, className=None,
28+
interactive=False, wantobjects=False, wantTk=True,
29+
sync=False, use=None):
30+
return TkApp(screenName, baseName, className,
31+
interactive, wantobjects, wantTk, sync, use)
32+
33+
def dooneevent(flags=0):
34+
return tklib.Tcl_DoOneEvent(flags)
35+
36+
37+
def _flatten(item):
38+
def _flatten1(output, item, depth):
39+
if depth > 1000:
40+
raise ValueError("nesting too deep in _flatten")
41+
if not isinstance(item, (list, tuple)):
42+
raise TypeError("argument must be sequence")
43+
# copy items to output tuple
44+
for o in item:
45+
if isinstance(o, (list, tuple)):
46+
_flatten1(output, o, depth + 1)
47+
elif o is not None:
48+
output.append(o)
49+
50+
result = []
51+
_flatten1(result, item, 0)
52+
return tuple(result)
53+
54+
# Encoding is not specified explicitly, but "must be passed argv[0]" sounds like a simple conversion to raw bytes.
55+
tklib.Tcl_FindExecutable(ToTCLString(sys.executable))

0 commit comments

Comments
 (0)