[PyQt] Problem connecting buttonClicked signal

dizou di_zou at yahoo.com
Tue Jun 22 19:10:45 BST 2010


I have a bunch of QPushButtons in a QButtonGroup. I am trying to connect the
buttonClicked() signal with a method, but I am not able to.

This is what I have:

class DrawWidget(QWidget):
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        
        self.Setup()
    def Setup(self):        
        cursorButton = QPushButton()
        platformButton = QPushButton()
        nodeButton = QPushButton()
        channelButton = QPushButton()
        
        buttonGroup = QButtonGroup()
        buttonGroup.setExclusive(True)
        buttonGroup.addButton(cursorButton, 0)
        buttonGroup.addButton(platformButton, 1)
        buttonGroup.addButton(nodeButton, 2)
        buttonGroup.addButton(channelButton, 3)
        
        for button in buttonGroup.buttons():
            button.setFlat(True)
            button.setCheckable(True)
        
        cursorButton.setChecked(True)
        gridLayout = QGridLayout()
        gridLayout.addWidget(cursorButton, 0, 0)
        gridLayout.addWidget(platformButton, 0, 1)
        gridLayout.addWidget(nodeButton, 0, 2)
        gridLayout.addWidget(channelButton, 0, 3)
        
        self.setLayout(gridLayout)
        
        self.connect(buttonGroup, SIGNAL("buttonClicked(int)"),
self.ButtonClick)
        #self.connect(buttonGroup, SIGNAL("clicked(int)"), self.ButtonClick)
    def ButtonClick(self, id):
        print id
        print "clicked"

When I run this code, I don't get anything printed on the screen.
-- 
View this message in context: http://old.nabble.com/Problem-connecting-buttonClicked-signal-tp28963271p28963271.html
Sent from the PyQt mailing list archive at Nabble.com.



More information about the PyQt mailing list