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 87cc73a was
87cc73a,
checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago
|
Added Modify Plot Properties functionality. SASVIEW-169
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[f721030] | 1 | from PyQt4.QtCore import * |
---|
| 2 | from PyQt4.QtGui import * |
---|
| 3 | from PyQt4.QtTest import * |
---|
| 4 | |
---|
[87cc73a] | 5 | def WarningNotImplemented(method_name): |
---|
| 6 | """ Prints warning about a non-implemented test """ |
---|
| 7 | print("\nWARNING: %s needs implementing!"%method_name) |
---|
| 8 | |
---|
[f721030] | 9 | class QtSignalSpy(QObject): |
---|
| 10 | """ |
---|
| 11 | Helper class for testing Qt signals. |
---|
| 12 | """ |
---|
| 13 | def __init__(self, widget, signal, parent=None): |
---|
| 14 | """ |
---|
| 15 | """ |
---|
| 16 | super(QtSignalSpy, self).__init__(parent) |
---|
| 17 | |
---|
[488c49d] | 18 | self._recorder = {} |
---|
[f721030] | 19 | self._count = 0 |
---|
[488c49d] | 20 | self._signal = [] |
---|
[f721030] | 21 | |
---|
| 22 | # Assign our own slot to the emitted signal |
---|
[5032ea68] | 23 | try: |
---|
| 24 | if isinstance(signal, pyqtBoundSignal): |
---|
| 25 | signal.connect(self.slot) |
---|
| 26 | elif hasattr(widget, signal): |
---|
| 27 | getattr(widget, signal).connect(self.slot) |
---|
| 28 | else: |
---|
| 29 | widget.signal.connect(slot) |
---|
[488c49d] | 30 | except AttributeError: |
---|
| 31 | msg = "Wrong construction of QtSignalSpy instance" |
---|
| 32 | raise RuntimeError, msg |
---|
[f721030] | 33 | |
---|
| 34 | def slot(self, *args, **kwargs): |
---|
| 35 | """ |
---|
| 36 | Record emitted signal. |
---|
| 37 | """ |
---|
[488c49d] | 38 | self._recorder[self._count] = { |
---|
[f721030] | 39 | 'args' : args, |
---|
| 40 | 'kwargs' : kwargs, |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | self._count += 1 |
---|
| 44 | self._signal = [args, kwargs] |
---|
| 45 | |
---|
| 46 | def signal(self, index=None): |
---|
| 47 | if index == None: |
---|
| 48 | return self._signal |
---|
| 49 | else: |
---|
| 50 | return self._signal[index] |
---|
| 51 | |
---|
| 52 | def count(self): |
---|
| 53 | return self._count |
---|
| 54 | |
---|
| 55 | def called(self): |
---|
[488c49d] | 56 | return self._recorder |
---|
Note: See
TracBrowser
for help on using the repository browser.