source: sasview/src/sas/qtgui/MainWindow/MainWindow.py @ 1ba88515

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 1ba88515 was 53c771e, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Converted unit tests

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