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

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 d6b8a1d was d6b8a1d, checked in by Piotr Rozyczko <rozyczko@…>, 6 years ago

More Qt5 related fixes

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