1. anatoly techtonik
  2. pyside-copy-paste

Commits

anatoly techtonik  committed 4a1d067

05.paint.button.py: save button reference in handler object, show color name

  • Participants
  • Parent commits 3b4ebfc
  • Branches default

Comments (0)

Files changed (1)

File 05.paint.button.py

View file
 
 
 class ButtonPainter(object):
+  def __init__(self, button):
+    self.button = button
+
   def choose_color(self):
     # Select color
     color  = QColorDialog().getColor()
         # as a icon in the msgbox dialog
         pixmap = QPixmap(50, 50)
         pixmap.fill(color)
-        msgbox.setWindowTitle(u'Selected Color')
+        msgbox.setWindowTitle(u'Selected Color: ' + color.name())
         msgbox.setIconPixmap(pixmap)
     else:
         msgbox.setWindowTitle(u'No Color was Selected')
 # button.clicked.connect() doesn't support passing custom parameters to
 # handler function (reference to the  button that we want to paint), so we
 # create object that will hold this parameter
-button_painter = ButtonPainter()
+button_painter = ButtonPainter(button)
 button.clicked.connect(button_painter.choose_color)
 button.show()