Mailing List Archive

Tkinter and fileevent
I'm using Python 1.5.2.

Does Tkinter provide an interface to Tcl's `fileevent' mechanism? I
couldn't find this anywhere in the Tkinter documentation or examples.

If `fileevent' is indeed accessible via Tkinter, could someone point me
to some docs or examples where this is used?

Thanks in advance.

--
Lloyd Zusman
ljz@asfast.com
Tkinter and fileevent [ In reply to ]
On 2 May 1999, Lloyd Zusman wrote:

> Does Tkinter provide an interface to Tcl's `fileevent' mechanism? I
> couldn't find this anywhere in the Tkinter documentation or examples.
>
> If `fileevent' is indeed accessible via Tkinter, could someone point me
> to some docs or examples where this is used?

I had to ask a similar question some weeks ago. It would be nice to have
some more documentations on features like that to help newbies like us.
Here's a small working example that uses filehandler:

#---snip---
import sys
import Tkinter
import tkMessageBox

root = Tkinter.Tk()

def stdin_handler(file, mask):
root.tk.deletefilehandler(file)
if not tkMessageBox.askokcancel("Go on?", file.readline()):
root.destroy()
root.tk.createfilehandler(file, mask, stdin_handler)

root.tk.createfilehandler(sys.stdin, Tkinter.READABLE, stdin_handler)

root.mainloop()
#---snap---

Olaf