def main(): path_icon = str(Path(__file__).parent / 'assets/openmc_logo.png') path_splash = str(Path(__file__).parent / 'assets/splash.png') app = QApplication(sys.argv) app.setOrganizationName("OpenMC") app.setOrganizationDomain("openmc.org") app.setApplicationName("OpenMC Plot Explorer") app.setWindowIcon(QtGui.QIcon(path_icon)) app.setAttribute(QtCore.Qt.AA_DontShowIconsInMenus, True) splash_pix = QtGui.QPixmap(path_splash) splash = QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() splash.setMask(splash_pix.mask()) splash.showMessage("Loading Model...", QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom) app.processEvents() # load OpenMC model on another thread loader_thread = Thread(target=_openmcReload) loader_thread.start() # while thread is working, process app events while loader_thread.is_alive(): app.processEvents() splash.clearMessage() splash.showMessage("Starting GUI...", QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom) app.processEvents() font_metric = QtGui.QFontMetrics(app.font()) screen_size = app.primaryScreen().size() mainWindow = MainWindow(font_metric, screen_size) # connect splashscreen to main window, close when main window opens mainWindow.loadGui() mainWindow.show() splash.close() # connect interrupt signal to close call signal.signal(signal.SIGINT, lambda *args: mainWindow.close()) # create timer that interrupts the Qt event loop # to check for a signal timer = QtCore.QTimer() timer.start(500) timer.timeout.connect(lambda: None) sys.exit(app.exec_())
# load_matlab_engine_and_show_splash_screen() # There is the possibility to disable matlab env, if you don't want to use it. if True: print('Loading Matlab engine.') print('...') pixmap = QPixmap(SONET_DATA_DIR + "splash.png") splash = QSplashScreen(pixmap) splash.show() splash.showMessage("Loading Matlab engine.", alignment=Qt.AlignCenter|Qt.AlignBottom, color=QColor('red')) app.processEvents() matlab_engine = matlab.engine.start_matlab() s = matlab_engine.genpath(SONET_DIR) matlab_engine.addpath(s, nargout=0) splash.showMessage("Matlab engine loaded.", alignment=Qt.AlignCenter|Qt.AlignBottom, color=QColor('red')) print('Matlab engine loaded.') splash.close() else: print("Matlab engine not loaded, some functionality won't be availabe.") main_window = SonetMainWindow() main_window.show() # post_actions(mw=main_window) sys.exit(app.exec_()) # Using fbs module # appctxt = ApplicationContext() # 1. Instantiate ApplicationContext # main_window = SonetMainWindow() # main_window.show() # exit_code = appctxt.app.exec_() # 2. Invoke appctxt.app.exec_()
from os.path import abspath, join, dirname out: QApplication = QApplication(argv) imagen = abspath( join(dirname(__file__), 'config', 'ventana_principal', 'assets', 'fondo.png')) ventana = QWidget() pantalla_de_carga = QSplashScreen(ventana, imagen) pantalla_de_carga.show() from PySide2.QtCore import Qt pantalla_de_carga.setFont(QFont('Segoe Ui SemiBold', 15)) pantalla_de_carga.showMessage( "Cargando...", Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignCenter, QColor('white')) state: State = State() pantalla_de_carga.showMessage( "Cargando fuentes...", Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignCenter, QColor('white')) fuentes: List[str] = cargar_fuentes() pantalla_de_carga.showMessage( "Iniciando AplicaciĆ³n...", Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignCenter, QColor('white')) clase: App = App(fuentes, state) pantalla_de_carga.close() clase.show() exit(out.exec_())