Skip to content

Comments

force light mode#1184

Merged
vasole merged 2 commits intomasterfrom
force_light_mode
Feb 13, 2026
Merged

force light mode#1184
vasole merged 2 commits intomasterfrom
force_light_mode

Conversation

@sergey-yaroslavtsev
Copy link
Collaborator

Closes #1178

By forcing Light mode.
Actually it should probably also fix the issue related to use of different PySide6 version - because it force to use a standard them instead of implementing user windows settings (default windows behavior) - yes maybe it makes things to look more "old style" but fully visible and functional.

Copy link
Collaborator

@woutdenolf woutdenolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some suggestions but I would prefer something better.

The idea is that the PyMca widgets don't show up well in dark mode.

So something like

from PyQt6.QtCore import Qt

def set_light_mode(app: QApplication):
    app.styleHints().setColorScheme(Qt.ColorScheme.Light)

or

from PyQt6.QtWidgets import QApplication
from PyQt6.QtGui import QPalette
from PyQt6.QtCore import Qt

def set_light_mode(app: QApplication):
    app.setStyle("Fusion")
    app.setPalette(app.style().standardPalette())

Of course we cannot use PyQt6 directly but you get the idea. Make a function that allows setting dark mode after instantiating the app. Perhaps this needs to be in silx.

Ping @t20100

@sergey-yaroslavtsev
Copy link
Collaborator Author

The problem is that

app.setStyle("Fusion")

will not work alone - setting "fusion" without disabling Dark mode still adapts to Dark mode and does not solve the issue of hardcoded colors. (I do not see why app.setPalette(app.style().standardPalette()) needed at all. Sorry if i am missing smthg.)

... Make a function that allows setting dark mode after instantiating the app. ...

the Dark mode should be disabled before starting the app thats the hole point unfortunately. Your first approach allows to bypass it but

app.styleHints().setColorScheme(qt.Qt.ColorScheme.Light)

do not exist in PySide6==6.7.3 and require higher version - which leads to another visual bugs #1182 #1179

@woutdenolf
Copy link
Collaborator

I do not see why app.setPalette(app.style().standardPalette()) needed at all. Sorry if i am missing smthg

I just dropped some code to help. I have no idea either. My point was: would it be possible to set the app to light-mode after instantiation and not use environment variables? I don't understand what this "fusion" business is either.

@t20100
Copy link
Member

t20100 commented Feb 11, 2026

| would it be possible to set the app to light-mode after instantiation

Quick test with silx view & PySide 6.10.2 on Linux: app.styleHints().setColorScheme(qt.Qt.ColorScheme.Light) looks to work fine.

@sergey-yaroslavtsev
Copy link
Collaborator Author

sergey-yaroslavtsev commented Feb 11, 2026

I would assume this PR as a hot fix for Windows Dark mode. Since we probably need to release patch to fix MacOS issue #1181. I would suggest to implement it.

The proper solution is to fix hardcoded colors in the way suggested by @t20100 and then there will be no need neither for Pyside6==6.7.3 nor for forcing Light mode. But it is time consumable.

We can also decide that Dark mode issue is not worth to have a hot fix and forget about this PR completely. I fine with it.

@woutdenolf woutdenolf self-requested a review February 12, 2026 07:24
@woutdenolf
Copy link
Collaborator

woutdenolf commented Feb 12, 2026

To summarize the patch:

  • QT_QPA_PLATFORM="windows:darkmode=0": stop Windows from activating dark mode at the platform level.
  • app.setStyle("Fusion"): control how widgets are drawn at the Qt style level.

@woutdenolf
Copy link
Collaborator

woutdenolf commented Feb 12, 2026

I still do not fully understand Qt's styles/palettes

Layer Controlled By What It Affects
Platform (QPA) QT_QPA_PLATFORM OS dark mode, title bars, palette defaults
Widget style setStyle() How widgets are drawn (e.g. layout)
Palette setPalette() Actual colors used
Mechanism Layer When Applied What It Affects
QT_QPA_PLATFORM Platform (QPA) Before app creation OS integration
setColorScheme() Qt-level color preference After app creation Qt palette + style behavior
OS dark mode
        ↓
Platform plugin reports preference
        ↓
Qt styleHints() stores color scheme
        ↓
Qt builds default palette
        ↓
Style renders using palette

setColorScheme is Qt6-only. It does not affect Windows dark title bars at the OS level.

🤯

@woutdenolf
Copy link
Collaborator

Btw I was told VISA has dark-mode by default now.

@vasole
Copy link
Member

vasole commented Feb 12, 2026

It looks to me there are unresolved comments.

Ideally I would expect light mode forced unless the user has explicitly asked dark mode. I guess the comment of @woutdenolf was in that direction but not implemented. Could it be?

I am fine forcing light mode in the mean time too, but the comments should be resolved.

@woutdenolf
Copy link
Collaborator

The Platform/Style/Palette discussion is a complicated one. I agreed with Sergej that we can enforce light mode on Windows for the next patch release. There is no point in allowing dark mode anyway, the GUI would become basically unusable. Afterwards we can discuss a common approach to this in pymca and other tools like silx.

@sergey-yaroslavtsev
Copy link
Collaborator Author

i will merge after MacOS patch #1185

@vasole vasole merged commit 83a117f into master Feb 13, 2026
7 checks passed
@vasole vasole deleted the force_light_mode branch February 13, 2026 10:53
@vasole vasole mentioned this pull request Feb 13, 2026
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

Successfully merging this pull request may close these issues.

Dark mode

4 participants