54 pm.fill(colour) |
54 pm.fill(colour) |
55 button.setIconSize(pm.size()) |
55 button.setIconSize(pm.size()) |
56 button.setIcon(QIcon(pm)) |
56 button.setIcon(QIcon(pm)) |
57 return colour |
57 return colour |
58 |
58 |
59 def selectColour(self, button, colourVar): |
59 def selectColour(self, button, colourVar, showAlpha = False): |
60 """ |
60 """ |
61 Public method used by the colour selection buttons. |
61 Public method used by the colour selection buttons. |
62 |
62 |
63 @param button reference to a button to show the colour on (QPushButton) |
63 @param button reference to a button to show the colour on (QPushButton) |
64 @param colourVar reference to the variable containing the colour (QColor) |
64 @param colourVar reference to the variable containing the colour (QColor) |
|
65 @param showAlpha flag indicating to show a selection for the alpha |
|
66 channel (boolean) |
65 @return selected colour (QColor) |
67 @return selected colour (QColor) |
66 """ |
68 """ |
67 colour = QColorDialog.getColor(colourVar) |
69 if showAlpha: |
|
70 colour = QColorDialog.getColor(colourVar, None, "", |
|
71 QColorDialog.ShowAlphaChannel) |
|
72 else: |
|
73 colour = QColorDialog.getColor(colourVar) |
68 if colour.isValid(): |
74 if colour.isValid(): |
69 size = button.iconSize() |
75 size = button.iconSize() |
70 pm = QPixmap(size.width(), size.height()) |
76 pm = QPixmap(size.width(), size.height()) |
71 pm.fill(colour) |
77 pm.fill(colour) |
72 button.setIcon(QIcon(pm)) |
78 button.setIcon(QIcon(pm)) |