Tkinter: focus/text selection problem with tkFileDialog

Irmen de Jong irmen at -nospam-remove-this-xs4all.nl
Fri Apr 30 09:51:40 EDT 2004


Hi,
I'm having trouble with the code below.
It's just a regular Tk text widget in which you can type and
select text as expected, however the call to tkFileDialog.askopenfilename()
seems to screw things up. After the file dialog, I can no longer use
the Text widget (typing, selecting, it doesn't work anymore!)
What am I doing wrong?

TIA,
--Irmen de Jong


-----test.py----
import Tkinter, tkFileDialog

window=Tkinter.Tk()
txt=Tkinter.Text(window)
txt.insert(Tkinter.END,"Choose a file, then try to select me")
txt.pack()

name=tkFileDialog.askopenfilename()
txt.insert(Tkinter.END,"\nFile chosen: "+name)
window.mainloop()



More information about the Python-list mailing list