[f721030] | 1 | # UNLESS EXEPTIONALLY REQUIRED TRY TO AVOID IMPORTING ANY MODULES HERE |
---|
| 2 | # ESPECIALLY ANYTHING IN SAS, SASMODELS NAMESPACE |
---|
[a95260d] | 3 | from PyQt4 import QtGui |
---|
[f721030] | 4 | |
---|
| 5 | # Local UI |
---|
[cd2cc745] | 6 | from sas.qtgui.UI import main_resources_rc |
---|
[f51ed67] | 7 | from UI.MainWindowUI import Ui_MainWindow |
---|
[f721030] | 8 | |
---|
[0cd8612] | 9 | # Initialize logging |
---|
[83eb5208] | 10 | import sas.qtgui.Utilities.SasviewLogger |
---|
[0cd8612] | 11 | |
---|
[f51ed67] | 12 | class 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] | 33 | def 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] | 43 | def 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 | |
---|
| 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 |
---|
[6fd4e36] | 60 | mainwindow = MainSasViewWindow() |
---|
[0cd8612] | 61 | mainwindow.showMaximized() |
---|
[f721030] | 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 | |
---|
[31c5b58] | 69 | if __name__ == "__main__": |
---|
| 70 | run() |
---|