Author: Alex Gaynor <alex.gay...@gmail.com>
Branch: stdlib-2.7.8
Changeset: r73020:9cfd18fbf13f
Date: 2014-08-23 18:29 -0700
http://bitbucket.org/pypy/pypy/changeset/9cfd18fbf13f/

Log:    Some missing methods on tkapp

diff --git a/lib_pypy/_tkinter/app.py b/lib_pypy/_tkinter/app.py
--- a/lib_pypy/_tkinter/app.py
+++ b/lib_pypy/_tkinter/app.py
@@ -438,10 +438,41 @@
     def getboolean(self, s):
         if isinstance(s, int):
             return s
+        if isinstance(s, unicode):
+            s = str(s)
+        if '\x00' in s:
+            raise TypeError
         v = tkffi.new("int*")
         res = tklib.Tcl_GetBoolean(self.interp, s, v)
         if res == tklib.TCL_ERROR:
             self.raiseTclError()
+        return bool(v[0])
+
+    def getint(self, s):
+        if isinstance(s, int):
+            return s
+        if isinstance(s, unicode):
+            s = str(s)
+        if '\x00' in s:
+            raise TypeError
+        v = tkffi.new("int*")
+        res = tklib.Tcl_GetInt(self.interp, s, v)
+        if res == tklib.TCL_ERROR:
+            self.raiseTclError()
+        return v[0]
+
+    def getdouble(self, s):
+        if isinstance(s, float):
+            return s
+        if isinstance(s, unicode):
+            s = str(s)
+        if '\x00' in s:
+            raise TypeError
+        v = tkffi.new("double*")
+        res = tklib.Tcl_GetDouble(self.interp, s, v)
+        if res == tklib.TCL_ERROR:
+            self.raiseTclError()
+        return v[0]
 
     def mainloop(self, threshold):
         self._check_tcl_appartment()
diff --git a/lib_pypy/_tkinter/tklib.py b/lib_pypy/_tkinter/tklib.py
--- a/lib_pypy/_tkinter/tklib.py
+++ b/lib_pypy/_tkinter/tklib.py
@@ -70,6 +70,8 @@
 void Tcl_DecrRefCount(Tcl_Obj* objPtr);
 
 int Tcl_GetBoolean(Tcl_Interp* interp, const char* src, int* boolPtr);
+int Tcl_GetInt(Tcl_Interp* interp, const char* src, int* intPtr);
+int Tcl_GetDouble(Tcl_Interp* interp, const char* src, double* doublePtr);
 char *Tcl_GetString(Tcl_Obj* objPtr);
 char *Tcl_GetStringFromObj(Tcl_Obj* objPtr, int* lengthPtr);
 unsigned char *Tcl_GetByteArrayFromObj(Tcl_Obj* objPtr, int* lengthPtr);
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to