Determining which QPushButton has been pressed

Solved my own problem… thx! code is as below


def set_color(self):
	sender = self.sender()
        print sender.objectName()

position = [(i, j) for i in range(2) for j in range(16)]

for x in range(1, 32):
	color = cmds.colorIndex(x, q=True)

	palette_buttons = QtGui.QPushButton(str(x))
        palette_buttons.setObjectName(str(x))

	style = 'QWidget {  ' \
			'padding: 20px; border-radius: 10px; border-width: 1px; border-style: inset; background-color:rgb(%s, %s, %s); }' \
			'QWidget: hover {border-color:red;}' \
			% (color[0]*255, color[1]*255, color[2]*255)

	palette_buttons.setStyleSheet(style)
	palette_layout.addWidget(palette_buttons, position[x][0], position[x][1])
	
	palette_buttons.clicked.connect(self.set_color)