Skip to content
Open
Changes from all commits
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
16 changes: 12 additions & 4 deletions src/magicgui/backends/_qtpy/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from __future__ import annotations

import math
import platform
import re
import sys
import warnings
from collections.abc import Callable
from contextlib import contextmanager, suppress
Expand Down Expand Up @@ -31,6 +33,14 @@
from magicgui.widgets._concrete import _LabeledWidget
from magicgui.widgets.bases import MenuWidget, Widget

# superqt's workaround for sliders on macOS 12+ with Qt 5 (QTBUG-98093, which Qt
# 6.2.3 fixed): it restyles the sliders, so it's only applied where it's needed
_PATCH_MAC_SLIDERS = (
qtpy.QT5
and sys.platform == "darwin"
and int(platform.mac_ver()[0].split(".", maxsplit=1)[0]) >= 12
)

if TYPE_CHECKING:
from collections.abc import Iterable, Iterator, Sequence

Expand Down Expand Up @@ -979,8 +989,7 @@ class RangeSlider(_Slider):

def __init__(self, **kwargs: Any) -> None:
super().__init__(superqt.QLabeledRangeSlider, **kwargs)
if hasattr(self._qwidget, "applyMacStylePatch"):
# >= magicgui v0.5.2
if _PATCH_MAC_SLIDERS:
self._qwidget.applyMacStylePatch()

def _mgui_set_readout_visibility(self, value: bool):
Expand Down Expand Up @@ -1009,8 +1018,7 @@ class FloatRangeSlider(RangeSlider):

def __init__(self, **kwargs: Any) -> None:
_Slider.__init__(self, superqt.QLabeledDoubleRangeSlider, **kwargs)
if hasattr(self._qwidget, "applyMacStylePatch"):
# >= magicgui v0.5.2
if _PATCH_MAC_SLIDERS:
self._qwidget.applyMacStylePatch()


Expand Down
Loading