explain the sleep
This commit is contained in:
@@ -26,14 +26,16 @@ import threading
|
|||||||
|
|
||||||
|
|
||||||
class FileObserver(FileSystemEventHandler):
|
class FileObserver(FileSystemEventHandler):
|
||||||
counter = 0
|
|
||||||
def __init__(self, big_text):
|
def __init__(self, big_text):
|
||||||
super(FileObserver, self).__init__()
|
super(FileObserver, self).__init__()
|
||||||
self.big_text = big_text
|
self.big_text = big_text
|
||||||
|
|
||||||
def on_modified(self, event):
|
def on_modified(self, event):
|
||||||
#print("file modified ", self.counter," ", time.time())
|
# slow down the updates. This is needed, because the file is modified
|
||||||
self.counter+=1
|
# constantly, which would lead to constant re-rendering, which would
|
||||||
|
# block the UI thread an make the UI unresponsive.
|
||||||
|
# Note: we don't miss events, because they are queued and de-duplicated
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
self.big_text.update()
|
self.big_text.update()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user