-
Notifications
You must be signed in to change notification settings - Fork 1
/
sxm.py
94 lines (78 loc) · 2.54 KB
/
sxm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""The main application"""
# -*- coding: latin-1 -*-
# TODO: make Makefiles platform-independent, then remove generated files from version control
# TODO: when the main window is closed, image windows should be closed as well
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
def main():
# import all the UI classes:
sys.path.insert(0,'.')
sys.path.insert(0,'..') # würg
from gui.mainwindow import MainWindow
import gui.sxmrc
# create main QT application:
app = QApplication(sys.argv)
splashpixmap = QPixmap(":/images/images/splash.png")
splash = QSplashScreen(splashpixmap) #,QtCore.Qt.WindowStaysOnTopHint)
splash.show()
a = Qt.AlignBottom
splash.showMessage("PySPA starting...",a)
app.processEvents()
app.setStyle(QStyleFactory.create("Windows"))
app.setQuitOnLastWindowClosed(True)
# install translator
trans = QTranslator(app)
trans.load(':lang/sxmlang_en.qm')
app.installTranslator(trans)
app.processEvents()
modulestring = "Loading"
modulestring += " SciPy"
splash.showMessage(modulestring,a)
app.processEvents()
import scipy
modulestring += " PIL"
splash.showMessage(modulestring,a)
app.processEvents()
import Image
modulestring += " format plugins"
splash.showMessage(modulestring,a)
app.processEvents()
from SXM import SM3
import SXM.FileIO
SXM.FileIO.init()
modulestring += "."
splash.showMessage(modulestring,a)
app.processEvents()
from SXM import Data
# create and show main window
win = MainWindow(app)
win.show()
splash.finish(win)
# testing: start a dummy worker thread
## worker = DummyThread()
## worker.start()
# run application event loop
app.exec_()
## if not worker.isFinished():
## print "Asking worker thread to finish."
## worker.stop()
## print "Waiting for worker thread to finish..."
## worker.wait()
## else:
## print "Worker thread has already finished."
sys.exit()
class DummyThread(QThread):
def __init__(self):
QThread.__init__(self)
self.count = 0
self.stopped = 0
def run(self):
while (self.count < 10) and not self.stopped:
print "work... (%i)" % (self.count),
self.count += 1
self.sleep(1)
def stop(self):
self.stopped = 1
if __name__ == '__main__':
main()