5yutan5 / PyQtDarkTheme

A flat dark theme for PySide and PyQt.
https://pyqtdarktheme.readthedocs.io
MIT License
568 stars 89 forks source link

Windows title bar not dark in dark theme #229

Open RyanHope opened 1 year ago

RyanHope commented 1 year ago

On my Win10 system when using the dark theme, the title bar still shows "light". I found that setting the WindowText to pure white will force the titlebar to be dark.

palette.setColor(QPalette.WindowText, Qt.white)

fmnijk commented 1 year ago

Something like this can make title bar dark.

app = QApplication(sys.argv + ['-platform', 'windows:darkmode=2'])
app.setStyle('Fusion')
app.setPalette(get_darkModePalette(app))
hannesdelbeke commented 1 year ago

Something like this can make title bar dark.

app = QApplication(sys.argv + ['-platform', 'windows:darkmode=2'])
app.setStyle('Fusion')
app.setPalette(get_darkModePalette(app))

thanks for that, works great. curious where the get_darkModePalette method comes from?

fmnijk commented 1 year ago

Here is the get_darkModePalette().

def get_darkModePalette(app=None):
    darkPalette = app.palette()
    darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
    darkPalette.setColor(QPalette.WindowText, Qt.white)
    darkPalette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(127, 127, 127))
    darkPalette.setColor(QPalette.Base, QColor(42, 42, 42))
    darkPalette.setColor(QPalette.AlternateBase, QColor(66, 66, 66))
    darkPalette.setColor(QPalette.ToolTipBase, Qt.white)
    darkPalette.setColor(QPalette.ToolTipText, Qt.white)
    darkPalette.setColor(QPalette.Text, Qt.white)
    darkPalette.setColor(QPalette.Disabled, QPalette.Text, QColor(127, 127, 127))
    darkPalette.setColor(QPalette.Dark, QColor(35, 35, 35))
    darkPalette.setColor(QPalette.Shadow, QColor(20, 20, 20))
    darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
    darkPalette.setColor(QPalette.ButtonText, Qt.white)
    darkPalette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(127, 127, 127))
    darkPalette.setColor(QPalette.BrightText, Qt.red)
    darkPalette.setColor(QPalette.Link, QColor(42, 130, 218))
    darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
    darkPalette.setColor(QPalette.Disabled, QPalette.Highlight, QColor(80, 80, 80))
    darkPalette.setColor(QPalette.HighlightedText, Qt.white)
    darkPalette.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(127, 127, 127), )

    return darkPalette

# end get_darkModePalette def