On Sun, 16 Nov 2008 19:21:34 -0200 "Guilherme Polo" <[EMAIL PROTECTED]> wrote:
> On Sun, Nov 16, 2008 at 6:59 PM, Michael Lange <[EMAIL PROTECTED]> wrote: > > On Sun, 16 Nov 2008 17:18:54 -0200 > > "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > > > >> On Sun, Nov 16, 2008 at 4:59 PM, Vasilis Vlachoudis > >> <[EMAIL PROTECTED]> wrote: > >> > Finally I didn't understand, is it a problem of Tkinter or Tk/Tcl? > >> > >> It is not really a problem. But if you want to blame someone, go for > >> Python then. > >> > > > > If you get unexpected and , if the software you write is supposed to run on > > different platforms, also unpredictable behavior like this I think it *is* a > > problem. > > I meant more in these sense of the conversion raising some exception, > but it can be seen in that way too sure. But this doesn't depend on > the platform, all them will show this behaviour. > O.k., by "platform" I actually meant different linux / unix systems with different versions of Python / Tk installed. (...) > > Good for you then :) > It gets hard to continue arguing about this now, since you apparently > solved the question on your side and thus won't have real examples of > this problem, and why it couldn't be solved, anymore (or maybe you do, > so we can continue on this). Using Tk-8.5 it is not too hard to find examples: >>> from Tkinter import * >>> root = Tk() >>> t = Text(root) >>> t.pack() >>> t.insert('end', 'foobar') >>> i = t.index('end') >>> i <textindex object at 0x81e0ba8> >>> print i 2.0 >>> int(i) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: int() argument must be a string or a number, not '_tkinter.Tcl_Obj' >>> str(i) '2.0' > > > The problem is that you never seem > > to know where the TclObjects appear on Python / Tk versions other than your > > own. > > So what else to do? Convert everything Tk returns to string? > > No, like I said, who calls into _tkinter should know what kind of > object to expect so you do the conversion yourself. If you are going > to return the object to the user, then surely check if it is what you > are expecting it to be. > > Now, I'm sure this can be improved in Python but you have to invest > some time on it. So you mean, the only option to fix this is to write patches for Tkinter.py, resp. the other modules in lib-tk, so the return values of "broken" methods are converted from TclObjects into string (or whatever seems adequate)? Michael _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss