source: sasview/src/sas/qtgui/MainWindow/MainWindow.py @ 0849aec

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

Initial, in-progress version. Not really working atm. SASVIEW-787

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[f721030]1# UNLESS EXEPTIONALLY REQUIRED TRY TO AVOID IMPORTING ANY MODULES HERE
2# ESPECIALLY ANYTHING IN SAS, SASMODELS NAMESPACE
[0849aec]3#from PyQt4 import QtGui
4from PyQt5.QtWidgets import *
5from PyQt5.QtGui import *
[f721030]6
7# Local UI
[cd2cc745]8from sas.qtgui.UI import main_resources_rc
[b0b09b9]9from .UI.MainWindowUI import Ui_MainWindow
[f721030]10
[0cd8612]11# Initialize logging
[83eb5208]12import sas.qtgui.Utilities.SasviewLogger
[0cd8612]13
[0849aec]14class MainSasViewWindow(QMainWindow, Ui_MainWindow):
[f721030]15    # Main window of the application
[6fd4e36]16    def __init__(self, parent=None):
[f721030]17        super(MainSasViewWindow, self).__init__(parent)
[f51ed67]18        self.setupUi(self)
[a95260d]19
[f721030]20        # define workspace for dialogs.
[0849aec]21        self.workspace = QMdiArea(self)
[f721030]22        self.setCentralWidget(self.workspace)
23
24        # Create the gui manager
[b0b09b9]25        from .GuiManager import GuiManager
[0849aec]26        try:
27            self.guiManager = GuiManager(self)
28        except Exception as ex:
29            print("EXCEPTION: ", ex)
[f721030]30
[9e426c1]31    def closeEvent(self, event):
[7451b88]32        if self.guiManager.quitApplication():
33            event.accept()
34        else:
35            event.ignore()
[481ff26]36
[a95260d]37
[f721030]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    """
[31c5b58]43    # TODO: standardize path to images
[0849aec]44    pixmap = QPixmap("src/sas/qtgui/images/SVwelcome_mini.png")
45    splashScreen = QSplashScreen(pixmap)
[f721030]46    return splashScreen
47
[31c5b58]48def run():
[0849aec]49    app = QApplication([])
[f721030]50
51    # Main must have reference to the splash screen, so making it explicit
52    splash = SplashScreen()
53    splash.show()
54
[2a8bd705]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
[f721030]60    # DO NOT move the following import to the top!
61    # (unless you know what you're doing)
[0849aec]62    import qt5reactor
[f721030]63    # Using the Qt4 reactor wrapper from https://github.com/ghtdak/qtreactor
[0849aec]64    qt5reactor.install()
[f721030]65
66    # DO NOT move the following import to the top!
67    from twisted.internet import reactor
68
69    # Show the main SV window
[6fd4e36]70    mainwindow = MainSasViewWindow()
[0cd8612]71    mainwindow.showMaximized()
[f721030]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
[31c5b58]79if __name__ == "__main__":
80    run()
Note: See TracBrowser for help on using the repository browser.