source: sasview/src/sas/qtgui/MainWindow/MainWindow.py @ 8a518285

ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 8a518285 was 3d18691, checked in by Piotr Rozyczko <rozyczko@…>, 6 years ago

New category manager design

  • Property mode set to 100644
File size: 2.5 KB
Line 
1# UNLESS EXEPTIONALLY REQUIRED TRY TO AVOID IMPORTING ANY MODULES HERE
2# ESPECIALLY ANYTHING IN SAS, SASMODELS NAMESPACE
3from PyQt5.QtWidgets import QMainWindow
4from PyQt5.QtWidgets import QMdiArea
5from PyQt5.QtWidgets import QSplashScreen
6from PyQt5.QtWidgets import QApplication
7from PyQt5.QtGui import QPixmap
8
9# Local UI
10from sas.qtgui.UI import main_resources_rc
11from .UI.MainWindowUI import Ui_MainWindow
12
13class MainSasViewWindow(QMainWindow, Ui_MainWindow):
14    # Main window of the application
15    def __init__(self, parent=None):
16        super(MainSasViewWindow, self).__init__(parent)
17        self.setupUi(self)
18
19        # define workspace for dialogs.
20        self.workspace = QMdiArea(self)
21        self.setCentralWidget(self.workspace)
22
23        # Create the gui manager
24        from .GuiManager import GuiManager
25        try:
26            self.guiManager = GuiManager(self)
27        except Exception as ex:
28            import logging
29            logging.error("Application failed with: "+str(ex))
30            print("Application failed with: ", str(ex))
31
32    def closeEvent(self, event):
33        if self.guiManager.quitApplication():
34            event.accept()
35        else:
36            event.ignore()
37
38
39def SplashScreen():
40    """
41    Displays splash screen as soon as humanely possible.
42    The screen will disappear as soon as the event loop starts.
43    """
44    # TODO: standardize path to images
45    pixmap = QPixmap("src/sas/qtgui/images/SVwelcome_mini.png")
46    splashScreen = QSplashScreen(pixmap)
47    return splashScreen
48
49def run_sasview():
50    app = QApplication([])
51
52    # Main must have reference to the splash screen, so making it explicit
53    splash = SplashScreen()
54    splash.show()
55
56    # fix for pyinstaller packages app to avoid ReactorAlreadyInstalledError
57    import sys
58    if 'twisted.internet.reactor' in sys.modules:
59        del sys.modules['twisted.internet.reactor']
60
61    # DO NOT move the following import to the top!
62    # (unless you know what you're doing)
63    import qt5reactor
64    # Using the Qt5 reactor wrapper from https://github.com/ghtdak/qtreactor
65    qt5reactor.install()
66
67    # DO NOT move the following import to the top!
68    from twisted.internet import reactor
69
70    # Show the main SV window
71    mainwindow = MainSasViewWindow()
72    mainwindow.showMaximized()
73
74    # no more splash screen
75    splash.finish(mainwindow)
76
77    # Time for the welcome window
78    mainwindow.guiManager.showWelcomeMessage()
79
80    # No need to .exec_ - the reactor takes care of it.
81    reactor.run()
82
83if __name__ == "__main__":
84    run_sasview()
Note: See TracBrowser for help on using the repository browser.