Preferences/ConfigurationPages/ConfigurationPageBase.py

changeset 2228
5c59b9393306
parent 1509
c0b5e693b0eb
child 2229
78539385a8df
equal deleted inserted replaced
2227:b7aceb255831 2228:5c59b9393306
38 38
39 @param state state data generated by saveState 39 @param state state data generated by saveState
40 """ 40 """
41 return 41 return
42 42
43 def initColour(self, colourstr, button, prefMethod): 43 def initColour(self, colourstr, button, prefMethod, selectSlot=None):
44 """ 44 """
45 Public method to initialize a colour selection button. 45 Public method to initialize a colour selection button.
46 46
47 @param colourstr colour to be set (string) 47 @param colourstr colour to be set (string)
48 @param button reference to a button to show the colour on (QPushButton) 48 @param button reference to a button to show the colour on (QPushButton)
49 @param prefMethod preferences method to get the colour 49 @param prefMethod preferences method to get the colour
50 @param selectSlot method to select the color
50 @return reference to the created colour (QColor) 51 @return reference to the created colour (QColor)
51 """ 52 """
52 colour = QColor(prefMethod(colourstr)) 53 colour = QColor(prefMethod(colourstr))
53 size = button.size() 54 size = button.size()
54 pm = QPixmap(size.width() / 2, size.height() / 2) 55 pm = QPixmap(size.width() / 2, size.height() / 2)
55 pm.fill(colour) 56 pm.fill(colour)
56 button.setIconSize(pm.size()) 57 button.setIconSize(pm.size())
57 button.setIcon(QIcon(pm)) 58 button.setIcon(QIcon(pm))
59 button.setProperty("colorName", colourstr)
60 if selectSlot is not None:
61 button.clicked[()].connect(selectSlot)
58 return colour 62 return colour
59 63
60 def selectColour(self, button, colourVar, showAlpha=False): 64 def selectColour(self, button, colourVar, showAlpha=False):
61 """ 65 """
62 Public method used by the colour selection buttons. 66 Public method used by the colour selection buttons.

eric ide

mercurial