migrate snippets from gitlab
This commit is contained in:
24
tk_task_wrapper.py
Normal file
24
tk_task_wrapper.py
Normal 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
|
||||
Reference in New Issue
Block a user