ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change
on this file since f721030 was
f721030,
checked in by Piotr Rozyczko <piotr.rozyczko@…>, 8 years ago
|
Initial commit of the main window prototype
|
-
Property mode set to
100755
|
File size:
1.2 KB
|
Rev | Line | |
---|
[f721030] | 1 | from PyQt4.QtCore import * |
---|
| 2 | from PyQt4.QtGui import * |
---|
| 3 | from PyQt4.QtTest import * |
---|
| 4 | |
---|
| 5 | class QtSignalSpy(QObject): |
---|
| 6 | """ |
---|
| 7 | Helper class for testing Qt signals. |
---|
| 8 | """ |
---|
| 9 | def __init__(self, widget, signal, parent=None): |
---|
| 10 | """ |
---|
| 11 | """ |
---|
| 12 | super(QtSignalSpy, self).__init__(parent) |
---|
| 13 | |
---|
| 14 | self._connector = {} |
---|
| 15 | self._count = 0 |
---|
| 16 | self._signal = [None, None] |
---|
| 17 | |
---|
| 18 | # Assign our own slot to the emitted signal |
---|
| 19 | if isinstance(signal, pyqtBoundSignal): |
---|
| 20 | signal.connect(self.slot) |
---|
| 21 | elif hasattr(widget, signal): |
---|
| 22 | getattr(widget, signal).connect(self.slot) |
---|
| 23 | else: |
---|
| 24 | widget.signal.connect(slot) |
---|
| 25 | |
---|
| 26 | def slot(self, *args, **kwargs): |
---|
| 27 | """ |
---|
| 28 | Record emitted signal. |
---|
| 29 | """ |
---|
| 30 | self._connector[self._count] = { |
---|
| 31 | 'args' : args, |
---|
| 32 | 'kwargs' : kwargs, |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | self._count += 1 |
---|
| 36 | self._signal = [args, kwargs] |
---|
| 37 | |
---|
| 38 | def signal(self, index=None): |
---|
| 39 | """ |
---|
| 40 | """ |
---|
| 41 | if index == None: |
---|
| 42 | return self._signal |
---|
| 43 | else: |
---|
| 44 | return self._signal[index] |
---|
| 45 | |
---|
| 46 | def count(self): |
---|
| 47 | """ |
---|
| 48 | """ |
---|
| 49 | return self._count |
---|
| 50 | |
---|
| 51 | def called(self): |
---|
| 52 | """ |
---|
| 53 | """ |
---|
| 54 | return self._connector |
---|
Note: See
TracBrowser
for help on using the repository browser.