Hello Anatoly!
I just changed some words of your code. This shows you both
possibilities accessing the sender. Hope it helps:
from PySide.QtGui import QApplication, QPushButton, QColorDialog,
QMessageBox, QPixmap
class MyButton(QPushButton):
def choose_color(self):
print type(self)
print type(self.sender())
color = QColorDialog().getColor()
msgbox = QMessageBox()
if color.isValid():
pixmap = QPixmap(50, 50)
pixmap.fill(color)
msgbox.setWindowTitle(u'Selected Color')
msgbox.setIconPixmap(pixmap)
else:
msgbox.setWindowTitle(u'No Color was Selected')
msgbox.exec_()
app = QApplication([])
button = MyButton('Choose Color')
button.clicked.connect(button.choose_color)
button.show()
app.exec_()
I have this script that is a simple Button that calls color selection
dialog and then shows this color in popup window.
https://bitbucket.org/techtonik/pyside-copy-paste/src/19c2cd089141/04.dialog.color.py
I define choose_color() function and assign it as a handler with:
button.clicked.connect(choose_color)
Now I want choose_color() to paint the button itself with a given
color. How can I pass a reference to the button into choose_color()?
--
anatoly t.
_______________________________________________
PySide mailing list
PySide@lists.pyside.org
http://lists.pyside.org/listinfo/pyside
_______________________________________________
PySide mailing list
PySide@lists.pyside.org
http://lists.pyside.org/listinfo/pyside