1. anatoly techtonik
  2. pyside-copy-paste


anatoly techtonik  committed 6a580a2

05.paint.button.py: paint button with a Qt Style Sheet

  • Participants
  • Parent commits 4a1d067
  • Branches default

Comments (0)

Files changed (1)

File 05.paint.button.py

View file
 # Minimal PySide application with button for choosing color to paint itself
-from PySide.QtGui import QApplication, QPushButton, QColorDialog, QMessageBox,\
-                         QPixmap
+from PySide.QtGui import QApplication, QPushButton, QColorDialog, QMessageBox
 class ButtonPainter(object):
     # Report about result of selection in QMessageBox dialog
     msgbox = QMessageBox()
     if color.isValid():
-        # Create a memory image 50x50 filled with selected color to display
-        # as a icon in the msgbox dialog
-        pixmap = QPixmap(50, 50)
-        pixmap.fill(color)
-        msgbox.setWindowTitle(u'Selected Color: ' + color.name())
-        msgbox.setIconPixmap(pixmap)
+        # Set color with a stylesheet
+        self.button.setStyleSheet(u'background-color:' + color.name())
         msgbox.setWindowTitle(u'No Color was Selected')