473,804 Members | 3,802 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.g et(1,255)

ceback (most recent call last):
ile "C:\Python23\li b\lib-tk\Tkinter.py", line 1345, in __call
return self.func(*args )
ile "blog.py", line 60, in saveFile
print self.textMain.g et("1","255")
ile "C:\Python23\li b\lib-tk\Tkinter.py", line 2868, in get
return self.tk.call(se lf._w, 'get', index1, index2)
Error: bad text index "1"
Jul 18 '05 #1
3 9566
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.colum n", 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.g et(1,255)

ceback (most recent call last):
ile "C:\Python23\li b\lib-tk\Tkinter.py", line 1345, in __call
return self.func(*args )
ile "blog.py", line 60, in saveFile
print self.textMain.g et("1","255")
ile "C:\Python23\li b\lib-tk\Tkinter.py", line 2868, in get
return self.tk.call(se lf._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.ge t("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.g et(1,255)

ceback (most recent call last):
ile "C:\Python23\li b\lib-tk\Tkinter.py", line 1345, in __call
return self.func(*args )
ile "blog.py", line 60, in saveFile
print self.textMain.g et("1","255")
ile "C:\Python23\li b\lib-tk\Tkinter.py", line 2868, in get
return self.tk.call(se lf._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
2211
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 entry field of the same size as the rectangle placed exactly over the rectangle thus creating the effect that the rectangle has entered "input mode". When clicking return in the entry field, the value is fed back to a text object within the...
3
4940
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 happens on loss of focus, not when pressing Esc. 2) TABbing between multiple entry fields does undesired things with the selection, and with cursor placement. Can anyone offer any suggestions for how to fix this? I'm attemting to
6
6089
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 somebody clue me in regarding how this is done? Muchas gracias. Peace
7
18042
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 each of the widgets using a temp variable to hold the text, but I don't wnat to reinvent the wheel if there already is something that does the job. Thanks, Bill
3
2151
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 the grid layout. If I make and grid the Label *before* the Entry then the Entry widget doesn't seem to work - it lets me put the cursor in it, but I can't type! See example code below. Is this just me doing something really really silly, or is...
8
12043
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
2030
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 World')
0
1603
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') returns the text from line 1 position 5 to line 2 position 7. There are also some special tagged names such as END and SEL.
0
1515
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 blocked (i cannot type characters into it) when I call askopenfilename before I create the widget. Calling askopenfile again (by clicking the button) releases the block, I can type into the entry as expected.
0
9577
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10315
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9140
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.