Visitar URL original
Fix PySide6 stylesheet usage by C-Achard · Pull Request #3371 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3b8c44a
fix path resolution on network drives. Replace Path(..).resolve() wi…
deruyter92 May 29, 2026
fddcbaa
Add safe_resolve helper for path resolution
deruyter92 May 29, 2026
65f8dfb
fix redundant resolution of resolved path in memory_replay.py
deruyter92 May 29, 2026
6bbe26d
fix open -> os.stat
deruyter92 May 29, 2026
3f93a76
replace os.stat -> open for files, listdir for dirs.
deruyter92 May 29, 2026
87cd6aa
fix TestReadConfigProjectPath
deruyter92 May 29, 2026
8be1c26
Update deeplabcut/utils/auxiliaryfunctions.py
deruyter92 May 29, 2026
5ec1023
Merge remote-tracking branch 'upstream/main' into jaap/safe_resolve_p…
deruyter92 Jun 26, 2026
f422dcc
Merge branch 'main' into jaap/safe_resolve_paths
C-Achard Jun 29, 2026
9d2732b
Adjust config path tests for Path objects
C-Achard Jun 29, 2026
bb23a34
address remaining `.resolve()` cases: prefer `.absolute()`, or otherw…
deruyter92 Jul 6, 2026
831cb1d
update `safe_resolve`: add logging, use os.stat (more efficient)
deruyter92 Jul 6, 2026
77bf7f0
update test safe_resolve: allow fallback and test open/closing instead
deruyter92 Jul 6, 2026
ca63582
Merge remote-tracking branch 'upstream/main' into jaap/safe_resolve_p…
deruyter92 Jul 6, 2026
205b550
fix remaining Path.resolve()
deruyter92 Jul 7, 2026
8c6c722
Add GUI asset helper utilities
C-Achard Jun 15, 2026
32c12e7
Use gui_assets for icons and pixmaps
C-Achard Jun 15, 2026
a7f2643
Use get_style_qss and update qdarkstyle deps
C-Achard Jun 15, 2026
2a59325
Update uv.lock
C-Achard Jun 15, 2026
4dec33a
Fallback to PySide2 qdarkstyle stylesheet
C-Achard Jun 15, 2026
5275139
Remove unused imports and tidy spacing
C-Achard Jul 16, 2026
e6aab6a
Remove outdated comments
C-Achard Jul 17, 2026
b5c2c91
Merge remote-tracking branch 'upstream/main' into cy/fix-pyside6-theme
deruyter92 Jul 17, 2026
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
2 changes: 1 addition & 1 deletion deeplabcut/core/debug/_debug_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _env_optional_float(name: str, default: float | None = None) -> float | None
def _which(command: str) -> str:
try:
resolved = shutil.which(command)
return str(Path(resolved).resolve()) if resolved else "not-found"
return str(Path(resolved).absolute()) if resolved else "not-found"
except Exception:
return "not-found"

Expand Down
2 changes: 1 addition & 1 deletion deeplabcut/core/debug/debug_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def _module_path(module_name: str) -> str:
try:
mod = __import__(module_name)
p = getattr(mod, "__file__", None)
return str(Path(p).resolve()) if p else "unknown"
return str(Path(p).absolute()) if p else "unknown"
except Exception:
return "unknown"

