Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit797e460

Browse files
committed
Try custom scrapers
1 parent0be3f7b commit797e460

File tree

2 files changed

+47
-11
lines changed

2 files changed

+47
-11
lines changed

‎docs/conf.py

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# import os
1414
# import sys
1515
# sys.path.insert(0, os.path.abspath('.'))
16-
importqtgallery
16+
fromsphinx_galleryimportscrapers
1717

1818
# -- Project information -----------------------------------------------------
1919

@@ -33,22 +33,59 @@
3333
"sphinx_automodapi.automodapi",
3434
"sphinx_automodapi.smart_resolver",
3535
"sphinx.ext.intersphinx",
36-
"qtgallery",
3736
]
3837

38+
39+
defreset_napari(gallery_conf,fname):
40+
fromnapari.settingsimportget_settings
41+
fromqtpy.QtWidgetsimportQApplication
42+
43+
settings=get_settings()
44+
settings.appearance.theme="dark"
45+
46+
# Disabling `QApplication.exec_` means example scripts can call `exec_`
47+
# (scripts work when run normally) without blocking example execution by
48+
# sphinx-gallery. (from qtgallery)
49+
QApplication.exec_=lambda_:None
50+
51+
52+
defnapari_scraper(block,block_vars,gallery_conf):
53+
"""Basic napari window scraper.
54+
55+
Looks for any QtMainWindow instances and takes a screenshot of them.
56+
57+
`app.processEvents()` allows Qt events to propagateo and prevents hanging.
58+
"""
59+
importnapari
60+
61+
imgpath_iter=block_vars["image_path_iterator"]
62+
63+
ifapp:=napari.qt.get_app():
64+
app.processEvents()
65+
else:
66+
return""
67+
68+
img_paths= []
69+
forwin,img_pathinzip(
70+
reversed(napari._qt.qt_main_window._QtMainWindow._instances),
71+
imgpath_iter,
72+
):
73+
img_paths.append(img_path)
74+
win._window.screenshot(img_path,canvas_only=False)
75+
76+
napari.Viewer.close_all()
77+
app.processEvents()
78+
79+
returnscrapers.figure_rst(img_paths,gallery_conf["src_dir"])
80+
81+
3982
sphinx_gallery_conf= {
4083
"filename_pattern":".",
41-
"image_scrapers": (qtgallery.qtscraper,),
42-
"reset_modules": (qtgallery.reset_qapp,),
84+
"image_scrapers": (napari_scraper,),
85+
"reset_modules": (reset_napari,),
4386
}
4487
suppress_warnings= ["config.cache"]
4588

46-
qtgallery_conf= {
47-
"xvfb_size": (640,480),
48-
"xvfb_color_depth":24,
49-
"xfvb_use_xauth":False,
50-
"xfvb_extra_args": [],
51-
}
5289

5390
numpydoc_show_class_members=False
5491
automodapi_inheritance_diagram=True

‎setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ docs =
5151
numpydoc
5252
pydantic<2
5353
pydata-sphinx-theme
54-
qtgallery
5554
sphinx
5655
sphinx-automodapi
5756
sphinx-gallery

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp