diff --git a/examples/PaletteEditor.py b/examples/PaletteEditor.py index 7906c07f..d8cb8718 100644 --- a/examples/PaletteEditor.py +++ b/examples/PaletteEditor.py @@ -265,23 +265,23 @@ class MainWindow(QtWidgets.QMainWindow): SEL_NORMAL = QtGui.QColor('#1464A0') SEL_DARK = QtGui.QColor('#14506E') qpal = QtGui.QPalette( QtGui.QColor(BG_DARK) ) - for ptype in ( QtGui.QPalette.Active, QtGui.QPalette.Inactive ): - qpal.setColor( ptype, QtGui.QPalette.Window, BG_NORMAL ) - qpal.setColor( ptype, QtGui.QPalette.WindowText, FG_LIGHT ) # or white? - qpal.setColor( ptype, QtGui.QPalette.Base, BG_DARK ) - qpal.setColor( ptype, QtGui.QPalette.Text, FG_LIGHT ) - qpal.setColor( ptype, QtGui.QPalette.AlternateBase, BG_DARK ) - qpal.setColor( ptype, QtGui.QPalette.ToolTipBase, BG_LIGHT ) - qpal.setColor( ptype, QtGui.QPalette.ToolTipText, FG_LIGHT ) - qpal.setColor( ptype, QtGui.QPalette.Button, BG_NORMAL ) - qpal.setColor( ptype, QtGui.QPalette.ButtonText, FG_LIGHT ) - qpal.setColor( ptype, QtGui.QPalette.Link, SEL_NORMAL ) - qpal.setColor( ptype, QtGui.QPalette.LinkVisited, FG_NORMAL ) - qpal.setColor( ptype, QtGui.QPalette.Highlight, SEL_LIGHT ) - qpal.setColor( ptype, QtGui.QPalette.HighlightedText, BLACK ) - qpal.setColor( QtGui.QPalette.Disabled, QtGui.QPalette.Button, BG_NORMAL ) - qpal.setColor( QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, FG_DARK ) - qpal.setColor( QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, FG_DARK ) + for ptype in ( QtGui.QPalette.ColorGroup.Active, QtGui.QPalette.ColorGroup.Inactive ): + qpal.setColor( ptype, QtGui.QPalette.ColorRole.Window, BG_NORMAL ) + qpal.setColor( ptype, QtGui.QPalette.ColorRole.WindowText, FG_LIGHT ) # or white? + qpal.setColor( ptype, QtGui.QPalette.ColorRole.Base, BG_DARK ) + qpal.setColor( ptype, QtGui.QPalette.ColorRole.Text, FG_LIGHT ) + qpal.setColor( ptype, QtGui.QPalette.ColorRole.AlternateBase, BG_DARK ) + qpal.setColor( ptype, QtGui.QPalette.ColorRole.ToolTipBase, BG_LIGHT ) + qpal.setColor( ptype, QtGui.QPalette.ColorRole.ToolTipText, FG_LIGHT ) + qpal.setColor( ptype, QtGui.QPalette.ColorRole.Button, BG_NORMAL ) + qpal.setColor( ptype, QtGui.QPalette.ColorRole.ButtonText, FG_LIGHT ) + qpal.setColor( ptype, QtGui.QPalette.ColorRole.Link, SEL_NORMAL ) + qpal.setColor( ptype, QtGui.QPalette.ColorRole.LinkVisited, FG_NORMAL ) + qpal.setColor( ptype, QtGui.QPalette.ColorRole.Highlight, SEL_LIGHT ) + qpal.setColor( ptype, QtGui.QPalette.ColorRole.HighlightedText, BLACK ) + qpal.setColor( QtGui.QPalette.ColorGroup.Disabled, QtGui.QPalette.ColorRole.Button, BG_NORMAL ) + qpal.setColor( QtGui.QPalette.ColorGroup.Disabled, QtGui.QPalette.ColorRole.ButtonText, FG_DARK ) + qpal.setColor( QtGui.QPalette.ColorGroup.Disabled, QtGui.QPalette.ColorRole.WindowText, FG_DARK ) return qpal ########################################################################## diff --git a/pyqtgraph/palette.py b/pyqtgraph/palette.py index 7d82487e..fa71d061 100644 --- a/pyqtgraph/palette.py +++ b/pyqtgraph/palette.py @@ -317,12 +317,12 @@ class Palette(object): """ Retrieves the current Qt 'active' palette and extracts the following colors: ===================================== ============================================================================ - 'gr_fg','gr_txt' from QPalette.Text (foreground color used with Base) - 'gr_bg' from QPalette.Base (background color for e.g. text entry widgets) - 'gr_wdw' from QPalette.Window (a general background color) - 'gr_reg' from QPalette.AlternateBase (alternating row background color) - 'gr_acc' from QPalette.Link (color used for unvisited hyperlinks) - 'gr_hlt' from QPalette.Highlight (color to indicate a selected item) + 'gr_fg','gr_txt' from ColorRole.Text (foreground color used with Base) + 'gr_bg' from ColorRole.Base (background color for e.g. text entry widgets) + 'gr_wdw' from ColorRole.Window (a general background color) + 'gr_reg' from ColorRole.AlternateBase (alternating row background color) + 'gr_acc' from ColorRole.Link (color used for unvisited hyperlinks) + 'gr_hlt' from ColorRole.Highlight (color to indicate a selected item) ===================================== ============================================================================ """ app = QtWidgets.QApplication.instance() @@ -331,32 +331,34 @@ class Palette(object): col_grp = QtGui.QPalette.Active colors = {} for key, alpha, col_role in ( - ('gr_bg' , None, QtGui.QPalette.Base), # background color for e.g. text entry - ('gr_fg' , None, QtGui.QPalette.WindowText), # overall foreground text color - ('gr_txt', None, QtGui.QPalette.Text), # foreground color used with Base - ('gr_reg', 128, QtGui.QPalette.AlternateBase), # alternating row background color - ('gr_acc', None, QtGui.QPalette.Link), # color of unvisited hyperlink - # ('gr_reg', 128, QtGui.QPalette.Highlight), # alternating row background color - # ('gr_acc', None, QtGui.QPalette.Highlight), # color of unvisited hyperlink - ('gr_hlt', None, QtGui.QPalette.Highlight), # color to indicate a selected item - ('ui_wind', None, QtGui.QPalette.Window), # a general background color - ('ui_text', None, QtGui.QPalette.WindowText) # overall foreground text color + ('gr_bg' , None, QtGui.QPalette.ColorRole.Base), # background color for e.g. text entry + ('gr_fg' , None, QtGui.QPalette.ColorRole.WindowText), # overall foreground text color + ('gr_txt', None, QtGui.QPalette.ColorRole.Text), # foreground color used with Base + ('gr_reg', 128, QtGui.QPalette.ColorRole.AlternateBase), # alternating row background color + ('gr_acc', None, QtGui.QPalette.ColorRole.Link), # color of unvisited hyperlink + # ('gr_reg', 128, QtGui.QPalette.ColorRole.Highlight), # alternating row background color + # ('gr_acc', None, QtGui.QPalette.ColorRole.Highlight), # color of unvisited hyperlink + ('gr_hlt', None, QtGui.QPalette.ColorRole.Highlight), # color to indicate a selected item + ('ui_wind', None, QtGui.QPalette.ColorRole.Window), # a general background color + ('ui_text', None, QtGui.QPalette.ColorRole.WindowText) # overall foreground text color ): qcol = qPalette.color(col_grp, col_role) if alpha is not None: qcol.setAlpha(alpha) colors[key] = qcol self.add(colors) colors = { - 'b': QtCore.Qt.blue , 'c': QtCore.Qt.cyan, 'g': QtCore.Qt.green , - 'y': QtCore.Qt.yellow, 'r': QtCore.Qt.red , 'm': QtCore.Qt.magenta, - 'w': QtCore.Qt.white , 's': QtCore.Qt.gray, 'k': QtCore.Qt.black , - 'l': QtCore.Qt.lightGray, 'd': QtCore.Qt.darkGray + 'b': QtCore.Qt.GlobalColor.blue , 'c': QtCore.Qt.GlobalColor.cyan, + 'g': QtCore.Qt.GlobalColor.green, 'y': QtCore.Qt.GlobalColor.yellow, + 'r': QtCore.Qt.GlobalColor.red , 'm': QtCore.Qt.GlobalColor.magenta, + 'w': QtCore.Qt.GlobalColor.white, 's': QtCore.Qt.GlobalColor.gray, + 'k': QtCore.Qt.GlobalColor.black, 'l': QtCore.Qt.GlobalColor.lightGray, + 'd': QtCore.Qt.GlobalColor.darkGray } if not self.dark: # darken some colors for light mode - colors['c'] = QtCore.Qt.darkCyan - colors['g'] = QtCore.Qt.darkGreen - colors['y'] = QtCore.Qt.darkYellow - colors['m'] = QtCore.Qt.darkMagenta + colors['c'] = QtCore.Qt.GlobalColor.darkCyan + colors['g'] = QtCore.Qt.GlobalColor.darkGreen + colors['y'] = QtCore.Qt.GlobalColor.darkYellow + colors['m'] = QtCore.Qt.GlobalColor.darkMagenta self.add(colors) colors = { 'p'+str(idx) : name