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

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

Workaround for the resource file requirement in each UI directory

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