Tkinter problem

Newt newt_e at blueyonder.co.uk
Fri May 16 05:29:06 EDT 2003


I've got a Label, created like:

        self.sp = Label(self.sel_s, text="")
        self.sp.grid(row=4, col=3)

I can change the text using:

        self.sp.configure(text='Something else')

I can conditionally test the text in the label using

        if self.sp['text'] == "" :

but how do I get the text data out again? I've tried the following ways:

        sp = self.sp.cget('text')
        sp = self.sp.cget(text)
        sp = self.sp['text']

but all I get back are errors similar to the below (that ones for sp =
self.sp['text'] ):

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python22\lib\lib-tk\Tkinter.py", line 1292, in __call__
    return apply(self.func, args)
  File "D:\py_stuff\curry.py", line 14, in __call__
    return self.fun(*(self.pending + args), **kw)
  File "D:\py_stuff\hometown.py", line 121, in bexit
    sp = self.sp['text']
  File "C:\Python22\lib\lib-tk\Tkinter.py", line 1090, in cget
    return self.tk.call(self._w, 'cget', '-' + key)
TclError: invalid command name ".9722920.9736352"

I'm kinda confused as to what's going on. Any suggestions would be useful.

TIA
Newt






More information about the Python-list mailing list