1 | import sys |
---|
2 | |
---|
3 | from PyQt4 import QtCore |
---|
4 | from PyQt4 import QtGui |
---|
5 | |
---|
6 | # UNLESS EXEPTIONALLY REQUIRED TRY TO AVOID IMPORTING ANY MODULES HERE |
---|
7 | # ESPECIALLY ANYTHING IN SAS, SASMODELS NAMESPACE |
---|
8 | |
---|
9 | # Local UI |
---|
10 | from UI.MainWindowUI import MainWindow |
---|
11 | |
---|
12 | class MainSasViewWindow(MainWindow): |
---|
13 | # Main window of the application |
---|
14 | def __init__(self, reactor, parent=None): |
---|
15 | super(MainSasViewWindow, self).__init__(parent) |
---|
16 | |
---|
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 |
---|
23 | self.guiManager = GuiManager(self, reactor, self) |
---|
24 | |
---|
25 | def closeEvent(self, event): |
---|
26 | from twisted.internet import reactor |
---|
27 | reactor.stop |
---|
28 | event.accept() |
---|
29 | sys.exit() |
---|
30 | |
---|
31 | def SplashScreen(): |
---|
32 | """ |
---|
33 | Displays splash screen as soon as humanely possible. |
---|
34 | The screen will disappear as soon as the event loop starts. |
---|
35 | """ |
---|
36 | pixmap = QtGui.QPixmap("images/SVwelcome_mini.png") |
---|
37 | splashScreen = QtGui.QSplashScreen(pixmap) |
---|
38 | return splashScreen |
---|
39 | |
---|
40 | |
---|
41 | if __name__ == "__main__": |
---|
42 | app = QtGui.QApplication([]) |
---|
43 | |
---|
44 | # Main must have reference to the splash screen, so making it explicit |
---|
45 | splash = SplashScreen() |
---|
46 | splash.show() |
---|
47 | |
---|
48 | # DO NOT move the following import to the top! |
---|
49 | # (unless you know what you're doing) |
---|
50 | import qt4reactor |
---|
51 | # Using the Qt4 reactor wrapper from https://github.com/ghtdak/qtreactor |
---|
52 | qt4reactor.install() |
---|
53 | |
---|
54 | # DO NOT move the following import to the top! |
---|
55 | from twisted.internet import reactor |
---|
56 | |
---|
57 | # Show the main SV window |
---|
58 | mainwindow = MainSasViewWindow(reactor) |
---|
59 | mainwindow.show() |
---|
60 | |
---|
61 | # no more splash screen |
---|
62 | splash.finish(mainwindow) |
---|
63 | |
---|
64 | # No need to .exec_ - the reactor takes care of it. |
---|
65 | reactor.run() |
---|
66 | |
---|