[PyKDE] Newbie pyQt user needs some slot help

Phil Thompson phil at river-bank.demon.co.uk
Thu Apr 27 21:23:20 BST 2000

QPopupMenu::exec() isn't a slot, it's just a member function.  You could
sub-class a QPopupMenu with a Python method called (say) showMenu which
does something like...

	def showMenu(self):

...and connect to it...

QObject.connect(but, SIGNAL("clicked()"), pm.showMenu)


Matthew Flower wrote:
> Hi folks,
> I am having a little bit of trouble and perhaps someone is listening out in radio land.  In a
> larger python application I am developing, I have a button that tries to bring up a popup menu.
> (Much in the same way that a "Start" button in windows brings up the start menu.
> The problem is that I can't seem to get the exec_loop() slot to work.  My push button will make
> other slots fire (such as the quit() signal for the application), but it won't pop up the menu.  I
> have played with the QObject.Connect statement a lot, but I haven't found a way that it will work.
>  (It does work okay if I just call pm.exec_loop())
> I transcribed some sample code below:
> from qt import *
> import sys
> App = QApplication(sys.argv)
> widg = QWidget()
> widg.setGeometry(300,300,100,35)
> but = QPushButton("Button", widg)
> pm = QPopupMenu()
> pm.insertItem("First Item")
> pm.insertItem("Second Item")
> QObject.connect(but, SIGNAL("clicked()"), pm, SLOT("exec_loop()"))
> App.setMainWidget(widg)
> widg.show()
> App.exec_loop()
> Thanks for all your help in advance.
> -Matt  (MattFlower at yahoo.com)
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online and get email alerts with Yahoo! Messenger.
> http://im.yahoo.com/
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.gmd.de
> http://mats.gmd.de/mailman/listinfo/pykde

More information about the PyQt mailing list