tkinter entry/text widget

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Mon Mar 15 20:58:24 CET 2004


bigbinc wrote:
> I have used the 'entry' tk widget to get text values, I am now using
> 'Text' but I cant seem to use 'get' method.  The TK docs say use
> get(index1, index2), I tried numbers and get an error
> 
> 
> print self.textMain.get(1,255)
> 
> ceback (most recent call last):
> ile "C:\Python23\lib\lib-tk\Tkinter.py", line 1345, in __call
>  return self.func(*args)
> ile "blog.py", line 60, in saveFile
>  print self.textMain.get("1","255")
> ile "C:\Python23\lib\lib-tk\Tkinter.py", line 2868, in get
>  return self.tk.call(self._w, 'get', index1, index2)
> Error: bad text index "1"

You should go get the Tk command reference OK it's not written in 
'Python' but it's still easy to translate.
Download a HTML version from here:--

http://www.tcl.tk/man/

The Exact reference for this problem would be :-

http://www.tcl.tk/man/tcl8.4/TkCmd/text.htm#M18

'Text widget INDICES'

It boils down to passing strings to the .get() method like so:-

myTextWidget.get("0.0", "end")

will get all the text in the Text widget.


HTH
Martin











More information about the Python-list mailing list