def start_gui(base_dir=None, app_exec=True): """Start the model fitting GUI. Args: base_dir (str): the starting directory for the file opening actions app_exec (boolean): if true we execute the Qt application, set to false to disable. """ try: mdt.configuration.load_user_gui() except IOError: pass app = QtManager.get_qt_application_instance() state = SharedState() state.base_dir = base_dir computations_thread = ComputationsThread() computations_thread.start() # catches the sigint timer = QTimer() timer.start(500) timer.timeout.connect(lambda: None) composite_model_gui = MDTGUISingleModel(state, computations_thread) signal.signal(signal.SIGINT, composite_model_gui.send_sigint) center_window(composite_model_gui) composite_model_gui.show() QtManager.add_window(composite_model_gui) if app_exec: QtManager.exec_()
def start_gui(data=None, config=None, controller=None, app_exec=True, show_maximized=False, window_title=None, enable_directory_watcher=True): """Start the GUI with the given data and configuration. Args: data (DataInfo): the initial set of data config (MapPlotConfig): the initial configuration controller (QtController): the controller to use in the application app_exec (boolean): if true we execute the Qt application, set to false to disable. show_maximized (true): if we want to show the window in a maximized state window_title (str): the title of the window enable_directory_watcher (boolean): if the directory watcher should be enabled/disabled. If the directory watcher is enabled, the viewer will automatically add new maps when added to the folder and also automatically remove maps when they are removed from the directory. It is useful to disable this if you want to have multiple viewers open with old results. Returns: MapsVisualizerWindow: the generated window """ controller = controller or QtController() app = QtManager.get_qt_application_instance() # catches the sigint timer = QTimer() timer.start(500) timer.timeout.connect(lambda: None) main = MapsVisualizerWindow( controller, enable_directory_watcher=enable_directory_watcher) main.set_window_title(window_title) signal.signal(signal.SIGINT, main.send_sigint) center_window(main) if show_maximized: main.showMaximized() main.show() if data: controller.set_data(data, config) elif config: controller.set_config(config) QtManager.add_window(main) if app_exec: QtManager.exec_() return main
def start_gui(data=None, config=None, controller=None, app_exec=True, show_maximized=False, window_title=None): """Start the GUI with the given data and configuration. Args: data (DataInfo): the initial set of data config (MapPlotConfig): the initial configuration controller (mdt.gui.maps_visualizer.base.QtController): the controller to use in the application app_exec (boolean): if true we execute the Qt application, set to false to disable. show_maximized (true): if we want to show the window in a maximized state window_title (str): the title of the window Returns: MapsVisualizerWindow: the generated window """ controller = controller or QtController() enable_pyqt_exception_hook() app = QtManager.get_qt_application_instance() # catches the sigint timer = QTimer() timer.start(500) timer.timeout.connect(lambda: None) main = MapsVisualizerWindow(controller) main.set_window_title(window_title) signal.signal(signal.SIGINT, main.send_sigint) center_window(main) if show_maximized: main.showMaximized() main.show() if data is None: data = SimpleDataInfo({}) controller.apply_action(NewDataAction(data, config=config), store_in_history=False) QtManager.add_window(main) if app_exec: QtManager.exec_() return main