Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows title bar not dark in dark theme #229

Open
RyanHope opened this issue Jan 30, 2023 · 3 comments
Open

Windows title bar not dark in dark theme #229

RyanHope opened this issue Jan 30, 2023 · 3 comments

Comments

@RyanHope
Copy link

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
Copy link

fmnijk commented Sep 2, 2023

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
Copy link

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
Copy link

fmnijk commented Sep 28, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants