Changeset View
Changeset View
Standalone View
Standalone View
user_manual/python_scripting/krita_python_plugin_howto.rst
Show First 20 Lines • Show All 301 Lines • ▼ Show 20 Line(s) | |||||
302 | Restart Krita and the button should now be laid out nicely. | 302 | Restart Krita and the button should now be laid out nicely. | ||
303 | 303 | | |||
304 | PyQT Signals and Slots | 304 | PyQT Signals and Slots | ||
305 | ---------------------- | 305 | ---------------------- | ||
306 | 306 | | |||
307 | We've already been using pyqt signals and slots already, but there's times where you want to create your own signals and slots. | 307 | We've already been using pyqt signals and slots already, but there's times where you want to create your own signals and slots. | ||
308 | `As pyQt's documentation is pretty difficult to understand <http://pyqt.sourceforge.net/Docs/PyQt4/new_style_signals_slots.html>`_, and the way how signals and slots are created is very different from C++ qt, we're explaining it here: | 308 | `As pyQt's documentation is pretty difficult to understand <http://pyqt.sourceforge.net/Docs/PyQt4/new_style_signals_slots.html>`_, and the way how signals and slots are created is very different from C++ qt, we're explaining it here: | ||
309 | 309 | | |||
310 | All python functions you make in pyQt can be understood as slots, meaning that they can be connected to signals like Action.triggered or QPushButton.clicked. However, QCheckBox has a signal for toggled, which sents a boolean. How do we get our function to accept that boolean? | 310 | All python functions you make in pyQt can be understood as slots, meaning that they can be connected to signals like Action.triggered or QPushButton.clicked. However, QCheckBox has a signal for toggled, which sends a boolean. How do we get our function to accept that boolean? | ||
311 | 311 | | |||
312 | First, make sure you have the right import for making custom slots: | 312 | First, make sure you have the right import for making custom slots: | ||
313 | 313 | | |||
314 | ``from PyQt5.QtCore import pyqtSlot`` | 314 | ``from PyQt5.QtCore import pyqtSlot`` | ||
315 | 315 | | |||
316 | (If there's from ``PyQt5.QtCore import *`` already in the list of imports, then you won't have to do this, of course) | 316 | (If there's from ``PyQt5.QtCore import *`` already in the list of imports, then you won't have to do this, of course) | ||
317 | 317 | | |||
318 | Then, you need to add a pyQt slot definition before your function: | 318 | Then, you need to add a pyQt slot definition before your function: | ||
Show All 37 Lines |