--- a/Preferences/ConfigurationPages/DiffColoursPage.py Mon Feb 05 19:15:47 2018 +0100 +++ b/Preferences/ConfigurationPages/DiffColoursPage.py Mon Feb 05 19:59:18 2018 +0100 @@ -42,27 +42,48 @@ sample.setFont(monospacedFont) # set initial values - self.__initColour("TextColor", self.textButton, - self.__updateSampleTextColour, - self.__selectTextColour, self.textSample) - self.__initColour("AddedColor", self.addedButton, - self.__updateSampleBackgroundColour, - self.__selectBackgroundColour, self.addedSample) - self.__initColour("RemovedColor", self.removedButton, - self.__updateSampleBackgroundColour, - self.__selectBackgroundColour, self.removedSample) - self.__initColour("ReplacedColor", self.replacedButton, - self.__updateSampleBackgroundColour, - self.__selectBackgroundColour, self.replacedSample) - self.__initColour("ContextColor", self.contextButton, - self.__updateSampleBackgroundColour, - self.__selectBackgroundColour, self.contextSample) - self.__initColour("HeaderColor", self.headerButton, - self.__updateSampleBackgroundColour, - self.__selectBackgroundColour, self.headerSample) - self.__initColour("BadWhitespaceColor", self.whitespaceButton, - self.__updateSampleBackgroundColour, - self.__selectBackgroundColour, self.whitespaceSample) + self.__initColour( + "TextColor", + self.textButton, + self.__updateSampleTextColour, + lambda: self.__selectTextColour(self.textButton), + self.textSample) + self.__initColour( + "AddedColor", + self.addedButton, + self.__updateSampleBackgroundColour, + lambda: self.__selectBackgroundColour(self.addedButton), + self.addedSample) + self.__initColour( + "RemovedColor", + self.removedButton, + self.__updateSampleBackgroundColour, + lambda: self.__selectBackgroundColour(self.removedButton), + self.removedSample) + self.__initColour( + "ReplacedColor", + self.replacedButton, + self.__updateSampleBackgroundColour, + lambda: self.__selectBackgroundColour(self.replacedButton), + self.replacedSample) + self.__initColour( + "ContextColor", + self.contextButton, + self.__updateSampleBackgroundColour, + lambda: self.__selectBackgroundColour(self.contextButton), + self.contextSample) + self.__initColour( + "HeaderColor", + self.headerButton, + self.__updateSampleBackgroundColour, + lambda: self.__selectBackgroundColour(self.headerButton), + self.headerSample) + self.__initColour( + "BadWhitespaceColor", + self.whitespaceButton, + self.__updateSampleBackgroundColour, + lambda: self.__selectBackgroundColour(self.whitespaceButton), + self.whitespaceSample) def save(self): """ @@ -95,11 +116,13 @@ initSlot(colourKey) @pyqtSlot() - def __selectTextColour(self): + def __selectTextColour(self, button): """ Private slot to select the text colour. + + @param button reference to the button been pressed + @type QPushButton """ - button = self.sender() colorKey = button.property("colorKey") colour = QColorDialog.getColor(self.__coloursDict[colorKey][0], self) @@ -108,11 +131,13 @@ self.__updateSampleTextColour(colorKey) @pyqtSlot() - def __selectBackgroundColour(self): + def __selectBackgroundColour(self, button): """ Private slot to select a background colour. + + @param button reference to the button been pressed + @type QPushButton """ - button = self.sender() colorKey = button.property("colorKey") colour = QColorDialog.getColor(self.__coloursDict[colorKey][0], self,