-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexternalProgramPathGui.pyw
More file actions
193 lines (167 loc) · 7.23 KB
/
externalProgramPathGui.pyw
File metadata and controls
193 lines (167 loc) · 7.23 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
#!/usr/bin/env python
# -*- coding: latin-1; -*-
#
# 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 externalProgramPath import *
from prmClassesGui 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 ExtProgsConfGui(QWidget):
app = QApplication(sys.argv)
def __init__(self, parent=None):
# parent constructor
QWidget.__init__(self, parent)
# -----------guis datas ----------------
self.guiPRM={}
self.sf={}
# ----------- externalProgramPath ----------------
self.extProgPath = ExtProgs(verb=False)
# ---------- draw frames -------------------------------
# |--------------------------------|
# | Applications : |
# | - Meshers |
# | - curvePlotter |
# | - image/text |
# |--------------------------------|
# | 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('External Program Configurator for Metafor')
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)
if isUnix():
exeFileType ="Exe files (*)"
else:
exeFileType ="Exe files (*.exe)"
#Mesher box
self.mesherGrpBox = QGroupBox("Meshers")
box.addWidget(self.mesherGrpBox)
grplay1 = QGridLayout()
grplay1.setColumnStretch(2,1)
self.mesherGrpBox.setLayout(grplay1)
if isUnix():
self.sf['SAMCEF'] = ExeFileLine(self, grplay1, self.extProgPath.pars['SAMCEF'], exeFileType, 0, 0, 4)
else:
self.sf['SAMCEF'] = ExeFileLine(self, grplay1, self.extProgPath.pars['SAMCEF'], "cmd files (*.cmd)", 0, 0, 4)
self.sf['GMSH'] = ExeFileLine(self, grplay1, self.extProgPath.pars['GMSH'], exeFileType, 1, 0, 4)
self.sf['TRIANGLE'] = ExeFileLine(self, grplay1, self.extProgPath.pars['TRIANGLE'], exeFileType, 2, 0, 4)
self.sf['TETGEN'] = ExeFileLine(self, grplay1, self.extProgPath.pars['TETGEN'], exeFileType, 3, 0, 4)
self.sf['ISOSURF'] = ExeFileLine(self, grplay1, self.extProgPath.pars['ISOSURF'], exeFileType, 4, 0, 4)
#CurvePlotter box
self.mesherGrpBox = QGroupBox("Post Pro")
box.addWidget(self.mesherGrpBox)
grplay2 = QGridLayout()
grplay2.setColumnStretch(2,1)
self.mesherGrpBox.setLayout(grplay2)
self.sf['MATLAB'] = ExeFileLine(self, grplay2, self.extProgPath.pars['MATLAB'], exeFileType, 0, 0, 4)
self.sf['SCILAB'] = ExeFileLine(self, grplay2, self.extProgPath.pars['SCILAB'], exeFileType, 1, 0, 4)
self.sf['GNUPLOT'] = ExeFileLine(self, grplay2, self.extProgPath.pars['GNUPLOT'], exeFileType, 2, 0, 4)
#Text & image
self.mesherGrpBox = QGroupBox("Text & Image")
box.addWidget(self.mesherGrpBox)
grplay3 = QGridLayout()
grplay3.setColumnStretch(2,1)
self.mesherGrpBox.setLayout(grplay3)
self.sf['LATEX'] = ExeFileLine(self, grplay3, self.extProgPath.pars['LATEX'], exeFileType, 0, 0, 4)
self.sf['GHOSTSCRIPT'] = ExeFileLine(self, grplay3, self.extProgPath.pars['GHOSTSCRIPT'], exeFileType, 1, 0, 4)
self.sf['IMAGEMAGICK'] = ExeFileLine(self, grplay3, self.extProgPath.pars['IMAGEMAGICK'], exeFileType, 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.saveButton1 = QPushButton(self.tr("Local User Save"))
butlayout.addWidget(self.saveButton1)
self.saveButton1.pressed.connect(self.userSave)
self.saveButton2 = QPushButton(self.tr("All Users Save"))
butlayout.addWidget(self.saveButton2)
self.saveButton2.pressed.connect(self.progSave)
self.quitButton = QPushButton(self.tr("Quit"))
butlayout.addWidget(self.quitButton)
self.quitButton.pressed.connect(self.quit)
def updateWidgetsValues(self):
self.extProgPath.applyDependencies()
if self.extProgPath.debug :
print "updateWidgetsValues"
for var in self.sf:
self.sf[var].setParamValue()
def updateWidgetsVisibility(self):
if self.extProgPath.debug :
print "updateWidgetsVisibility"
# update enabled/disabled of options
self.extProgPath.configActions()
for var in self.sf:
self.sf[var].setEnabled(self.extProgPath.pars[var].enabled)
def updateWidgetsValues(self):
if self.extProgPath.debug :
print "updateWidgetsVisibility"
# update enabled/disabled of options
self.extProgPath.configActions()
for var in self.sf:
self.sf[var].setEnabled(self.extProgPath.pars[var].enabled)
def userSave(self):
if self.extProgPath.debug :
print "Save pressed"
self.extProgPath.savePars()
def progSave(self):
if self.extProgPath.debug :
print "Save pressed"
self.extProgPath.savePars('.')
def quit(self):
if self.extProgPath.debug :
print "Quit pressed"
sys.exit()
# ============== Main ========================
def main():
# create gui
confGui = ExtProgsConfGui()
# 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()