source: sasview/src/sas/qtgui/MainWindow/MainWindow.py @ a486918

ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since a486918 was a486918, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 6 years ago

Added missed q range display formatting

  • Property mode set to 100644
File size: 2.6 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
8import sys
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        # Temporary solution for problem with menubar on Mac
24        if sys.platform == "darwin":  # Mac
25            self.menubar.setNativeMenuBar(False)
26
27        # Create the gui manager
28        from .GuiManager import GuiManager
29        try:
30            self.guiManager = GuiManager(self)
31        except Exception as ex:
32            import logging
33            logging.error("Application failed with: "+str(ex))
34
35    def closeEvent(self, event):
36        if self.guiManager.quitApplication():
37            event.accept()
38        else:
39            event.ignore()
40
41def SplashScreen():
42    """
43    Displays splash screen as soon as humanely possible.
44    The screen will disappear as soon as the event loop starts.
45    """
46    # TODO: standardize path to images
47    pixmap = QPixmap("src/sas/qtgui/images/SVwelcome_mini.png")
48    splashScreen = QSplashScreen(pixmap)
49    return splashScreen
50
51def run_sasview():
52    app = QApplication([])
53
54    # Main must have reference to the splash screen, so making it explicit
55    splash = SplashScreen()
56    splash.show()
57
58    # fix for pyinstaller packages app to avoid ReactorAlreadyInstalledError
59    import sys
60    if 'twisted.internet.reactor' in sys.modules:
61        del sys.modules['twisted.internet.reactor']
62
63    # DO NOT move the following import to the top!
64    # (unless you know what you're doing)
65    import qt5reactor
66    # Using the Qt5 reactor wrapper from https://github.com/ghtdak/qtreactor
67    qt5reactor.install()
68
69    # DO NOT move the following import to the top!
70    from twisted.internet import reactor
71
72    # Show the main SV window
73    mainwindow = MainSasViewWindow()
74    mainwindow.showMaximized()
75
76    # no more splash screen
77    splash.finish(mainwindow)
78
79    # Time for the welcome window
80    mainwindow.guiManager.showWelcomeMessage()
81
82    # No need to .exec_ - the reactor takes care of it.
83    reactor.run()
84
85if __name__ == "__main__":
86    run_sasview()
Note: See TracBrowser for help on using the repository browser.