The only way I know of to do this is to use "after" to invoke a function which does the 
file checking and whatever else is required. That function sets another "after" - with 
perhaps a one second delay or whatever seems appropriate - to invoke itself. Thus the function is 
invoked repeatedly to keep track of the file. It isn't pretty but it works.

Cam Farnell

O'Gorman, Lawrence (Larry) wrote:
I’m trying to figure out if Python and Tkinter can offer a solution to my following problem. I want to monitor a file and when that file is changed, I want to detect that event and have my window change its text from “File Unchanged” to “File has Changed.”

That is, I can produce a function to periodically sample the modification time of a file and if it is different than my last sample time, then this function will return an indication that the file is changed. I want this file-change event to be captured by the tkinit mainloop(), which I will then use to change the appearance of my window.

I understand that any GUI event (mouse, keyboard, etc.) can be detected in the mainloop(), but I have seen no indication in the documentation and discussions that a file-change can produce an event that can be detected in the mainloop(). Does anyone know if I can do this? If so, how? Or, if there is an alternative way than mainloop() to get a window to change upon a file-change, that would be helpful, too.
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to