473,385 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

tkinter entry/text widget

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"
Jul 18 '05 #1
3 9292
Tk Text widgets do not support indexes in the form of single integers,
since their internal representation is NOT a contiguous block of memory
(which would be horribly inefficient for insertions at the top of a
large document). Instead, you must use indexes of the form
"line.column", where line starts at 1, and column starts at 0. To get
the entire text, you'd use: .get("1.0", END) . Other allowed forms of
indexes are given in the documentation.
Jason Harper
Jul 18 '05 #2
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


Jul 18 '05 #3
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"


I was asking for it, I need a couple more months with the language before I
ask the silly newbie questions. I asked anyway.

--
Berlin Brown
bi*****@hotmail.com
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mickel Grönroos | last post by:
Hi, I'm trying to put an Tkinter.Entry of fixed size onto a specific location on a canvas using the place manager. The idea is that one can double-click a rectangle object on a canvas to get an...
3
by: Phil Schmidt | last post by:
I'm trying to make a custom entry widget, as in the code that follows. There are two problems I'm trying to fix: 1) I would like the widget to behave as myEntry.Escape() does now, except that it...
6
by: Elaine Jackson | last post by:
I've got a script where a button gets pushed over and over: to cut down on the carpal tunnel syndrome I'd like to have the button respond to presses of the Enter key as well as mouse clicks; can...
7
by: William Gill | last post by:
Is there a simple way to cut and paste from a tkinter text widget to an entry widget? I know I could create a mouse button event that triggers a popup (message widget) prompting for cut/paste in...
3
by: Matt Hammond | last post by:
Here's a strange one in Tkinter that has me stumped: (I'm running python 2.4 on Suse Linux 9.3 64bit) I'm trying to make a set of Entry widgets with Label widgets to the left of each one, using...
8
by: Dustan | last post by:
I'm trying to get a scrollbar bound with a Frame, and I keep on getting a scrollbar, but it doesn't actually scroll. Some help, please?
8
by: Lie | last post by:
Inspect the following code: --- start of code --- import Tkinter as Tk from Tkconstants import * root = Tk.Tk() e1 = Tk.Entry(root, text = 'Hello World') e2 = Tk.Entry(root, text = 'Hello...
0
by: John McMoangle | last post by:
Hey guys. I am having trouble understanding the get() method from The arguments to the get method of the Text widget are strings in the form of "line.position". So, text.get('1.5', '2.7')...
0
by: Leonhard Vogt | last post by:
Hello I have the following problem in Python 2.5 on Windows XP. On Ubuntu I do not see the problem. I have a Tkinter application as in the following example The entry-widget is somehow...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.