migrate snippets from gitlab

This commit is contained in:
Andreas Balogh
2024-03-14 22:17:41 +01:00
commit 5744a6efa9
5 changed files with 132 additions and 0 deletions

24
tk_task_wrapper.py Normal file
View File

@@ -0,0 +1,24 @@
def long_running_task(status):
" status decorator "
def lrt_decorator(func):
def lrt_wrapper(*args, **kwargs):
self = args[0]
self.lb12["text"] = status
self.bu10.state(['disabled'])
self.bu11.state(['disabled'])
self.update_idletasks()
try:
rc = func(*args, **kwargs)
finally:
# make sure GUI unlocks even after exception
self.lb12["text"] = "Ready."
self.bu10.state(['!disabled'])
self.bu11.state(['!disabled'])
self.update_idletasks()
return rc
return lrt_wrapper
return lrt_decorator