[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 |
---|
[f51ed67] | 6 | from UI.MainWindowUI import Ui_MainWindow |
---|
[f721030] | 7 | |
---|
[0cd8612] | 8 | # Initialize logging |
---|
| 9 | import SasviewLogger |
---|
| 10 | |
---|
[f51ed67] | 11 | class MainSasViewWindow(QtGui.QMainWindow, Ui_MainWindow): |
---|
[f721030] | 12 | # Main window of the application |
---|
| 13 | def __init__(self, reactor, parent=None): |
---|
| 14 | super(MainSasViewWindow, self).__init__(parent) |
---|
[f51ed67] | 15 | self.setupUi(self) |
---|
[a95260d] | 16 | |
---|
[f721030] | 17 | # define workspace for dialogs. |
---|
| 18 | self.workspace = QtGui.QWorkspace(self) |
---|
| 19 | self.setCentralWidget(self.workspace) |
---|
| 20 | |
---|
| 21 | # Create the gui manager |
---|
| 22 | from GuiManager import GuiManager |
---|
[9e426c1] | 23 | self.guiManager = GuiManager(self, reactor, self) |
---|
[f721030] | 24 | |
---|
[9e426c1] | 25 | def closeEvent(self, event): |
---|
[7451b88] | 26 | if self.guiManager.quitApplication(): |
---|
| 27 | event.accept() |
---|
| 28 | else: |
---|
| 29 | event.ignore() |
---|
[481ff26] | 30 | |
---|
[a95260d] | 31 | |
---|
[f721030] | 32 | def SplashScreen(): |
---|
| 33 | """ |
---|
| 34 | Displays splash screen as soon as humanely possible. |
---|
| 35 | The screen will disappear as soon as the event loop starts. |
---|
| 36 | """ |
---|
[31c5b58] | 37 | # TODO: standardize path to images |
---|
| 38 | pixmap = QtGui.QPixmap("src/sas/qtgui/images/SVwelcome_mini.png") |
---|
[f721030] | 39 | splashScreen = QtGui.QSplashScreen(pixmap) |
---|
| 40 | return splashScreen |
---|
| 41 | |
---|
[31c5b58] | 42 | def run(): |
---|
[f721030] | 43 | app = QtGui.QApplication([]) |
---|
| 44 | |
---|
| 45 | # Main must have reference to the splash screen, so making it explicit |
---|
| 46 | splash = SplashScreen() |
---|
| 47 | splash.show() |
---|
| 48 | |
---|
| 49 | # DO NOT move the following import to the top! |
---|
| 50 | # (unless you know what you're doing) |
---|
| 51 | import qt4reactor |
---|
| 52 | # Using the Qt4 reactor wrapper from https://github.com/ghtdak/qtreactor |
---|
| 53 | qt4reactor.install() |
---|
| 54 | |
---|
| 55 | # DO NOT move the following import to the top! |
---|
| 56 | from twisted.internet import reactor |
---|
| 57 | |
---|
| 58 | # Show the main SV window |
---|
| 59 | mainwindow = MainSasViewWindow(reactor) |
---|
[0cd8612] | 60 | mainwindow.showMaximized() |
---|
[f721030] | 61 | |
---|
| 62 | # no more splash screen |
---|
| 63 | splash.finish(mainwindow) |
---|
| 64 | |
---|
| 65 | # No need to .exec_ - the reactor takes care of it. |
---|
| 66 | reactor.run() |
---|
| 67 | |
---|
[31c5b58] | 68 | if __name__ == "__main__": |
---|
| 69 | run() |
---|