Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to move insert to position in Text widget (Tkinter)

Reply
Thread Tools

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

 
 
Harlin Seritt
Guest
Posts: n/a
 
      03-25-2005
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.search(findString.get(), 1.0,
stopindex=END)
if not pos:
break

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

thanks,

Harlin Seritt

 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      03-25-2005
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_remove(SEL, 1.0, END)

</F>



 
Reply With Quote
 
 
 
 
Harlin Seritt
Guest
Posts: n/a
 
      03-25-2005
Frederik,

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

Cheers,

Harlin

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: Tkinter.Text widget - how to get text cursor position? Alex9968 Python 0 03-19-2008 07:07 PM
Tkinter.Text widget - how to get text cursor position? Alex9968 Python 0 03-19-2008 05:37 PM
Tkinter Text widget - insert line beps Python 0 11-21-2004 10:02 PM
[PYGTK] Insert Backspace into text widget? Dennis Craven Python 3 05-17-2004 10:00 PM



Advertisments