'Set text editor palette colors:
background color and caret (text cursor) color'

def set_palette(self, background, foreground):

    palette = QPalette()
    palette.setColor(QPalette.Base, background)
    palette.setColor(QPalette.Text, foreground)
    self.setPalette(palette)
    if (sys.platform == 'darwin'):
        if self.objectName():
            style = ('QPlainTextEdit#%s    {background:    %s;    color:    %s;}' % (self.objectName(), background.name(), foreground.name()))
            self.setStyleSheet(style)
