-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostProLoopGui.pyw
More file actions
231 lines (201 loc) · 9.2 KB
/
postProLoopGui.pyw
File metadata and controls
231 lines (201 loc) · 9.2 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!/usr/bin/env python
# -*- coding: latin-1; -*-
# $Id: externalProgramPathGui.pyw 2384 2015-09-22 10:07:54Z papeleux $
#
#
# Gui to configure externals program path according to local configuration
#
## Qt ##
foundQt=0
try:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
foundQt=4
except:
pass
try:
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
foundQt=5
except:
pass
if not foundQt:
raise Exception("PyQt4/5 not found!")
#print "PyQt%d (Qt %s) loaded!" % (foundQt, QT_VERSION_STR)
from prmClassesGui import *
from postProLoop import *
import sys
# avec pythonw : pas de console => les prints sont interdits => redirection des sorties stdout et stderr vers os.devnull !!!
if (sys.executable.split( '\\' )[-1] == 'pythonw.exe'):
sys.stdout = open(os.devnull, 'w')
sys.stderr = open(os.devnull, 'w')
class PostProLoopGui(QWidget):
app = QApplication(sys.argv)
def __init__(self, parent=None):
# parent constructor
QWidget.__init__(self, parent)
# -----------guis datas ----------------
self.guiPRM={}
self.sf={}
# ----------- externalProgramPath ----------------
self.postProLoop = PostProLoop(False)
# ---------- draw frames -------------------------------
# |--------------------------------|
# | BaseDir : |
# | - options |
# |--------------------------------|
# | Matlab : |
# | - options |
# |--------------------------------|
# | GhostScript : |
# | - options |
# |--------------------------------|
# | Python : |
# | - options |
# |--------------------------------|
# | Latex : |
# | - options |
# |--------------------------------|
# | Buttons |
# |--------------------------------|
mainBox = QVBoxLayout()
mainBox.setContentsMargins(2,2,2,2)
self.setLayout(mainBox)
# Application Frame
self.buildApplicationFrame(mainBox)
# Button Box
self.buildButtonFrame(mainBox)
self.resize(500, 450)
self.setWindowTitle('PostPro Loop Utilities')
try:
iconFile = os.path.join(os.path.dirname(os.path.realpath(__file__)), "./Metafor.png")
self.setWindowIcon(QIcon(iconFile))
except:
pass
def buildApplicationFrame(self, box):
appFrame = QFrame()
box.addWidget(appFrame)
#Dir box
self.mesherGrpBox = QGroupBox("Base Directories of post processing")
box.addWidget(self.mesherGrpBox)
grplay1 = QGridLayout()
grplay1.setColumnStretch(2,1)
self.mesherGrpBox.setLayout(grplay1)
self.sf['DIRNAME'] = PathLine (self, grplay1, self.postProLoop.pars['DIRNAME'], 0, 0, 4)
self.sf['MULTITEST'] = CheckBoxLine(self, grplay1, self.postProLoop.pars['MULTITEST'], 1, 0)
self.sf['DIRWILDCARD'] = TextLine (self, grplay1, self.postProLoop.pars['DIRWILDCARD'], 1, 3, 1) #, QIntValidator(-1,100000))
if isUnix():
exeFileType ="Exe files (*)"
else:
exeFileType ="Exe files (*.exe)"
#Matlab box
self.mesherGrpBox = QGroupBox("Matlab")
box.addWidget(self.mesherGrpBox)
grplay2 = QGridLayout()
grplay2.setColumnStretch(2,1)
self.mesherGrpBox.setLayout(grplay2)
self.sf['MATLABRUN'] = CheckBoxLine(self, grplay2, self.postProLoop.pars['MATLABRUN'], 0, 0)
self.sf['MATLABEXE'] = ExeFileLine (self, grplay2, self.postProLoop.pars['MATLABEXE'], exeFileType, 1, 0, 4)
self.sf['MATLABCMD'] = TextLine (self, grplay2, self.postProLoop.pars['MATLABCMD'], 2, 0, 4)
self.sf['MATLABPATH'] = PathLine (self, grplay2, self.postProLoop.pars['MATLABPATH'], 3, 0, 4)
self.sf['MATLABREQUEST'] = TextLine (self, grplay2, self.postProLoop.pars['MATLABREQUEST'], 4, 0, 4)
#GhostScript box
self.mesherGrpBox = QGroupBox("GhostScript (eps -> png)")
box.addWidget(self.mesherGrpBox)
grplay3 = QGridLayout()
grplay3.setColumnStretch(2,1)
self.mesherGrpBox.setLayout(grplay3)
self.sf['GSRUN'] = CheckBoxLine(self, grplay3, self.postProLoop.pars['GSRUN'], 0, 0)
self.sf['GSEXE'] = ExeFileLine (self, grplay3, self.postProLoop.pars['GSEXE'], exeFileType, 1, 0, 4)
self.sf['GSFILTER'] = TextLine (self, grplay3, self.postProLoop.pars['GSFILTER'], 2, 0, 1)
self.sf['GSOUTPUTFORMAT'] = MultiPMRLine(self, grplay3, self.postProLoop.pars['GSOUTPUTFORMAT'],3, 0)
self.sf['GSDEFINITION'] = TextLine (self, grplay3, self.postProLoop.pars['GSDEFINITION'], 3, 3, 1, QIntValidator(72,1800))
self.sf['GSREQUEST'] = TextLine (self, grplay3, self.postProLoop.pars['GSREQUEST'], 4, 0, 1)
#build Latex box
self.mesherGrpBox = QGroupBox("Python")
box.addWidget(self.mesherGrpBox)
grplay4 = QGridLayout()
grplay4.setColumnStretch(2,1)
self.mesherGrpBox.setLayout(grplay4)
self.sf['PYTHONRUN'] = CheckBoxLine(self, grplay4, self.postProLoop.pars['PYTHONRUN'], 0, 0)
self.sf['PYTHONMODULE'] = FileLine (self, grplay4, self.postProLoop.pars['PYTHONMODULE'], '*.py', 1, 0, 4)
self.sf['PYTHONSCRIPT'] = TextLine (self, grplay4, self.postProLoop.pars['PYTHONSCRIPT'], 2, 0, 4)
self.sf['PYTHONREQUEST'] = TextLine (self, grplay4, self.postProLoop.pars['PYTHONREQUEST'], 3, 0, 4)
'''
#build Latex box
self.mesherGrpBox = QGroupBox("Latex")
box.addWidget(self.mesherGrpBox)
grplay5 = QGridLayout()
grplay5.setColumnStretch(2,1)
self.mesherGrpBox.setLayout(grplay5)
self.sf['LATEXRUN'] = CheckBoxLine(self, grplay5, self.postProLoop.pars['LATEXRUN'], 0, 0)
self.sf['LATEXCMD'] = TextLine (self, grplay5, self.postProLoop.pars['LATEXCMD'], 1, 0, 4)
self.sf['LATEXREQUEST'] = TextLine (self, grplay5, self.postProLoop.pars['LATEXREQUEST'], 2, 0, 4)
'''
def buildButtonFrame(self, box):
# == Buttons Frame ==
butframe = QFrame()
box.addWidget(butframe)
butlayout = QHBoxLayout();
butlayout.setContentsMargins(0,0,0,0)
butframe.setLayout(butlayout)
# buttons
self.goButton = QPushButton(self.tr("Go"))
butlayout.addWidget(self.goButton)
self.goButton.pressed.connect(self.go)
self.saveButton = QPushButton(self.tr("Save"))
butlayout.addWidget(self.saveButton)
self.saveButton.pressed.connect(self.save)
self.quitButton = QPushButton(self.tr("Quit"))
butlayout.addWidget(self.quitButton)
self.quitButton.pressed.connect(self.quit)
def updateWidgetsValues(self):
self.postProLoop.applyDependencies()
if self.postProLoop.debug:
print "updateWidgetsValues"
for var in self.sf:
self.sf[var].setParamValue()
def updateWidgetsVisibility(self):
if self.postProLoop.debug:
print "updateWidgetsVisibility"
# update enabled/disabled of options
self.postProLoop.configActions()
for var in self.sf:
self.sf[var].setEnabled(self.postProLoop.pars[var].enabled)
def updateWidgetsValues(self):
if self.postProLoop.debug:
print "updateWidgetsVisibility"
# update enabled/disabled of options
self.postProLoop.configActions()
for var in self.sf:
self.sf[var].setEnabled(self.postProLoop.pars[var].enabled)
def go(self):
if self.postProLoop.debug:
print "Go pressed"
self.postProLoop.go()
def save(self):
if self.postProLoop.debug:
print "Save pressed"
self.postProLoop.savePars('.')
def quit(self):
if self.postProLoop.debug:
print "Quit pressed"
sys.exit()
# ============== Main ========================
def main():
# create gui
confGui = PostProLoopGui()
# opening Gui
confGui.show()
# signal pour cloturer proprement l'application PyQt quand on ferme la fenetre
confGui.app.lastWindowClosed.connect(confGui.app.quit)
#print "ready."
sys.exit(confGui.app.exec_())
if __name__ == "__main__":
try:
import signal
signal.signal(signal.SIGBREAK, sigbreak);
except:
pass
main()