By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,551 Members | 1,127 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,551 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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>

Jul 18 '05 #2

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.