0

I came across some new way of connecting signals and slots in PyQt. Please have a look at this link. How to capture output of Python's interpreter and show in a Text widget?. Here the textWritten(signal)=self.normalOutputWritten(function) are connected directly. It is working. Can someone elaborate on this new way of connections.

Rephrasing the question: How to capture output of Python's interpreter and show in a Text widget?. In the above link, testWritten is defined as pyqtSignal and self.normalOutput is the slot function. Usually, we connect using the old or new styles but here they just used the '=' symbol. It is working. Please explain this new way.

Community
  • 1
  • 1
honeybadger
  • 1,465
  • 1
  • 19
  • 32

1 Answers1

2

When you create some PyQt object, you can set properties and connect signals uising keyword arguments to __init__(), e.g.:

button = QtGui.QPushButton(clicked=on_click, text='My button', checkable=True)

For more info see:

PyQt Support for Qt Properties

Frequently overlooked (and practical) PyQt4 features

reclosedev
  • 9,352
  • 34
  • 51
  • I am familiar with the old and new styles of connecting slots and signals. All of them use 'connect' . Here, testWritten signal is being connected to self.normalOutput function by using '='. Please check my updated question. thanks. – honeybadger Jul 14 '12 at 07:06
  • @kasa, Are you talking about ``sys.stdout = EmittingStream(textWritten=self.normalOutputWritten)`` It's same as ``QPushButtton(clicked=self.on_click)`` i.e. keyword argument. Did you read links from answer? – reclosedev Jul 14 '12 at 07:29