diff --git a/brainglobe_utils/napari/__init__.py b/brainglobe_utils/qtpy/__init__.py similarity index 100% rename from brainglobe_utils/napari/__init__.py rename to brainglobe_utils/qtpy/__init__.py diff --git a/brainglobe_utils/napari/brainglobe.png b/brainglobe_utils/qtpy/brainglobe.png similarity index 100% rename from brainglobe_utils/napari/brainglobe.png rename to brainglobe_utils/qtpy/brainglobe.png diff --git a/brainglobe_utils/napari/logo.py b/brainglobe_utils/qtpy/logo.py similarity index 55% rename from brainglobe_utils/napari/logo.py rename to brainglobe_utils/qtpy/logo.py index da5bf46..003b669 100644 --- a/brainglobe_utils/napari/logo.py +++ b/brainglobe_utils/qtpy/logo.py @@ -4,11 +4,14 @@ def _docs_links_widget( - package_name: str, tutorial_file_name: str, parent: QWidget = None + package_name: str, + package_tagline: str, + tutorial_file_name: str, + parent: QWidget = None, ): _docs_links_html = f"""

-

2D Registration

+

{package_tagline}

Website

Tutorial

Source

@@ -20,31 +23,44 @@ def _docs_links_widget( def _logo_widget(package_name: str, parent: QWidget = None): - brainglobe_logo = files("brainglobe.png") + brainglobe_logo = files("brainglobe_utils").joinpath("qtpy/brainglobe.png") _logo_html = f"""

{package_name}

<\h1> - """ + """ # noqa W605 return QLabel(_logo_html, parent=None) def header_widget( - package_name: str, tutorial_file_name: str, parent: QWidget = None + package_name: str, + package_tagline: str, + tutorial_file_name: str, + parent: QWidget = None, ): """ Render HTML in a QGroupBox with a BrainGlobe logo and links to the docs and source code. - Args: - package_name: The name of the package, e.g. "brainrender-napari" - tutorial_file_name: The name of the tutorial file - (must include .html), e.g. "brainrender-napari.html" - parent: The parent widget - Returns: A QGroupBox with the rendered HTML containing the logo and links + Parameters + ---------- + package_name : str + The name of the package, e.g. "brainrender-napari" + package_tagline : str + The tagline for the package + tutorial_file_name : str + The name of the tutorial file (must include .html), + e.g. "brainrender-qtpy.html": str + parent : QWidget + The parent widget, defaults to None + + Returns + ------- + QGroupBox + A QGroupBox with the rendered HTML containing the logo and links """ box = QGroupBox(parent) @@ -52,7 +68,9 @@ def header_widget( box.setLayout(QHBoxLayout()) box.layout().addWidget(_logo_widget(package_name, parent=box)) box.layout().addWidget( - _docs_links_widget(package_name, tutorial_file_name, parent=box) + _docs_links_widget( + package_name, package_tagline, tutorial_file_name, parent=box + ) ) return box diff --git a/tests/tests/test_unit/test_qtpy/__init__.py b/tests/tests/test_unit/test_qtpy/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/tests/test_unit/test_qtpy/test_logo.py b/tests/tests/test_unit/test_qtpy/test_logo.py new file mode 100644 index 0000000..5033419 --- /dev/null +++ b/tests/tests/test_unit/test_qtpy/test_logo.py @@ -0,0 +1,29 @@ +from brainglobe_utils.qtpy.logo import header_widget + + +def test_logo(qtbot): + package_name = "test" + package_tagline = "Tagline" + package_tutorial = "test.html" + + header = header_widget(package_name, package_tagline, package_tutorial) + + qtbot.addWidget(header) + + # header.window().show() + + expected_strings_logo = [package_name, "brainglobe.png"] + expected_strings_docs = [ + package_tagline, + package_tutorial, + "https://brainglobe.info", + "https://github.com", + ] + + assert header.layout().count() == 2 + + for logo_string in expected_strings_logo: + assert logo_string in header.layout().itemAt(0).widget().text() + + for docs_string in expected_strings_docs: + assert docs_string in header.layout().itemAt(1).widget().text()