diff options
author | Picca Frédéric-Emmanuel <picca@debian.org> | 2018-03-04 10:20:27 +0100 |
---|---|---|
committer | Picca Frédéric-Emmanuel <picca@debian.org> | 2018-03-04 10:20:27 +0100 |
commit | 270d5ddc31c26b62379e3caa9044dd75ccc71847 (patch) | |
tree | 55c5bfc851dfce7172d335cd2405b214323e3caf /silx/gui/widgets | |
parent | e19c96eff0c310c06c4f268c8b80cb33bd08996f (diff) |
New upstream version 0.7.0+dfsg
Diffstat (limited to 'silx/gui/widgets')
-rw-r--r-- | silx/gui/widgets/FrameBrowser.py | 2 | ||||
-rw-r--r-- | silx/gui/widgets/MedianFilterDialog.py | 10 | ||||
-rw-r--r-- | silx/gui/widgets/PeriodicTable.py | 8 | ||||
-rw-r--r-- | silx/gui/widgets/PrintPreview.py | 4 | ||||
-rw-r--r-- | silx/gui/widgets/ThreadPoolPushButton.py | 11 | ||||
-rw-r--r-- | silx/gui/widgets/test/test_threadpoolpushbutton.py | 24 |
6 files changed, 35 insertions, 24 deletions
diff --git a/silx/gui/widgets/FrameBrowser.py b/silx/gui/widgets/FrameBrowser.py index 6737e9c..a8c0349 100644 --- a/silx/gui/widgets/FrameBrowser.py +++ b/silx/gui/widgets/FrameBrowser.py @@ -229,8 +229,6 @@ class HorizontalSliderWithBrowser(qt.QAbstractSlider): :param QWidget parent: Optional parent widget """ - sigIndexChanged = qt.pyqtSignal(object) - def __init__(self, parent=None): qt.QAbstractSlider.__init__(self, parent) self.setOrientation(qt.Qt.Horizontal) diff --git a/silx/gui/widgets/MedianFilterDialog.py b/silx/gui/widgets/MedianFilterDialog.py index 3eddff3..dd4a00d 100644 --- a/silx/gui/widgets/MedianFilterDialog.py +++ b/silx/gui/widgets/MedianFilterDialog.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2017 European Synchrotron Radiation Facility +# Copyright (c) 2017-2018 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -35,8 +35,14 @@ __authors__ = ["H. Payno"] __license__ = "MIT" __date__ = "14/02/2017" + +import logging + from silx.gui import qt + +_logger = logging.getLogger(__name__) + class MedianFilterDialog(qt.QDialog): """QDialog window featuring a :class:`BackgroundWidget`""" sigFilterOptChanged = qt.Signal(int, bool) @@ -69,6 +75,6 @@ class MedianFilterDialog(qt.QDialog): def _filterOptionChanged(self): """Call back used when the filter values are changed""" if self._filterWidth.value()%2 == 0: - logging.warning('median filter only accept odd values') + _logger.warning('median filter only accept odd values') else: self.sigFilterOptChanged.emit(self._filterWidth.value(), self._filterOption.isChecked())
\ No newline at end of file diff --git a/silx/gui/widgets/PeriodicTable.py b/silx/gui/widgets/PeriodicTable.py index db71483..0233e8c 100644 --- a/silx/gui/widgets/PeriodicTable.py +++ b/silx/gui/widgets/PeriodicTable.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2004-2017 European Synchrotron Radiation Facility +# Copyright (c) 2004-2018 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -634,7 +634,7 @@ class PeriodicTable(qt.QWidget): objects. :return: Selected items - :rtype: list(PeriodicTableItem) + :rtype: List[PeriodicTableItem] """ return [b.item for b in self._eltButtons.values() if b.isSelected()] @@ -644,7 +644,7 @@ class PeriodicTable(qt.QWidget): This causes the sigSelectionChanged signal to be emitted, even if the selection didn't actually change. - :param list(str) symbols: List of symbols of elements to be selected + :param List[str] symbols: List of symbols of elements to be selected (e.g. *["Fe", "Hg", "Li"]*) """ # accept list of PeriodicTableItems as input, because getSelection @@ -813,7 +813,7 @@ class PeriodicList(qt.QTreeWidget): objects. :return: Selected elements - :rtype: list(PeriodicTableItem)""" + :rtype: List[PeriodicTableItem]""" return [_defaultTableItems[idx] for idx in range(len(self.tree_items)) if self.tree_items[idx].isSelected()] diff --git a/silx/gui/widgets/PrintPreview.py b/silx/gui/widgets/PrintPreview.py index 158d6b7..2b4c433 100644 --- a/silx/gui/widgets/PrintPreview.py +++ b/silx/gui/widgets/PrintPreview.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2004-2017 European Synchrotron Radiation Facility +# Copyright (c) 2004-2018 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -666,8 +666,6 @@ class _GraphicsResizeRectItem(qt.QGraphicsRectItem): def main(): """ """ - import sys - if len(sys.argv) < 2: print("give an image file as parameter please.") sys.exit(1) diff --git a/silx/gui/widgets/ThreadPoolPushButton.py b/silx/gui/widgets/ThreadPoolPushButton.py index 4dba488..949b6ef 100644 --- a/silx/gui/widgets/ThreadPoolPushButton.py +++ b/silx/gui/widgets/ThreadPoolPushButton.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016 European Synchrotron Radiation Facility +# Copyright (c) 2016-2018 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -201,17 +201,20 @@ class ThreadPoolPushButton(WaitingPushButton): return self.__runnerStarted() runner = self._createRunner(self.__callable, self.__args, self.__kwargs) - qt.QThreadPool.globalInstance().start(runner) + qt.silxGlobalThreadPool().start(runner) self.__runnerSet.add(runner) def __releaseRunner(self, runner): self.__runnerSet.remove(runner) + def hasPendingOperations(self): + return len(self.__runnerSet) > 0 + def _createRunner(self, function, args, kwargs): """Create a QRunnable from a callable object. :param callable function: A callable Python object. - :param list args: List of arguments to call the function. + :param List args: List of arguments to call the function. :param dict kwargs: Dictionary of arguments used to call the function. :rtpye: qt.QRunnable """ @@ -227,7 +230,7 @@ class ThreadPoolPushButton(WaitingPushButton): WARNING: The callable will be called in a separate thread. :param callable function: A callable Python object - :param list args: List of arguments to call the function. + :param List args: List of arguments to call the function. :param dict kwargs: Dictionary of arguments used to call the function. """ self.__callable = function diff --git a/silx/gui/widgets/test/test_threadpoolpushbutton.py b/silx/gui/widgets/test/test_threadpoolpushbutton.py index 126f8f3..a8618a4 100644 --- a/silx/gui/widgets/test/test_threadpoolpushbutton.py +++ b/silx/gui/widgets/test/test_threadpoolpushbutton.py @@ -26,7 +26,7 @@ __authors__ = ["V. Valls"] __license__ = "MIT" -__date__ = "15/12/2016" +__date__ = "17/01/2018" import unittest @@ -35,7 +35,7 @@ from silx.gui import qt from silx.gui.test.utils import TestCaseQt from silx.gui.test.utils import SignalListener from silx.gui.widgets.ThreadPoolPushButton import ThreadPoolPushButton -from silx.test.utils import TestLogging +from silx.utils.testutils import TestLogging class TestThreadPoolPushButton(TestCaseQt): @@ -44,6 +44,14 @@ class TestThreadPoolPushButton(TestCaseQt): super(TestThreadPoolPushButton, self).setUp() self._result = [] + def waitForPendingOperations(self, object): + for i in range(50): + if not object.hasPendingOperations(): + break + self.qWait(10) + else: + raise RuntimeError("Still waiting for a pending operation") + def _trace(self, name, delay=0): self._result.append(name) if delay != 0: @@ -61,27 +69,25 @@ class TestThreadPoolPushButton(TestCaseQt): button.executeCallable() time.sleep(0.1) self.assertListEqual(self._result, ["a"]) - self.qapp.processEvents() + self.waitForPendingOperations(button) def testMultiExecution(self): button = ThreadPoolPushButton() button.setCallable(self._trace, "a", 0) - number = qt.QThreadPool.globalInstance().maxThreadCount() * 2 + number = qt.silxGlobalThreadPool().maxThreadCount() for _ in range(number): button.executeCallable() - time.sleep(number * 0.01 + 0.1) + self.waitForPendingOperations(button) self.assertListEqual(self._result, ["a"] * number) - self.qapp.processEvents() def testSaturateThreadPool(self): button = ThreadPoolPushButton() button.setCallable(self._trace, "a", 100) - number = qt.QThreadPool.globalInstance().maxThreadCount() * 2 + number = qt.silxGlobalThreadPool().maxThreadCount() * 2 for _ in range(number): button.executeCallable() - time.sleep(number * 0.1 + 0.1) + self.waitForPendingOperations(button) self.assertListEqual(self._result, ["a"] * number) - self.qapp.processEvents() def testSuccess(self): listener = SignalListener() |