Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.png filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.ico filter=lfs diff=lfs merge=lfs -text
*.svg filter=lfs diff=lfs merge=lfs -text
1 change: 1 addition & 0 deletions docs/source/_static/custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
document.title = "fastplotlib";
3 changes: 3 additions & 0 deletions docs/source/_static/favicon.ico
Git LFS file not shown
3 changes: 3 additions & 0 deletions docs/source/_static/logo-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/source/_static/logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/source/_static/logo-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/source/_static/logo-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/source/_static/parrot-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/source/_static/parrot-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 13 additions & 6 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
# otherwise fpl tries to select glfw canvas
os.environ["WGPU_FORCE_OFFSCREEN"] = "1"

import fastplotlib
from pygfx.utils.gallery_scraper import find_examples_for_gallery
from pathlib import Path
import sys
from sphinx_gallery.sorting import ExplicitOrder
from pathlib import Path

import imageio.v3 as iio
from pygfx.utils.gallery_scraper import find_examples_for_gallery
from sphinx_gallery.sorting import ExplicitOrder

import fastplotlib

ROOT_DIR = Path(__file__).parents[1].parents[0] # repo root
EXAMPLES_DIR = Path.joinpath(ROOT_DIR, "examples")
Expand Down Expand Up @@ -112,13 +113,19 @@
"name": "Github",
"url": "https://github.com/fastplotlib/fastplotlib",
"icon": "fa-brands fa-github",
}
},
],
"logo": {
"image_light": "_static/logo-light.png",
"image_dark": "_static/logo-dark.png",
},
}

html_static_path = ["_static"]
html_js_files = ["custom.js"]
html_logo = "_static/logo.png"
html_title = f"v{release}"
html_favicon = "_static/favicon.ico"
html_title = ""

autodoc_member_order = "groupwise"
autoclass_content = "both"
Expand Down
2,976 changes: 3 additions & 2,973 deletions docs/source/fastplotlib_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Welcome to fastplotlib's documentation!
=======================================
fastplotlib
===========

.. toctree::
:caption: Getting started
Expand Down
4 changes: 2 additions & 2 deletions fastplotlib/assets/fastplotlib_face_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions fastplotlib/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions fastplotlib/layouts/_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import importlib
from itertools import product
from pathlib import Path

import numpy as np

Expand All @@ -8,6 +9,8 @@

from ..utils.gui import BaseRenderCanvas, RenderCanvas

ICON_PATH = Path(__file__).parent.parent / "assets" / "icon.png"

try:
import imgui_bundle
except ImportError:
Expand Down Expand Up @@ -50,6 +53,8 @@ def make_canvas_and_renderer(
f"renderer option must be a pygfx.Renderer instance such as pygfx.WgpuRenderer"
)

_set_window_icon(canvas)

return canvas, renderer


Expand Down Expand Up @@ -123,3 +128,50 @@ def get_extents_from_grid(
extents.append(extent)

return extents


def _set_window_icon(canvas) -> None:
"""Set the window icon based on canvas type."""
if not ICON_PATH.exists():
return

canvas_name = canvas.__class__.__name__

if canvas_name == "QRenderCanvas":
_set_icon_qt(canvas)
elif canvas_name == "GlfwRenderCanvas":
_set_icon_glfw(canvas)


def _set_icon_glfw(canvas) -> None:
"""Set window icon for GLFW backend."""
try:
import glfw
from PIL import Image
except ImportError:
return

if not hasattr(canvas, "_window"):
return

img = Image.open(ICON_PATH).convert("RGBA")
pixels = np.array(img)
glfw.set_window_icon(canvas._window, 1, [(img.width, img.height, pixels)])


def _set_icon_qt(canvas) -> None:
"""Set window icon for Qt backend."""
try:
from qtpy.QtGui import QIcon
from qtpy.QtWidgets import QApplication
except ImportError:
return

icon = QIcon(str(ICON_PATH))

app = QApplication.instance()
if app is not None:
app.setWindowIcon(icon)

for window in app.topLevelWidgets():
window.setWindowIcon(icon)
Loading