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

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

Changes to allow pyinstaller builds

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[f721030]1# UNLESS EXEPTIONALLY REQUIRED TRY TO AVOID IMPORTING ANY MODULES HERE
2# ESPECIALLY ANYTHING IN SAS, SASMODELS NAMESPACE
[a95260d]3from PyQt4 import QtGui
[f721030]4
5# Local UI
[cd2cc745]6from sas.qtgui.UI import main_resources_rc
[f51ed67]7from UI.MainWindowUI import Ui_MainWindow
[f721030]8
[0cd8612]9# Initialize logging
[83eb5208]10import sas.qtgui.Utilities.SasviewLogger
[0cd8612]11
[f51ed67]12class MainSasViewWindow(QtGui.QMainWindow, Ui_MainWindow):
[f721030]13    # Main window of the application
[6fd4e36]14    def __init__(self, parent=None):
[f721030]15        super(MainSasViewWindow, self).__init__(parent)
[f51ed67]16        self.setupUi(self)
[a95260d]17
[f721030]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
[6fd4e36]24        self.guiManager = GuiManager(self)
[f721030]25
[9e426c1]26    def closeEvent(self, event):
[7451b88]27        if self.guiManager.quitApplication():
28            event.accept()
29        else:
30            event.ignore()
[481ff26]31
[a95260d]32
[f721030]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    """
[31c5b58]38    # TODO: standardize path to images
39    pixmap = QtGui.QPixmap("src/sas/qtgui/images/SVwelcome_mini.png")
[f721030]40    splashScreen = QtGui.QSplashScreen(pixmap)
41    return splashScreen
42
[31c5b58]43def run():
[f721030]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
[2a8bd705]50    # fix for pyinstaller packages app to avoid ReactorAlreadyInstalledError
51    import sys
52    if 'twisted.internet.reactor' in sys.modules:
53        del sys.modules['twisted.internet.reactor']
54
[f721030]55    # DO NOT move the following import to the top!
56    # (unless you know what you're doing)
57    import qt4reactor
58    # Using the Qt4 reactor wrapper from https://github.com/ghtdak/qtreactor
59    qt4reactor.install()
60
61    # DO NOT move the following import to the top!
62    from twisted.internet import reactor
63
64    # Show the main SV window
[6fd4e36]65    mainwindow = MainSasViewWindow()
[0cd8612]66    mainwindow.showMaximized()
[f721030]67
68    # no more splash screen
69    splash.finish(mainwindow)
70
71    # No need to .exec_ - the reactor takes care of it.
72    reactor.run()
73
[31c5b58]74if __name__ == "__main__":
75    run()
Note: See TracBrowser for help on using the repository browser.