diff options
author | kali <kali@leap.se> | 2013-01-31 05:26:18 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2013-01-31 05:30:28 +0900 |
commit | 555210630659018785fdb9d2318081a76b49fb4c (patch) | |
tree | df7a51aaa32d9436a86881f9815d66a0f28773a5 /src/leap/gui/utils.py | |
parent | 00276d12b44630315c19ff2cd0f906eac34d92cf (diff) |
actually merge the release/v0.2.0 branch!
My life has been a lie until this moment...
I had done:
git merge -s ours release/v0.2.0
to avoid deleting the debian folder...
but that left the src untouched...
Now I just rm'd the src folder and did a
git checkout release/v0.2.0 src/
... and merge happy! :)
Diffstat (limited to 'src/leap/gui/utils.py')
-rw-r--r-- | src/leap/gui/utils.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/leap/gui/utils.py b/src/leap/gui/utils.py new file mode 100644 index 00000000..f91ac3ef --- /dev/null +++ b/src/leap/gui/utils.py @@ -0,0 +1,34 @@ +""" +utility functions to work with gui objects +""" +from PyQt4 import QtCore + + +def layout_widgets(layout): + """ + return a generator with all widgets in a layout + """ + return (layout.itemAt(i) for i in range(layout.count())) + + +DELAY_MSECS = 50 + + +def delay(obj, method_str=None, call_args=None): + """ + Triggers a function or slot with a small delay. + this is a mainly a hack to get responsiveness in the ui + in cases in which the event loop freezes and the task + is not heavy enough to setup a processing queue. + """ + if callable(obj) and not method_str: + fun = lambda: obj() + + if method_str: + invoke = QtCore.QMetaObject.invokeMethod + if call_args: + fun = lambda: invoke(obj, method_str, call_args) + else: + fun = lambda: invoke(obj, method_str) + + QtCore.QTimer().singleShot(DELAY_MSECS, fun) |