TkPhotoImage data-option

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

TkPhotoImage data-option

shoz
Hello, Developers

I modified Tkinter on Python 2.7 and use it every time.
Because original Tkinter dosen't execute the following code well:

f = open("apple.ppm", "rb")
pho = Tk.PhotoImage(data=f.read())

I found out what is wrong in Tkinter implement and fixed it.
That is:

*** org/_tkinter.c
--- new/_tkinter.c
***************
*** 947,954 ****
Tcl_Obj *result;

if (PyString_Check(value))
! return Tcl_NewStringObj(PyString_AS_STRING(value),
PyString_GET_SIZE(value));
else if (PyBool_Check(value))
return Tcl_NewBooleanObj(PyObject_IsTrue(value));
else if (PyInt_Check(value))
--- 947,954 ----
Tcl_Obj *result;

if (PyString_Check(value))
! return Tcl_NewByteArrayObj(PyString_AS_STRING(value),
PyString_GET_SIZE(value));
else if (PyBool_Check(value))
return Tcl_NewBooleanObj(PyObject_IsTrue(value));
else if (PyInt_Check(value))

The reason seems that Tcl_NewStringObj() expects UTF-8 string as input
but PyString_AS_STRING() returns ascii string.

Dose anyone verify whether my fixed code is correct or not.

Best regards.
Shozo

_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Loading...