2020
2121import imageio .v2 as iio
2222import napari
23+ from napari .settings import get_settings
24+ from qtpy .QtWidgets import QApplication
2325from sphinx_gallery import scrapers
2426from sphinx_gallery .sorting import ExampleTitleSortKey
2527
@@ -248,14 +250,11 @@ def napari_scraper(block, block_vars, gallery_conf):
248250
249251 Looks for any QtMainWindow instances and takes a screenshot of them.
250252
251- `app. processEvents()` allows Qt events to propagateo and prevents hanging.
253+ `processEvents()` allows Qt events to propagate and prevents hanging.
252254 """
253255 imgpath_iter = block_vars ["image_path_iterator" ]
254256
255- if app := napari .qt .get_app ():
256- app .processEvents ()
257- else :
258- return ""
257+ QApplication .processEvents ()
259258
260259 img_paths = []
261260 for win , img_path in zip (
@@ -267,15 +266,12 @@ def napari_scraper(block, block_vars, gallery_conf):
267266 win ._window .screenshot (img_path , canvas_only = False )
268267
269268 napari .Viewer .close_all ()
270- app .processEvents ()
269+ QApplication .processEvents ()
271270
272271 return scrapers .figure_rst (img_paths , gallery_conf ["src_dir" ])
273272
274273
275274def reset_napari (gallery_conf , fname ):
276- from napari .settings import get_settings
277- from qtpy .QtWidgets import QApplication
278-
279275 settings = get_settings ()
280276 settings .appearance .theme = "dark"
281277
0 commit comments