def quit_app(): """Close all windows and quit the QApplication if napari started it.""" QApplication.closeAllWindows() # if we started the application then the app will be named 'napari'. if (QApplication.applicationName() == 'napari' and not _ipython_has_eventloop()): QApplication.quit() # otherwise, something else created the QApp before us (such as # %gui qt IPython magic). If we quit the app in this case, then # *later* attempts to instantiate a napari viewer won't work until # the event loop is restarted with app.exec_(). So rather than # quit just close all the windows (and clear our app icon). else: QApplication.setWindowIcon(QIcon()) if perf.USE_PERFMON: # Write trace file before exit, if we were writing one. # Is there a better place to make sure this is done on exit? perf.timers.stop_trace_file() if config.monitor: # Stop the monitor service if we were using it from ..components.experimental.monitor import monitor monitor.stop() if config.async_loading: # Shutdown the chunkloader from ..components.experimental.chunk import chunk_loader chunk_loader.shutdown()
def _wrapper(self): global QAPP if not QAPP: setup_library_paths() QAPP = QApplication(['']) test_method(self) QAPP.closeAllWindows()
def start_cube_extraction(viewer): """Extract cubes for training""" if not output_filename.exists(): print("No curation results have been saved. " "Please save before extracting cubes") else: print(f"Saving cubes to: {output_directory}") run_extraction( output_filename, output_directory, args.signal_image_paths, args.background_image_paths, args.cube_depth, args.cube_width, args.cube_height, args.voxel_sizes, args.network_voxel_sizes, args.max_ram, args.n_free_cpus, args.save_empty_cubes, ) print("Saving yaml file to use for training") save_yaml_file(output_directory) print("Closing window") QApplication.closeAllWindows() print("Finished! You may now annotate more " "datasets, or go straight to training")
def to_brainrender(self): print("Closing viewer and viewing in brainrender.") QApplication.closeAllWindows() view_in_brainrender( self.scene, self.splines, self.paths.regions_directory, alpha=self.region_alpha.value(), shading=str(self.shading.currentText()), region_to_add=str(self.region_to_render.currentText()), region_alpha=self.structure_alpha.value(), )
def handle_exit(): # if the event loop was started in gui_qt() then the app will be # named 'napari'. Since the Qapp was started by us, just close it. if QApplication.applicationName() == 'napari': QApplication.closeAllWindows() QApplication.quit() # otherwise, something else created the QApp before us (such as # %gui qt IPython magic). If we quit the app in this case, then # *later* attemps to instantiate a napari viewer won't work until # the event loop is restarted with app.exec_(). So rather than # quit just close all the windows (and clear our app icon). else: QApplication.setWindowIcon(QIcon()) self.close()
def handle_exit(): # if the event loop was started in gui_qt() then the app will be # named 'napari'. Since the Qapp was started by us, just close it. if QApplication.applicationName() == 'napari': QApplication.closeAllWindows() QApplication.quit() # otherwise, something else created the QApp before us (such as # %gui qt IPython magic). If we quit the app in this case, then # *later* attempts to instantiate a napari viewer won't work until # the event loop is restarted with app.exec_(). So rather than # quit just close all the windows (and clear our app icon). else: QApplication.setWindowIcon(QIcon()) self.close() if perf.USE_PERFMON: # Write trace file before exit, if we were writing one. # Is there a better place to make sure this is done on exit? perf.timers.stop_trace_file()