From 6032f776cabcd04aa7f4e1f55a34ecfec2775e85 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 7 Nov 2012 04:48:12 +0900 Subject: changes to update_signal + Fix update + Rename + Changed signature (we update progress bar from slot now) --- src/leap/gui/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/leap/gui/utils.py (limited to 'src/leap/gui/utils.py') diff --git a/src/leap/gui/utils.py b/src/leap/gui/utils.py new file mode 100644 index 00000000..8b1e3630 --- /dev/null +++ b/src/leap/gui/utils.py @@ -0,0 +1,10 @@ +""" +utility functions to work with gui objects +""" + + +def layout_widgets(layout): + """ + return a generator with all widgets in a layout + """ + return (layout.itemAt(i) for i in range(layout.count())) -- cgit v1.2.3 From eec567a0a26edddb30b15ea4ef67f042c160d5ba Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 28 Nov 2012 02:03:22 +0900 Subject: move delay function to gui/utils --- src/leap/gui/utils.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/leap/gui/utils.py') diff --git a/src/leap/gui/utils.py b/src/leap/gui/utils.py index 8b1e3630..f91ac3ef 100644 --- a/src/leap/gui/utils.py +++ b/src/leap/gui/utils.py @@ -1,6 +1,7 @@ """ utility functions to work with gui objects """ +from PyQt4 import QtCore def layout_widgets(layout): @@ -8,3 +9,26 @@ 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) -- cgit v1.2.3