From b8f35aafadd996baf7592abcea5c4d706538cbe2 Mon Sep 17 00:00:00 2001 From: Axel Svensson Date: Tue, 12 Oct 2021 16:22:46 +0200 Subject: [PATCH] Throttle GUI updates --- pdf-sign | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pdf-sign b/pdf-sign index c0532dc..df2fa7f 100755 --- a/pdf-sign +++ b/pdf-sign @@ -225,6 +225,7 @@ def main(args): @Cell def updateTitle(): root.title(f'Signing page {pageNumber()}/{pageCount} of {filePath}') + @tkthrottle(100, root) def update(): (w, h) = displaySize() root._docImg = tk.PhotoImage(file=displayPNG()) @@ -308,6 +309,27 @@ class Cell(): d.dirty() self._dependents=[] +def tkthrottle(frequency, root): + wait=1/frequency + now=lambda: time.time() + def decorator(fn): + def throttled(): + if(throttled._suppressUntil