Visitar URL original
Route GUI Qt imports through qtpy, keeping PySide6 preferred by C-Achard · Pull Request #3490 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Avoid QT_API override in darkstyle loading
Switch GUI dark theme setup to `qdarkstyle.load_stylesheet(palette=DarkPalette)` in both app launch and the runtime dark mode toggle. This avoids the binding-specific helpers that mutate `QT_API` and can desynchronize matplotlib from qtpy’s loaded backend. Also keep the bundled `style.qss` as a fallback if qdarkstyle fails to load, with clearer warning logging.
  • Loading branch information
C-Achard committed Sep 7, 2026
commit 42c9acbc62bd05d837188bc7a503bb9a5d41da04
14 changes: 8 additions & 6 deletions deeplabcut/gui/launch_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import sys

import qdarkstyle
from qdarkstyle.dark.palette import DarkPalette
from qtpy import QtWidgets
from qtpy.QtCore import Qt

Expand All @@ -39,13 +40,14 @@ def launch_dlc():
splash = QtWidgets.QSplashScreen(pixmap)
splash.show()

app.setStyleSheet(get_style_qss()) # this gets overridden immediately?
app.setStyleSheet(get_style_qss())
try:
dark_stylesheet = qdarkstyle.load_stylesheet_pyside6()
except Exception as e:
logger.warning(f"Could not load qdarkstyle stylesheet for PySide6: {e}. Falling back to PySide2 stylesheet.")
dark_stylesheet = qdarkstyle.load_stylesheet_pyside2()
app.setStyleSheet(dark_stylesheet)
# Always pass `palette=`: the zero-argument load_stylesheet() and the
# load_stylesheet_<binding>() helpers overwrite os.environ["QT_API"],
# which desynchronises matplotlib from the binding qtpy loaded.
app.setStyleSheet(qdarkstyle.load_stylesheet(palette=DarkPalette))
except Exception:
logger.warning("Could not load the qdarkstyle stylesheet; keeping the bundled style.qss.", exc_info=True)

# Set up a logger and add an stdout handler.
# A single logger can have many handlers:
Expand Down
4 changes: 3 additions & 1 deletion deeplabcut/gui/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,9 @@ def load_config(
return True

def darkmode(self):
dark_stylesheet = qdarkstyle.load_stylesheet_pyside2()
from qdarkstyle.dark.palette import DarkPalette

dark_stylesheet = qdarkstyle.load_stylesheet(palette=DarkPalette)
self.app.setStyleSheet(dark_stylesheet)

names = ["new_project2.png", "open2.png", "help2.png"]
Expand Down