1 | # UNLESS EXEPTIONALLY REQUIRED TRY TO AVOID IMPORTING ANY MODULES HERE |
---|
2 | # ESPECIALLY ANYTHING IN SAS, SASMODELS NAMESPACE |
---|
3 | from PyQt4 import QtGui |
---|
4 | |
---|
5 | # Local UI |
---|
6 | from sas.qtgui.UI import main_resources_rc |
---|
7 | from UI.MainWindowUI import Ui_MainWindow |
---|
8 | |
---|
9 | # Initialize logging |
---|
10 | import sas.qtgui.Utilities.SasviewLogger |
---|
11 | |
---|
12 | class 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 | |
---|
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 | """ |
---|
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 | |
---|
43 | def 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 | |
---|
69 | if __name__ == "__main__": |
---|
70 | run() |
---|