From 875ae8e38bc3663e5057ca910e7ebe4b2994edb9 Mon Sep 17 00:00:00 2001 From: tpearson Date: Tue, 14 Sep 2010 19:47:20 +0000 Subject: Updated python directory git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1175349 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- python/pykde/doc/signal.html | 290 ------------------------------------------- 1 file changed, 290 deletions(-) delete mode 100644 python/pykde/doc/signal.html (limited to 'python/pykde/doc/signal.html') diff --git a/python/pykde/doc/signal.html b/python/pykde/doc/signal.html deleted file mode 100644 index b95ed7f6..00000000 --- a/python/pykde/doc/signal.html +++ /dev/null @@ -1,290 +0,0 @@ -Signal and Slot Support
Python Bindings for KDE (PyKDE-3.16.0)
PrevNext

Signal and Slot Support

General Signals and Slots

A signal may be either a Qt signal (specified using -TQT_SIGNAL()) or a Python signal (specified using -PYQT_SIGNAL()).

A slot can be either a Python callable object, a Qt signal (specified using -TQT_SIGNAL()), a Python signal (specified using -PYQT_SIGNAL()), or a Qt slot (specified using -TQT_SLOT()).

You connect signals to slots (and other signals) as you would from C++. For -example:

TQObject.connect(a,TQT_SIGNAL("QtSig()"),pyFunction)
-TQObject.connect(a,TQT_SIGNAL("QtSig()"),pyClass.pyMethod)
-TQObject.connect(a,TQT_SIGNAL("QtSig()"),PYQT_SIGNAL("PySig"))
-TQObject.connect(a,TQT_SIGNAL("QtSig()"),TQT_SLOT("QtSlot()"))
-TQObject.connect(a,PYQT_SIGNAL("PySig"),pyFunction)
-TQObject.connect(a,PYQT_SIGNAL("PySig"),pyClass.pyMethod)
-TQObject.connect(a,PYQT_SIGNAL("PySig"),TQT_SIGNAL("QtSig()"))
-TQObject.connect(a,PYQT_SIGNAL("PySig"),TQT_SLOT("QtSlot()"))

When a slot is a Python method that corresponds to a Qt slot then a signal can -be connected to either the Python method or the Qt slot. The following -connections achieve the same effect.

sbar = TQScrollBar()
-lcd = TQLCDNumber()
-
-TQObject.connect(sbar,TQT_SIGNAL("valueChanged(int)"),lcd.display)
-TQObject.connect(sbar,TQT_SIGNAL("valueChanged(int)"),lcd,TQT_SLOT("display(int)"))

The difference is that the second connection is made at the C++ level and is -more efficient.

Disconnecting signals works in exactly the same way.

Any instance of a class that is derived from the TQObject -class can emit a signal using the emit method. This takes -two arguments. The first is the Python or Qt signal, the second is a Python -tuple which are the arguments to the signal. For example:

a.emit(TQT_SIGNAL("clicked()"),())
-a.emit(PYQT_SIGNAL("pySig"),("Hello","World"))

Qt allows a signal to be connected to a slot that requires fewer arguments than -the signal passes. The extra arguments are quietly discarded. Python slots -can be used in the same way.

Slots in Menus, Toolbars and Actions

The C++ declarations for menu items or KActions are similar to these examples:

int TQMenuData::insertItem (const TQString & text,
-     const TQObject * receiver, const char * member,
-     int accel = 0, int id = -1, int index = -1 )
-
-KAction ( const TQString& text, int accel,
-     const TQObject* receiver, const char* slot,
-     TQObject* parent, const char* name = 0 )

Notice the "const TQObject* receiver, const char* slot" parameters for each declaration.

In PyKDE, these two parameters are replaced with a SINGLE parameter that specifies the -slot to be connected to the menu item, toolbar button or KAction:

p = insertItem ("Open", self.slotOpen, 0, -1, -1)
-
-action = KAction ("Open", 0, self.slotOpen, None, 0)

This substitution applies to appropriate methods in KStdAction, KAction and related -subclasses, KAccelMenu and KToolBar


PrevHomeNext
General Limitations Static Member Functions
\ No newline at end of file -- cgit v1.2.3