473,803 Members | 3,306 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to move insert to position in Text widget (Tkinter)

I am working on a Find Text dialog box. Once you find a string in a
Text widget, how do you at least move the cursor to that index
(position)? Even better how can one 'select' the string one finds?

---code---
def searchText():
while 1:
pos = self.mainEdit.s earch(findStrin g.get(), 1.0,
stopindex=END)
if not pos:
break

print pos
start = pos + "+1c"
break
---end code---

thanks,

Harlin Seritt

Jul 18 '05 #1
2 2822
Harlin Seritt wrote:
I am working on a Find Text dialog box. Once you find a string in a
Text widget, how do you at least move the cursor to that index
(position)?
widget.mark_set (INSERT, pos)
Even better how can one 'select' the string one finds?


widget.tag_add( SEL, pos, endpos)

to remove an existing selection, use

widget.tag_remo ve(SEL, 1.0, END)

</F>

Jul 18 '05 #2
Frederik,

Thanks! Just looking at your site (effbot and pythonware). I don't know
what I'd do without it!

Cheers,

Harlin

Jul 18 '05 #3

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

Similar topics

7
10711
by: Jane Austine | last post by:
As you add more items, say text lines, in Text widget, it gets too slow and almost impractical to use on. Take idle for example. If the text gets bigger(e.g. print urllib.urlopen('http://www.amazon.com').read() ), it becomes too sluggish to use as an "interactive" shell. I have tried wxPython and it seems to have the same problem (from my experience using PyCrust). Is there any way to speed up Text widget, or should I look for another
2
2956
by: Harry Pehkonen | last post by:
While setting up some unit tests, I came to the conclusion that a Tkinter Text widget can never be empty, but will always (?) contain a \n. Here is a brief example: >>> import Tkinter >>> t = Tkinter.Text() >>> t.get(0.0, Tkinter.END) '\n' >>> t.delete(0.0, Tkinter.END) >>> t.get(0.0, Tkinter.END)
3
9564
by: bigbinc | last post by:
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)
3
2380
by: Matthias | last post by:
Hello, I have a Canvas-Widget and will use as a "array of pixel". At Positon x,y I print a rectangle with a special color. I give the rectangle no objectname. Then I will ask the "root-Canvas-Widget" for the color in position x,y like: color=cw.cget('bg',x,y) I need HELP :))
8
11448
by: James Stroud | last post by:
Hello All, I would like for a tkinter text widget to be aware of how big the frame that contains it is, then I would like for it to reset its width to the appropriate number of characters when this frame changes size. I can get a cget("width") for the text, but this does not dynamically reflect the visible width. One way I can think of is getting the size of the font used in the widget then
7
18039
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
4
11574
by: sullivanz.pku | last post by:
Hi all I am using the standard python GUI Tkinter as my program's main interface. Although I know wxPython has some widget to support rich text widget, but I do not have time to shift to wx---- series. Does anyone know any Tkinter based widget that support: 1. Blod, Italic, Underline and their combinations. 2. Several most commonly used fonts, like Times New Roman and Arial 3. Multiline text 4. Cross platform support. Available in...
4
2193
by: Jay | last post by:
This may be really obscure, but I had a dream about programming something like this, so don't blame me. Is it possible to take a small image or icon and display it as a character in a Tk text box? Think how Thunderbird displays text smilies as actual smiley icons. Or how in AIM as you type a smiley, it replaces it with the picture. Does anyone know how to display these specifically in a Tk text box? Thanks.
4
5451
by: BartlebyScrivener | last post by:
Using Python on Debian Etch. What is the best way to paste a block of text in at the command prompt. I'm trying something like: Quote = raw_input("Paste quote here: ") Which works great for one line of text with a single newline. It gets
0
9700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
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
10546
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9121
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
7603
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
6841
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
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2970
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.