Along this line, the pyqtgraph library doesn't use decorated slots anywhere in the library. One of the issues on our backlog has been to try and evaluate if there is any benefit to doing so. As far as I know, nobody has actually done this, if you're curious about it, and do some testing along this line, let us know here! https://github.com/pyqtgraph/pyqtgraph/issues/1607
On Thu, Jul 15, 2021 at 6:52 AM [email protected] <[email protected]> wrote: > As to when or where the decorator is necessary at all, this link has a > very short answer for PyQt4 that may also be relevant for PySide (and > PyQt5). It's still slightly mysterious, though. > > > https://stackoverflow.com/questions/14421897/is-the-pyside-slot-decorator-necessary/14431607#14431607 > > On Tuesday, July 13, 2021 at 2:20:34 PM UTC-4 James wrote: > >> Hi all, >> >> The code below works as expected to get the position of a click in a >> GraphicsLayoutWidget. But if I uncomment the @pyqtSlot() line, then I get >> the following error when I click in the GLW: >> >> TypeError: onClick() missing 1 required positional argument: 'evt' >> >> Should I not be using @pyqtSlot() decorator? >> >> James >> >> PS: I do not see an option to syntax-highlight code blocks in this group. >> Can that be enabled? >> >> import sys >> import pyqtgraph as pg >> from PyQt5 import QtWidgets as qtw >> from PyQt5.QtCore import pyqtSlot >> >> class MainWindow(qtw.QMainWindow): >> def __init__(self, *args, **kwargs): super(MainWindow, >> self).__init__(*args, **kwargs) >> >> self.glw = pg.GraphicsLayoutWidget() >> self.setCentralWidget(self.glw) >> self.glw.scene().sigMouseClicked.connect(self.onClick) >> self.show() >> >> #@pyqtSlot() >> >> def onClick(self, evt): >> print("glw clicked") >> print(evt.scenePos()) >> >> if __name__ == "__main__": >> app = qtw.QApplication(sys.argv) >> win = MainWindow() >> app.exec_() >> > -- > You received this message because you are subscribed to the Google Groups > "pyqtgraph" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pyqtgraph/6609b0e8-b5f8-4175-9f65-03f0dbbfb89cn%40googlegroups.com > <https://groups.google.com/d/msgid/pyqtgraph/6609b0e8-b5f8-4175-9f65-03f0dbbfb89cn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "pyqtgraph" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CA%2BnduTGbxrva-PNVsr%2BTOcd4jjTjr1QEo3VypUKvYbv_U8r%2B-A%40mail.gmail.com.