Expand Down
2 changes: 1 addition & 1 deletion deeplabcut/create_project/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def add_new_videos(config, videos, copy_videos=False, coords=None, extract_frame
for idx, video in enumerate(videos):
try:
# For windows os.path.realpath does not work and does not link to the real video.
video_path = str(Path.resolve(Path(video)))
video_path = str(Path(video).absolute())
# video_path = os.path.realpath(video)
except Exception:
video_path = os.readlink(video)
Expand Down
2 changes: 1 addition & 1 deletion deeplabcut/create_project/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def load_demo_data(
>>> deeplabcut.load_demo_data('config.yaml')
--------
"""
config = Path(config).resolve()
config = Path(config).absolute()
config = str(config)

transform_data(config)
Expand Down
6 changes: 3 additions & 3 deletions deeplabcut/create_project/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def create_new_project(
date = dt.today().strftime("%Y-%m-%d")
if working_directory is None:
working_directory = "."
wd = Path(working_directory).resolve()
wd = Path(working_directory).absolute()
project_name = f"{project}-{experimenter}-{date}"
project_path = wd / project_name

Expand All @@ -174,7 +174,7 @@ def create_new_project(
for dir, count in files_per_dir.items():
print(f"Found {count} videos in {dir}")
for p in (Path(v) for v in videos if Path(v).is_dir()):
if p.resolve() not in {d.resolve() for d in files_per_dir}:
if p.absolute() not in {d.absolute() for d in files_per_dir}:
print(f"No videos found in {p}")
print(f"Perhaps change the video_extensions, which is currently set to: {video_extensions}")

Expand Down Expand Up @@ -221,7 +221,7 @@ def create_new_project(
try:
# For windows os.path.realpath does not work and does not link to the real
# video. [old: rel_video_path = os.path.realpath(video)]
rel_video_path = str(Path.resolve(Path(video)))
rel_video_path = str(Path(video).absolute())
except Exception:
rel_video_path = os.readlink(str(video))

Expand Down
2 changes: 1 addition & 1 deletion deeplabcut/create_project/new_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def create_new_project_3d(project, experimenter, num_cameras=2, working_director
if working_directory is None:
working_directory = "."

wd = Path(working_directory).resolve()
wd = Path(working_directory).absolute()
project_name = "{pn}-{exp}-{date}-{triangulate}".format(pn=project, exp=experimenter, date=date, triangulate="3d")
project_path = wd / project_name
# Create project and sub-directories
Expand Down
4 changes: 2 additions & 2 deletions deeplabcut/generate_training_dataset/frame_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def extract_frames(

from deeplabcut.utils import auxiliaryfunctions, frameselectiontools

config_file = Path(config).resolve()
config_file = Path(config)
cfg = auxiliaryfunctions.read_config(config_file)
print("Config file read successfully.")

Expand Down Expand Up @@ -456,7 +456,7 @@ def extract_frames(
elif mode == "match":
import cv2

config_file = Path(config).resolve()
config_file = Path(config)
cfg = auxiliaryfunctions.read_config(config_file)
print("Config file read successfully.")
videos = sorted(cfg["video_sets"].keys())
Expand Down
13 changes: 6 additions & 7 deletions deeplabcut/gui/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

from PySide6 import QtWidgets
from PySide6.QtCore import Qt, Slot
from PySide6.QtGui import QIcon

from deeplabcut.core.config import read_config_as_dict
from deeplabcut.gui.dlc_params import DLCParams
from deeplabcut.gui.gui_assets import icon_from_resource
from deeplabcut.gui.widgets import ConfigEditor


Expand Down Expand Up @@ -672,9 +672,9 @@ def _create_message_box(text, info_text):

msg.setWindowTitle("Info")
msg.setMinimumWidth(900)
logo_dir = os.path.dirname(os.path.realpath("logo.png")) + os.path.sep
logo = logo_dir + "/assets/logo.png"
msg.setWindowIcon(QIcon(logo))
# logo = Path("logo.png").resolve().parent / "assets" / "logo.png"
Comment thread
C-Achard marked this conversation as resolved.
Resolved
icon = icon_from_resource("logo.png")
msg.setWindowIcon(icon)
msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
return msg

Expand All @@ -687,9 +687,8 @@ def _create_confirmation_box(title, description):

msg.setWindowTitle("Confirmation")
msg.setMinimumWidth(900)
logo_dir = os.path.dirname(os.path.realpath("logo.png")) + os.path.sep
logo = logo_dir + "/assets/logo.png"
msg.setWindowIcon(QIcon(logo))
icon = icon_from_resource("logo.png")
msg.setWindowIcon(icon)
msg.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
return msg

Expand Down
53 changes: 53 additions & 0 deletions deeplabcut/gui/gui_assets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# DeepLabCut Toolbox (deeplabcut.org)
# © A. & M.W. Mathis Labs
# https://github.com/DeepLabCut/DeepLabCut
#
# Please see AUTHORS for contributors.
# https://github.com/DeepLabCut/DeepLabCut/blob/master/AUTHORS
#
# Licensed under GNU Lesser General Public License v3.0
#
from __future__ import annotations

from importlib.resources import files
from pathlib import Path

from PySide6.QtGui import QIcon, QPixmap

ASSETS_DIR = files("deeplabcut.gui").joinpath("assets")


def resource_bytes(*parts: str) -> bytes:
"""Read a resource bundled inside deeplabcut.gui."""
return ASSETS_DIR.joinpath(*parts).read_bytes()


def resource_text(*parts: str, encoding: str = "utf-8") -> str:
"""Read a text resource bundled inside deeplabcut.gui."""
return ASSETS_DIR.joinpath(*parts).read_text(encoding=encoding)


def get_assets_dir() -> Path:
"""Get the path to the assets directory."""
return Path(ASSETS_DIR)


def get_style_qss() -> str:
"""Get the contents of the style.qss file."""
return resource_text("style.qss")


def pixmap_from_resource(*parts: str) -> QPixmap:
pixmap = QPixmap()
data = resource_bytes(*parts)

if not pixmap.loadFromData(data):
joined = "/".join(parts)
raise FileNotFoundError(f"Could not load GUI resource as QPixmap: {joined}")

return pixmap


def icon_from_resource(*parts: str) -> QIcon:
return QIcon(pixmap_from_resource(*parts))
24 changes: 12 additions & 12 deletions deeplabcut/gui/launch_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@

"""

import os
import logging
import sys

import PySide6.QtWidgets as QtWidgets
import qdarkstyle
from PySide6.QtCore import Qt
from PySide6.QtGui import QIcon, QPixmap

from deeplabcut.gui import BASE_DIR
from deeplabcut.gui.gui_assets import get_style_qss, icon_from_resource, pixmap_from_resource

logger = logging.getLogger(__name__)


def launch_dlc():
app = QtWidgets.QApplication(sys.argv)
app.setWindowIcon(QIcon(os.path.join(BASE_DIR, "assets", "logo.png")))
app.setWindowIcon(icon_from_resource("logo.png"))
screen_size = app.screens()[0].size()
pixmap = QPixmap(os.path.join(BASE_DIR, "assets", "welcome.png")).scaledToWidth(
int(0.7 * screen_size.width()), Qt.SmoothTransformation
)
pixmap = pixmap_from_resource("welcome.png").scaledToWidth(int(0.7 * screen_size.width()), Qt.SmoothTransformation)
splash = QtWidgets.QSplashScreen(pixmap)
splash.show()

stylefile = os.path.join(BASE_DIR, "style.qss")
with open(stylefile) as f:
app.setStyleSheet(f.read())

dark_stylesheet = qdarkstyle.load_stylesheet_pyside2()
app.setStyleSheet(get_style_qss()) # this gets overridden immediately?
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)

# Set up a logger and add an stdout handler.
Expand Down
2 changes: 1 addition & 1 deletion deeplabcut/gui/tabs/analyze_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def _get_unique_video_parent_folders(self, batches: list[tuple[str, list[str]]])

for _, videos in batches:
for video in videos:
parent = str(Path(video).parent.resolve())
parent = str(Path(video).parent.absolute())
if parent not in seen:
seen.add(parent)
folders.append(parent)
Expand Down
6 changes: 3 additions & 3 deletions deeplabcut/gui/tabs/create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
from datetime import datetime

from PySide6 import QtCore, QtWidgets
from PySide6.QtGui import QBrush, QColor, QDesktopServices, QIcon, QPainter, QPen
from PySide6.QtGui import QBrush, QColor, QDesktopServices, QPainter, QPen

from deeplabcut.create_project import create_new_project, create_new_project_3d
from deeplabcut.gui import BASE_DIR
from deeplabcut.gui.dlc_params import DLCParams
from deeplabcut.gui.gui_assets import icon_from_resource
from deeplabcut.gui.tabs.docs import (
URL_3D,
URL_MA_CONFIGURE,
Expand Down Expand Up @@ -235,7 +235,7 @@ def lay_out_user_frame(self):
self.loc_line = QtWidgets.QLineEdit(self.loc_default, user_frame)
self.loc_line.setReadOnly(True)
action = self.loc_line.addAction(
QIcon(os.path.join(BASE_DIR, "assets", "icons", "open2.png")),
icon_from_resource("icons", "open2.png"),
QtWidgets.QLineEdit.TrailingPosition,
)
action.triggered.connect(self.on_click)
Expand Down
4 changes: 2 additions & 2 deletions deeplabcut/gui/tabs/extract_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ def _check_symlink(self, video_path: str | Path) -> Path:
FileNotFoundError if there is no symlink or video in the 'videos' folder for
the given video
"""
video_path = Path(video_path).resolve()
project_videos = (Path(self.root.config).parent / "videos").resolve()
video_path = Path(video_path).absolute()
project_videos = (Path(self.root.config).parent / "videos").absolute()
if video_path.parent == project_videos:
return video_path

Expand Down
11 changes: 5 additions & 6 deletions deeplabcut/gui/tabs/modelzoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@
#
# Licensed under GNU Lesser General Public License v3.0
#
import os
import webbrowser
from functools import partial
from pathlib import Path

import dlclibrary
from PySide6 import QtWidgets
from PySide6.QtCore import QRegularExpression, QSize, Qt, QTimer, Signal, Slot
from PySide6.QtGui import QIcon, QPixmap, QRegularExpressionValidator
from PySide6.QtGui import QRegularExpressionValidator

import deeplabcut
from deeplabcut.core.engine import Engine
from deeplabcut.gui import BASE_DIR
from deeplabcut.gui.components import (
DefaultTab,
VideoSelectionWidget,
Expand All @@ -29,6 +27,7 @@
set_combo_items,
set_layout_contents_visible,
)
from deeplabcut.gui.gui_assets import icon_from_resource, pixmap_from_resource
from deeplabcut.gui.utils import move_to_separate_thread
from deeplabcut.gui.widgets import ClickableLabel
from deeplabcut.pose_estimation_pytorch.apis.utils import TORCHVISION_DETECTORS
Expand Down Expand Up @@ -213,7 +212,7 @@ def _add_output_settings_section(self, layout: QtWidgets.QGridLayout):
)
self.loc_line.setReadOnly(True)
action = self.loc_line.addAction(
QIcon(os.path.join(BASE_DIR, "assets", "icons", "open2.png")),
icon_from_resource("icons", "open2.png"),
QtWidgets.QLineEdit.TrailingPosition,
)
action.triggered.connect(self.select_folder)
Expand Down Expand Up @@ -251,7 +250,7 @@ def _add_tf_scales_row(self, layout: QtWidgets.QGridLayout):
validator.validationChanged.connect(self._handle_validation_change)
self.scales_line.setValidator(validator)
tooltip_label = QtWidgets.QLabel()
tooltip_label.setPixmap(QPixmap(os.path.join(BASE_DIR, "assets", "icons", "help2.png")).scaledToWidth(30))
tooltip_label.setPixmap(pixmap_from_resource("icons", "help2.png").scaledToWidth(30))
tooltip_label.setToolTip(
"Approximate animal sizes in pixels, for spatial pyramid search. If left "
"blank, defaults to video height +/- 50 pixels"
Expand All @@ -269,7 +268,7 @@ def _add_use_adaptation_row(self, layout: QtWidgets.QGridLayout, layout_row: int
self.adapt_checkbox.setStyleSheet("font-weight: bold; font-size: 16px; padding: 6px 12px;")
# Add help button
adapt_help_btn = QtWidgets.QToolButton()
adapt_help_btn.setIcon(QIcon(os.path.join(BASE_DIR, "assets", "icons", "help2.png")))
adapt_help_btn.setIcon(icon_from_resource("icons", "help2.png"))
adapt_help_btn.setIconSize(QSize(24, 24))
adapt_help_btn.setToolTip("What is video adaptation?")

Expand Down
11 changes: 4 additions & 7 deletions deeplabcut/gui/tabs/open_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import os

from PySide6 import QtCore, QtWidgets
from PySide6.QtGui import QIcon

from deeplabcut.gui.gui_assets import icon_from_resource


class OpenProject(QtWidgets.QDialog):
Expand Down Expand Up @@ -76,17 +77,13 @@ def open_project(self):

msg.setWindowTitle("Error")
msg.setMinimumWidth(400)
self.logo_dir = os.path.dirname(os.path.realpath("logo.png")) + os.path.sep
self.logo = self.logo_dir + "/assets/logo.png"
msg.setWindowIcon(QIcon(self.logo))
icon = icon_from_resource("logo.png")
msg.setWindowIcon(icon)
msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
msg.exec_()

self.loaded = False
else:
self.logo_dir = os.path.dirname(os.path.realpath("logo.png")) + os.path.sep
self.logo = self.logo_dir + "/assets/logo.png"

self.loaded = True
self.accept()
self.close()
7 changes: 2 additions & 5 deletions deeplabcut/gui/tabs/train_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
#
from __future__ import annotations

import os
from dataclasses import dataclass

from PySide6 import QtWidgets
from PySide6.QtCore import Qt, Slot
from PySide6.QtGui import QIcon

import deeplabcut.compat as compat
from deeplabcut.core.engine import Engine
Expand All @@ -27,6 +25,7 @@
_create_label_widget,
)
from deeplabcut.gui.displays.selected_shuffle_display import SelectedShuffleDisplay
from deeplabcut.gui.gui_assets import icon_from_resource
from deeplabcut.gui.widgets import ConfigEditor


Expand Down Expand Up @@ -244,9 +243,7 @@ def train_network(self):

msg.setWindowTitle("Info")
msg.setMinimumWidth(900)
self.logo_dir = os.path.dirname(os.path.realpath("logo.png")) + os.path.sep
self.logo = self.logo_dir + "/assets/logo.png"
msg.setWindowIcon(QIcon(self.logo))
msg.setWindowIcon(icon_from_resource("logo.png"))
msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
msg.exec_()

Expand Down
Loading