Skip to content

Commit 0a9e3ec

Browse files
samcunliffedstansby
andcommitted
Better function name.
It's not a generic CSS parser but rather Napari-specific. Co-authored-by: David Stansby <[email protected]>
1 parent 88c3673 commit 0a9e3ec

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/napari_matplotlib/base.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from qtpy.QtGui import QIcon
1313
from qtpy.QtWidgets import QVBoxLayout, QWidget
1414

15-
from .util import Interval, from_css_get_size_of
15+
from .util import Interval, from_napari_css_get_size_of
1616

1717
# Icons modified from
1818
# https://github.com/matplotlib/matplotlib/tree/main/lib/matplotlib/mpl-data/images
@@ -194,7 +194,9 @@ class NapariNavigationToolbar(NavigationToolbar2QT):
194194
def __init__(self, *args, **kwargs): # type: ignore[no-untyped-def]
195195
super().__init__(*args, **kwargs)
196196
self.setIconSize(
197-
from_css_get_size_of("QtViewerPushButton", fallback=(28, 28))
197+
from_napari_css_get_size_of(
198+
"QtViewerPushButton", fallback=(28, 28)
199+
)
198200
)
199201

200202
def _update_buttons_checked(self) -> None:

src/napari_matplotlib/tests/test_util.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from qtpy.QtCore import QSize
33

4-
from napari_matplotlib.util import Interval, from_css_get_size_of
4+
from napari_matplotlib.util import Interval, from_napari_css_get_size_of
55

66

77
def test_interval():
@@ -28,19 +28,19 @@ def test_get_size_from_css(mocker):
2828
}
2929
"""
3030
mocker.patch("napari.qt.get_current_stylesheet").return_value = test_css
31-
assert from_css_get_size_of("Flibble", (1, 2)) == QSize(123, 456)
31+
assert from_napari_css_get_size_of("Flibble", (1, 2)) == QSize(123, 456)
3232

3333

3434
def test_fallback_if_missing_dimensions(mocker):
3535
"""Test fallback if given something that doesn't have dimensions"""
3636
test_css = " Flobble { background-color: rgb(0, 97, 163); } "
3737
mocker.patch("napari.qt.get_current_stylesheet").return_value = test_css
3838
with pytest.warns(RuntimeWarning, match="Unable to find DimensionToken"):
39-
assert from_css_get_size_of("Flobble", (1, 2)) == QSize(1, 2)
39+
assert from_napari_css_get_size_of("Flobble", (1, 2)) == QSize(1, 2)
4040

4141

4242
def test_fallback_if_prelude_not_in_css():
4343
"""Test fallback if given something not in the css"""
4444
doesntexist = "AQButtonThatDoesntExist"
4545
with pytest.warns(RuntimeWarning, match=f"Unable to find {doesntexist}"):
46-
assert from_css_get_size_of(doesntexist, (1, 2)) == QSize(1, 2)
46+
assert from_napari_css_get_size_of(doesntexist, (1, 2)) == QSize(1, 2)

src/napari_matplotlib/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _get_dimension(
7272
return None
7373

7474

75-
def from_css_get_size_of(
75+
def from_napari_css_get_size_of(
7676
qt_element_name: str, fallback: Tuple[int, int]
7777
) -> QSize:
7878
"""

0 commit comments

Comments
 (0)