Selection in Tkinter Text widget.

Ant antroy at gmail.com
Fri Jun 2 07:08:03 EDT 2006


Hi all,

I have been trying to select text in a Text widget programmatically. I
have been trying the following minimal example:
#=================================
from Tkinter import *

def showgui():
    win = Tk()

    area = Text(win, width = 50, height = 20)
    area.pack()

    new = """Lots of text here
    and here
    and here..."""
    area.insert("1.0", new)

    area.tag_add(SEL, "1.0", END)

    win.mainloop()

if __name__ == "__main__":
    showgui()
#==================================

The area.tag_add(...) line should - from what I have read in Frederik's
Intro to Tkinter guide - select all of the text in the text area. It
doesn't however...

Does anyone have any idea how to get this to work? Or tell me what I am
doing wrong.

Cheers,

-- 
Ant...




More information about the Python-list mailing list