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