forked from mohamedlahdour/ERSN-OpenMC-Py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.py
executable file
·2847 lines (2579 loc) · 128 KB
/
gui.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
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
import os
from datetime import datetime
from PyQt5 import QtCore, QtWidgets, QtPrintSupport, QtGui
from PyQt5.QtCore import *
from PyQt5.QtGui import QTextCursor, QIcon, QKeySequence, QColor, QTextCharFormat, QTextDocument, QTextFormat, \
QFontDatabase
from PyQt5.QtWidgets import *
import time
import subprocess
from PyQt5 import uic # added
import glob
import os.path
from os import path
from PyQt5.QtGui import *
from src.InfoPythonScript import InfoPythonScript
from src.InfoXMLScripts import InfoXMLScripts
from src.ExportPlots import ExportPlots
from src.ExportTallies import ExportTallies
from src.ExportSettings import ExportSettings
from src.ExportGeometry import ExportGeometry
from src.ExportMaterials import ExportMaterials
from src.PyEdit import TextEdit, NumberBar, tab, lineHighlightColor
from src.install import InstallOpenMC
import src.source_rc
from src.syntax_py import Highlighter
from src.image_viewer import QImageViewer
lineBarColor = QColor("#d3d7cf")
lineHighlightColor = QColor("#fce94f")
tab = chr(9)
eof = "\n"
iconsize = QSize(24, 24)
# look if miniconda3 is installed
CONDA = subprocess.run(['which', 'conda'], stdout=subprocess.PIPE, text=True)
CONDA = CONDA.stdout.rstrip('\n')
if "miniconda3" in CONDA:
try:
from src.TallyDataProcessing import TallyDataProcessing
except:
pass
class EmittingStream(QtCore.QObject):
textWritten = QtCore.pyqtSignal(str)
def write(self, text):
self.textWritten.emit(str(text))
pass
def flush(self):
pass
class VLine(QFrame):
# a simple VLine, like the one you get from designer
def __init__(self):
super(VLine, self).__init__()
self.setFrameShape(self.VLine | self.Sunken)
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
class Application(QtWidgets.QMainWindow):
from src.func import Surf,Cell,Hex_Lat,Rec_Lat,Comment,Mat,Settings,Tally
from src.func import Filter,Mesh,Ass_Sep,CMDF,Plot_S,Plot_V
from src.func import showDialog, CursorPosition
def __init__(self, title= "Py_ERSN_OpenMC", parent=None):
super(Application, self).__init__(parent)
from subprocess import Popen, PIPE
#sys.stdout = EmittingStream(textWritten=self.normalOutputWritten)
#sys.stderr = EmittingStream(textWritten=self.normalOutputWritten)
#self.settings = QSettings("PyEdit", "Py_ERSN_OpenMC")
try:
from openmc import __version__
self.openmc_version = int(__version__.split('-')[0].replace('.', ''))
except:
self.showDialog('Warning', 'OpenMC not yet installed !')
self.openmc_version = 0
self.title = title
self.ui = uic.loadUi("src/ui/Interface.ui", self)
self.new_File = False
self.openedFiles = False
self.ploting = False
#self.initUI()
self.radioButton.setChecked(True)
self.directory = ''
self.filename = ''
self.app_dir = os.getcwd()
self.Surfaces_key_list = ['Plane', 'XPlane', 'YPlane', 'ZPlane', 'Sphere', 'XCylinder', 'YCylinder', 'ZCylinder',
'Cone', 'XCone', 'YCone', 'Zcone', 'Quadric', 'XTorus', 'YTorus', 'ZTorus', 'model.hexagonal_prism', 'model.rectangular_prism']
self.Filters_key_list = ['UniverseFilter', 'MaterialFilter', 'CellFilter', 'CellFromFilter', 'CellbornFilter',
'CellInstanceFilter', 'SurfaceFilter', 'MeshFilter', 'MeshSurfaceFilter',
'DistribcellFilter', 'CollisionFilter', 'EnergyFilter', 'EnergyoutFilter',
'MuFilter', 'PolarFilter', 'AzimuthalFilter', 'DelayedGroupFilter', 'EnergyFunctionFilter',
'LegendreFilter', 'SpatialLegendreFilter', 'SphericalHarmonicsFilter', 'ZernikeFilter',
'ZernikeRadialFilter', 'ParticleFilter', 'TimeFilter']
self.Filters_key_sub_list = ['CellFilter', 'CellFromFilter', 'CellbornFilter', 'CellInstanceFilter']
self.clear_Lists()
self.Enrichment = False
self.plots_file_name = ''
# detects available nuclides in cross_section.xml
self.Neutron_XS_List = []
self.TSL_XS_List = []
self.Photon_XS_List = []
process = Popen(["echo $OPENMC_CROSS_SECTIONS"], stdout=PIPE, shell=True)
f = process.communicate()[0].decode('ascii').rstrip('\n')
if not os.path.isfile(f):
f = './bash_scripts/cross_sections.xml'
lines = open(f, 'r').read().split('\n')
for line in lines:
if 'neutron' in line:
item = line.split()
"""if 'materials' in item and '=' in item:
nuclide = item.strip('materials').strip('=').strip().replace('"','')
elif 'materials' in item and '=' not in item:
nuclide = items[items.index(item) + 1].strip().replace('"','')"""
nuclide = line[line.find('materials') + 1: line.find('path')].split('=')[1].rstrip().replace('"', '')
self.Neutron_XS_List.append(nuclide)
elif 'thermal' in line:
tsl = line[line.find('materials') + 1: line.find('path')].split('=')[1].rstrip().replace('"', '')
self.TSL_XS_List.append(tsl)
elif 'photon' in line or 'wmp' in line:
element = line[line.find('materials') + 1: line.find('path')].split('=')[1].rstrip().replace('"', '')
self.Photon_XS_List.append(element)
self.available_xs = [self.Neutron_XS_List, self.TSL_XS_List, self.Photon_XS_List]
self.xml_file_names_list = ['geometry.xml', 'materials.xml', 'settings.xml', 'tallies.xml', 'plots.xml', 'cmfd.xml']
#self.statusBar().addPermanentWidget(VLine())
self.statusBar().setStyleSheet("color : blue")
# this part is added to allow myEditor to work
# Brackets ExtraSelection ...
self.left_selected_bracket = QTextEdit.ExtraSelection()
self.right_selected_bracket = QTextEdit.ExtraSelection()
self.fname = ""
self.words = []
self.root = QDir.currentPath()
self.wordList = []
self.appfolder = self.root
self.openPath = ""
self.MaxRecentFiles = 15
self.windowList = []
self.recentFileActs = []
self.settings = QSettings("PyEdit", "PyEdit")
self.dirpath = QDir.homePath() + "$HOME/Documents/python_files/"
self.setAttribute(Qt.WA_DeleteOnClose)
self.setWindowIcon(QIcon("src/icons/python3.png"))
self.createActions()
self.line = 0
self.pos = 0
#myEditor()
self.editor_tool_bar()
self.editor_menu()
self.editor_core()
self.initUI()
sys.stdout = EmittingStream(textWritten=self.normalOutputWritten)
#sys.stderr = EmittingStream(textWritten=self.normalOutputWritten)
self._initButtons()
if self.tabWidget.currentWidget().objectName() == 'tab_python': # python script window
#self.toolBar_1.setEnabled(True)
self.toolBar_2.setEnabled(True)
self.toolBar_4.setEnabled(True)
self.editor = self.plainTextEdit_7
else:
#self.toolBar_1.setEnabled(False)
self.toolBar_2.setEnabled(False)
self.toolBar_4.setEnabled(False)
self.checkbox.setChecked(True)
# addapt GUI size to screen dimensions
self.resize_ui()
def _initButtons(self):
self.pushButton_20.clicked.connect(self.Surf)
self.pushButton_21.clicked.connect(self.Cell)
self.pushButton_22.clicked.connect(self.Comment)
self.pushButton_23.clicked.connect(self.Hex_Lat)
self.pushButton_24.clicked.connect(self.Rec_Lat)
self.pushButton_29.clicked.connect(self.Filter)
self.pushButton_25.clicked.connect(self.Mat)
self.pushButton_27.clicked.connect(self.Tally)
self.pushButton_26.clicked.connect(self.Comment)
self.pushButton_15.clicked.connect(self.createGeom)
self.pushButton_28.clicked.connect(self.Comment)
self.pushButton_30.clicked.connect(self.Mesh)
self.pushButton_31.clicked.connect(self.Ass_Sep)
self.pushButton_33.clicked.connect(self.Plot_S)
self.pushButton_32.clicked.connect(self.Comment)
self.pushButton_34.clicked.connect(self.Plot_V)
self.pushButton_19.clicked.connect(self.Run_OpenMC)
self.comboBox_3.currentIndexChanged.connect(self.Settings)
self.comboBox_4.currentIndexChanged.connect(self.CMDF)
self.actionExit.triggered.connect(self.Exit)
self.actionHelp.triggered.connect(self.Help)
self.actionAbout.triggered.connect(self.About)
self.actionClose_Project.triggered.connect(self.Close_Project)
self.pB_Clear_OW_2.clicked.connect(self.clear_text)
self.actionGet_OpenMC.triggered.connect(self.Get_OpenMC)
self.pushButton.clicked.connect(self.Python_Materials)
self.pushButton_2.clicked.connect(self.Python_Geometry)
self.pushButton_3.clicked.connect(self.Python_Settings)
self.pushButton_4.clicked.connect(self.Python_Tallies)
self.pushButton_5.clicked.connect(self.Python_Plots)
self.actionAlign_Left.triggered.connect(self.Align_Left)
self.actionAlign_Right.triggered.connect(self.Align_Right)
self.actionAlign_Center.triggered.connect(self.Align_Center)
self.actionAlign_Justify.triggered.connect(self.Align_Justify)
self.actionXML_Validation.triggered.connect(self.XML_Validation)
self.action2D_Slice.triggered.connect(self.View_2D)
self.actionDump_sammay_h5.triggered.connect(self.Dump_H5)
self.actionEdit_Tallies_out.triggered.connect(self.Tallies_View)
self.actionVoxels_to_VTI.triggered.connect(self.Voxels_to_VTI)
self.actionTracks_to_VTI.triggered.connect(self.Tracks_to_VTI)
self.actionTally_Data_Processing.triggered.connect(self.Python_TallyDataProcessing)
self.action3D_Voxels_3.triggered.connect(self.View_3D)
self.actionView_Track.triggered.connect(self.View_Track)
self.tabWidget.currentChanged.connect(self.editor_id)
self.tabWidget_3.currentChanged.connect(self.editor_id)
self.RunMode_CB.currentIndexChanged.connect(self.SetRunMode)
self.radioButton.toggled.connect(self.RunPB_State)
self.tabWidget.currentChanged.connect(self.Update_StatusBar)
# self.plainTextEdit_7.blockCountChanged.connect(self.detect_components)
self.plainTextEdit_7.textChanged.connect(self.detect_components)
def initUI(self):
# defining widgets in statusBar
# self.statusBar().showMessage(self.appfolder)
self.lineLabel1 = QLabel("Project")
self.lineLabel2 = QLabel()
self.lineLabel3 = QLabel("Cursor position")
self.lineLabel2.setAlignment(QtCore.Qt.AlignCenter)
self.lineLabel3.setAlignment(QtCore.Qt.AlignCenter)
widget = QWidget(self)
widget.setLayout(QHBoxLayout())
widget.layout().addWidget(self.lineLabel1)
widget.layout().addWidget(VLine())
widget.layout().addWidget(self.lineLabel2)
widget.layout().addWidget(VLine())
widget.layout().addWidget(self.lineLabel3)
self.statusBar().addWidget(widget, 1)
self.editor_id()
self.CursorPositionChanged()
# The program below adds tooltip messages to the buttons.
self.pushButton_20.setToolTip(
'Each <surface> element can have the following attributes or sub-elements: \n'
'id: A unique integer that can be used to identify the surface. Default: None\n'
'type: The type of the surfaces. This can be “x-plane”, “y-plane”, “z-plane”, “plane”, “x-cylinder”, “y-cylinder”, “z-cylinder”, “sphere”,“x-cone”,\n'
'“y-cone”, “z-cone”, or “quadric”. Default: None\n'
'coeffs: The corresponding coefficients for the given type of surface. See below for a list a what coefficients to specify for a given surface. \n'
'Default: None\n\n'
'boundary: The boundary condition for the surface. This can be “periodic”, “vacuum”, “reflective” or “white”. Default: “transmissive” \n\n'
'More information can be found in : https://openmc.readthedocs.io/en/stable/usersguide/index.html')
self.pushButton_21.setToolTip(
'Each <cell> element can have the following attributes or sub-elements:\n'
'- id: A unique integer that can be used to identify the surface. Default: None\n'
'- universe: The id of the universe that this cell is contained in. Default: 0\n'
'- fill: The id of the universe that fills this cell.\n'
'- material: The id of the material that this cell contains. If the cell should contain no material, this can also be set to “void”. Default: None\n'
'- region: A list of the ids for surfaces that bound this cell, e.g. if the cell is on the negative side of surface 3 and the positive side of \n'
'surface 5, the bounding surfaces would be given as “-3 5”. \n'
'Note: space means intersection operator, | means union operator and Gui_orig.\n'
'and the Complement of an existing openmc.Region can be created by using the ~ operator\n'
'- rotation: If the cell is filled with a universe, this element specifies the angles in degrees about the x, y, and z axes that the filled universe\n'
'should be rotated. Should be given as three real numbers. Rotation can be omitted if no rotation is applyed. Default: None\n'
'- translation: If the cell is filled with a universe, this element specifies a vector that is used to translate (shift) the universe. Should be given\n'
'as three real numbers. Translation can be omitted if no translation is applyed. Default: None\n\n'
'More information can be found in : https://openmc.readthedocs.io/en/stable/usersguide/index.html')
self.pushButton_23.setToolTip("<b>HTML</b> <i>can</i> be shown too..")
def editor_tool_bar(self):
self.actionNew = QAction(QIcon("src/icons/new_project.png"), "&New Project", self, shortcut=QKeySequence.New,
statusTip="new project", triggered=self.NewFiles)
self.toolBar.addAction(self.actionNew)
self.newAct = QAction(QIcon("src/icons/new24.png"), "&New File", self, shortcut=QKeySequence.New,
statusTip="new file", triggered=self.newFile)
self.toolBar.addAction(self.newAct)
self.actionOpen = QAction(QIcon("src/icons/open24.png"), "&Open Project", self, shortcut=QKeySequence.Open,
statusTip="open project", triggered=self.OpenFiles)
self.toolBar.addAction(self.actionOpen)
self.actionSave = QAction(QIcon("src/icons/document-save.png"), "&Save Project", self, shortcut=QKeySequence.Save,
statusTip="save files", triggered=self.SaveFiles)
self.toolBar.addAction(self.actionSave)
self.actionSave_as = QAction(QIcon("src/icons/document-save-as.png"), "Sa&ve Project as", self, shortcut=QKeySequence.SaveAs,
statusTip="save file as", triggered=self.SaveAsFiles)
self.toolBar.addAction(self.actionSave_as)
####################################################################################################
self.toolBar.addSeparator()
self.actionCut = QAction(QIcon("src/icons/cut_text.png"), "&Cut", self, shortcut=QKeySequence.Cut,
statusTip="cut", triggered=self.Cut)
self.toolBar.addAction(self.actionCut)
self.actionCopy = QAction(QIcon("src/icons/copy_text.png"), "&Copy", self, shortcut=QKeySequence.Copy,
statusTip="copy", triggered=self.Copy)
self.toolBar.addAction(self.actionCopy)
self.actionPaste = QAction(QIcon("src/icons/paste_text.png"), "&Paste", self, shortcut=QKeySequence.Paste,
statusTip="paste", triggered=self.Paste)
self.toolBar.addAction(self.actionPaste)
self.actionUndo = QAction(QIcon("src/icons/undo_text.png"), "&Undo", self, shortcut=QKeySequence.Undo,
statusTip="undo", triggered=self.Undo)
self.toolBar.addAction(self.actionUndo)
self.actionRedo = QAction(QIcon("src/icons/redo_text.png"), "&Redo", self, shortcut=QKeySequence.Redo,
statusTip="redo", triggered=self.Redo)
self.toolBar.addAction(self.actionRedo)
self.toolBar.addSeparator()
####################################################################################################
self.toolBar_2 = QToolBar()
self.toolBar.addWidget(self.toolBar_2)
### comment buttons
self.commentAct = QAction(QIcon("src/icons/comment.png"), "#comment Line", self, shortcut="F2",
statusTip="comment Line (F2)", triggered=self.commentLine)
self.toolBar_2.addAction(self.commentAct)
self.uncommentAct = QAction(QIcon("src/icons/uncomment.png"), "uncomment Line", self, shortcut="F3",
statusTip="uncomment Line (F3)", triggered=self.uncommentLine)
self.toolBar_2.addAction(self.uncommentAct)
self.commentBlockAct = QAction(QIcon("src/icons/commentBlock.png"), "comment Block", self, shortcut="F6",
statusTip="comment selected block (F6)", triggered=self.commentBlock)
self.toolBar_2.addAction(self.commentBlockAct)
self.uncommentBlockAct = QAction(QIcon("src/icons/uncommentBlock.png"), "uncomment Block (F7)", self,
shortcut="F7",
statusTip="uncomment selected block (F7)", triggered=self.uncommentBlock)
self.toolBar_2.addAction(self.uncommentBlockAct)
self.toolBar_2.addSeparator()
### color chooser
self.toolBar_2.addAction(QIcon('src/icons/color1.png'), "insert QColor", self.insertColor)
self.toolBar_2.addAction(QIcon('src/icons/color.png'), "change Color", self.changeColor)
####################################################################################################
self.toolBar.addSeparator()
self.toolBar_3 = QToolBar()
self.toolBar.addWidget(self.toolBar_3)
self.indentAct = QAction(QIcon("src/icons/format-indent-more.png"), "indent more, select text to indent", self,
triggered=self.indentLine,
shortcut="F8")
self.indentLessAct = QAction(QIcon("src/icons/format-indent-less.png"), "indent less, select text to indent", self,
triggered=self.indentLessLine, shortcut="F9")
self.toolBar_3.addAction(self.indentAct)
self.toolBar_3.addAction(self.indentLessAct)
self.toolBar_3.addSeparator()
### save as pdf
self.pdfAct = QAction(QIcon("src/icons/pdf.png"), "export PDF", self, shortcut="Ctrl+Shift+p",
statusTip="save file as PDF", triggered=self.exportPDF)
self.toolBar_3.addAction(self.pdfAct)
### print preview
self.printPreviewAct = QAction(QIcon("src/icons/document-print-preview.png"), "Print Preview", self,
shortcut="Ctrl+Shift+P",
statusTip="Preview Document", triggered=self.handlePrintPreview)
self.toolBar_3.addAction(self.printPreviewAct)
### print
self.printAct = QAction(QIcon("src/icons/document-print.png"), "Print", self, shortcut=QKeySequence.Print,
statusTip="Print Document", triggered=self.handlePrint)
self.toolBar_3.addAction(self.printAct)
self.comboSize = QComboBox(self.toolBar_3)
self.toolBar_3.addSeparator()
self.comboSize.setObjectName("comboSize")
self.toolBar_3.addWidget(self.comboSize)
self.comboSize.setEditable(True)
db = QFontDatabase()
for size in db.standardSizes():
self.comboSize.addItem("%s" % (size))
self.comboSize.addItem("%s" % (90))
self.comboSize.addItem("%s" % (100))
self.comboSize.addItem("%s" % (160))
self.comboSize.activated[str].connect(self.textSize)
self.comboSize.setCurrentIndex(
self.comboSize.findText(
"%s" % (QApplication.font().pointSize())))
self.bgAct = QAction(QIcon("src/icons/sbg_color.png"), "change Background Color", self,
triggered=self.changeBGColor)
self.bgAct.setStatusTip("change Background Color")
self.toolBar_3.addAction(self.bgAct)
self.toolBar.addSeparator()
# checkBox for highlighting
self.checkbox = QCheckBox('Highlighting', self)
self.toolBar.addWidget(self.checkbox)
self.checkbox.stateChanged.connect(self.HLAct)
### show / hide shellWin
self.toolBar.addSeparator()
self.shToggleAction = QAction(QIcon("src/icons/close-terminal.png"), "show/ hide shell window", self,
statusTip="show/ hide shell window", triggered=self.handleShellWinToggle)
self.shToggleAction.setCheckable(True)
self.toolBar.addAction(self.shToggleAction)
self.toolBar_4 = QToolBar()
self.toolBar.addWidget(self.toolBar_4)
### path python buttons
self.py3Act = QAction(QIcon('src/icons/run.png'), "run in Python 3 (F5)", self, shortcut="F5",
statusTip="run in Python 3 (F5)", triggered=self.runPy3)
self.toolBar_4.addAction(self.py3Act)
self.toolBar_4.addAction(QIcon("src/icons/eraser.png"), "Clear output", self.clearLabel)
self.toolBar_3 = QToolBar()
self.toolBar.addWidget(self.toolBar_3)
self.killPyAct = QAction(QIcon('src/icons/close.png'), "kill process (F12)", self, shortcut="F12",
statusTip="kill process (F12)", triggered=self.killPython)
self.toolBar_3.addAction(self.killPyAct)
self.toolBar.addSeparator()
####################################################################################################
### find / replace toolbar
#self.addToolBarBreak()
tbf = self.addToolBar("Find")
tbf.setContextMenuPolicy(Qt.PreventContextMenu)
tbf.setMovable(False)
tbf.setIconSize(QSize(iconsize))
self.findfield = QLineEdit()
self.findfield.addAction(QIcon("icons/edit-find.png"), QLineEdit.LeadingPosition)
self.findfield.setClearButtonEnabled(True)
self.findfield.setFixedWidth(150)
self.findfield.setPlaceholderText("find")
self.findfield.setToolTip("press RETURN to find")
self.findfield.setText("")
ft = self.findfield.text()
self.findfield.returnPressed.connect(self.findText)
tbf.addWidget(self.findfield)
self.replacefield = QLineEdit()
self.replacefield.addAction(QIcon("src/icons/edit-find-replace.png"), QLineEdit.LeadingPosition)
self.replacefield.setClearButtonEnabled(True)
self.replacefield.setFixedWidth(150)
self.replacefield.setPlaceholderText("replace with")
self.replacefield.setToolTip("press RETURN to replace the first")
self.replacefield.returnPressed.connect(self.replaceOne)
tbf.addSeparator()
tbf.addWidget(self.replacefield)
tbf.addSeparator()
self.repAllAct = QPushButton("replace all")
self.repAllAct.setFixedWidth(100)
self.repAllAct.setIcon(QIcon("src/icons/edit-find-replace.png"))
self.repAllAct.setStatusTip("replace all")
self.repAllAct.clicked.connect(self.replaceAll)
tbf.addWidget(self.repAllAct)
tbf.addSeparator()
self.gotofield = QLineEdit()
self.gotofield.addAction(QIcon("src/icons/go-next.png"), QLineEdit.LeadingPosition)
self.gotofield.setClearButtonEnabled(True)
self.gotofield.setFixedWidth(120)
self.gotofield.setPlaceholderText("go to line")
self.gotofield.setToolTip("press RETURN to go to line")
self.gotofield.returnPressed.connect(self.gotoLine)
tbf.addWidget(self.gotofield)
tbf.addSeparator()
# add ComboBox for rescaling factor
ComboBox_label = QLabel('Rescale Factor', self)
self.comboBox = QComboBox()
self.comboBox.addItems(['1', '0.9', '0.8', '0.7', '0.6', '0.5'])
tbf.addWidget(ComboBox_label)
tbf.addWidget(self.comboBox)
self.comboBox.currentIndexChanged.connect(self.resize_ui)
## addStretch
empty = QWidget();
empty.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred);
tbf.addWidget(empty)
tbf.addSeparator()
self.exitAct = QAction(QIcon("src/icons/quit.png"), "exit", self, shortcut=QKeySequence.Quit,
statusTip="Exit", triggered=self.Exit)
tbf.addAction(self.exitAct)
##############################################################################################""""""
def editor_menu(self):
# project menu
self.projectmenu = self.menubar.addMenu("Project")
self.separatorAct = self.projectmenu.addSeparator()
self.projectmenu.addAction(self.actionNew)
self.projectmenu.addAction(self.actionOpen)
self.projectmenu.addAction(self.actionSave)
self.projectmenu.addAction(self.actionSave_as)
self.projectmenu.addSeparator()
self.projectmenu.addAction(self.actionClose_Project)
self.projectmenu.addSeparator()
self.projectmenu.addAction(self.actionExit)
self.projectmenu.addSeparator()
### file buttons
self.filemenu = self.menubar.addMenu("File")
self.filemenu.addSeparator()
self.filemenu.addSeparator()
'''self.newAct = QAction(QIcon("src/icons/new24.png"), "&New", self, shortcut=QKeySequence.New,
statusTip="new file", triggered=self.newFile)'''
self.filemenu.addAction(self.newAct)
self.filemenu.addAction(self.actionOpen)
self.filemenu.addAction(self.actionSave)
self.filemenu.addAction(self.actionSave_as)
self.filemenu.addSeparator()
self.filemenu.addAction(self.pdfAct)
self.filemenu.addSeparator()
for i in range(self.MaxRecentFiles):
self.filemenu.addAction(self.recentFileActs[i])
try:
self.updateRecentFileActions()
except:
pass
self.filemenu.addSeparator()
self.clearRecentAct = QAction(QIcon("src/icons/close.png"), "clear Recent Files List", self,
triggered=self.clearRecentFiles)
self.filemenu.addAction(self.clearRecentAct)
self.filemenu.addSeparator()
self.filemenu.addAction(self.exitAct)
# tools menu
self.toolsmenu = self.menubar.addMenu("Tools")
self.separatorAct = self.toolsmenu.addSeparator()
self.toolsmenu.addAction(self.actionXML_Validation)
self.separatorAct = self.toolsmenu.addSeparator()
self.submenu1 = self.toolsmenu.addMenu("View output")
self.separatorAct = self.toolsmenu.addSeparator()
self.submenu1.addAction(self.actionEdit_Tallies_out)
self.separatorAct = self.submenu1.addSeparator()
self.submenu1.addAction(self.actionDump_sammay_h5)
self.separatorAct = self.toolsmenu.addSeparator()
self.submenu2 = self.toolsmenu.addMenu("View geometry")
self.separatorAct = self.toolsmenu.addSeparator()
self.submenu2.addAction(self.action2D_Slice)
self.separatorAct = self.submenu2.addSeparator()
self.submenu2.addAction(self.action3D_Voxels_3)
self.separatorAct = self.toolsmenu.addSeparator()
self.submenu3 = self.toolsmenu.addMenu("Convert H to VTI file")
self.separatorAct = self.toolsmenu.addSeparator()
self.submenu3.addAction(self.actionVoxels_to_VTI)
self.separatorAct = self.submenu3.addSeparator()
self.submenu3.addAction(self.actionTracks_to_VTI)
self.separatorAct = self.toolsmenu.addSeparator()
self.toolsmenu.addAction(self.actionView_Track)
self.separatorAct = self.toolsmenu.addSeparator()
self.toolsmenu.addAction(self.actionTally_Data_Processing)
self.separatorAct = self.toolsmenu.addSeparator()
# get openmc menu
self.getOpenMCmenu = self.menubar.addMenu("Get OpenMC")
self.separatorAct = self.getOpenMCmenu.addSeparator()
self.getOpenMCmenu.addAction(self.actionGet_OpenMC)
self.separatorAct = self.getOpenMCmenu.addSeparator()
# about menu
self.toolsmenu = self.menubar.addMenu("About")
self.separatorAct = self.toolsmenu.addSeparator()
self.toolsmenu.addAction(self.actionAbout)
# help menu
self.toolsmenu = self.menubar.addMenu("Help")
self.separatorAct = self.toolsmenu.addSeparator()
self.toolsmenu.addAction(self.actionHelp)
def editor_core(self):
from PyQt5.QtGui import QTextOption
# add new editor for python window
U_layout = QGridLayout()
U_widgets = QWidget()
D_layout = QGridLayout()
self.D_widgets = QWidget()
U_widgets.setLayout(U_layout)
self.D_widgets.setLayout(D_layout)
self.plainTextEdit_7 = TextEdit()
self.numbers = NumberBar(self.plainTextEdit_7)
self.shellWin = TextEdit() # QTextEdit()
self.shellWin.setContextMenuPolicy(Qt.CustomContextMenu)
layoutH7 = QHBoxLayout()
layoutH7.addWidget(self.numbers)
layoutH7.addWidget(self.plainTextEdit_7)
layoutH7_ = QVBoxLayout()
layoutH7_.addWidget(self.shellWin)
U_layout.addLayout(layoutH7, 0, 0)
D_layout.addLayout(layoutH7_, 0, 0)
splitter1 = QSplitter(Qt.Vertical, frameShape=QFrame.NoFrame, frameShadow=QFrame.Plain, lineWidth=0)
splitter1.addWidget(U_widgets)
splitter1.addWidget(self.D_widgets)
splitter1.setSizes([450, 100])
self.EditorLayout.addWidget(splitter1)
# add new editor for output window
self.plainTextEdit_8 = TextEdit()
self.numbers = NumberBar(self.plainTextEdit_8)
layoutH8 = QHBoxLayout()
#layoutH8.setSpacing(1.5)
layoutH8.addWidget(self.numbers)
layoutH8.addWidget(self.plainTextEdit_8)
self.OutputEditor.addLayout(layoutH8, 0, 0)
# add new editor for xml windows
self.plainTextEdit_1 = TextEdit()
if self.tabWidget.currentWidget().objectName() == 'tab_python': # python script window
self.editor = self.plainTextEdit_7
elif self.tabWidget.currentWidget().objectName() == 'tab_xml': # xml script window
self.editor = self.plainTextEdit_1
elif self.tabWidget.currentWidget().objectName() == 'tab_run': # output window
self.editor = self.plainTextEdit_8
self.editor.setWordWrapMode(QTextOption.NoWrap)
self.highlighter = Highlighter(self.editor.document())
self.editor.setContextMenuPolicy(Qt.CustomContextMenu)
self.editor.customContextMenuRequested.connect(self.contextMenuRequested)
self.readSettings()
self.numbers = NumberBar(self.plainTextEdit_1)
layoutH = QHBoxLayout()
#layoutH.setSpacing(1.5)
layoutH.addWidget(self.numbers)
layoutH.addWidget(self.plainTextEdit_1)
self.GeomEditor.addLayout(layoutH, 0, 0)
#
self.plainTextEdit_2 = TextEdit()
self.numbers = NumberBar(self.plainTextEdit_2)
layoutH2 = QHBoxLayout()
#layoutH2.setSpacing(1.5)
layoutH2.addWidget(self.numbers)
layoutH2.addWidget(self.plainTextEdit_2)
self.MatEditor.addLayout(layoutH2, 0, 0)
#
self.plainTextEdit_3 = TextEdit()
self.numbers = NumberBar(self.plainTextEdit_3)
layoutH3 = QHBoxLayout()
#layoutH3.setSpacing(1.5)
layoutH3.addWidget(self.numbers)
layoutH3.addWidget(self.plainTextEdit_3)
self.SetEditor.addLayout(layoutH3, 0, 0)
#
self.plainTextEdit_4 = TextEdit()
self.numbers = NumberBar(self.plainTextEdit_4)
layoutH4 = QHBoxLayout()
#layoutH4.setSpacing(1.5)
layoutH4.addWidget(self.numbers)
layoutH4.addWidget(self.plainTextEdit_4)
self.TallyEditor.addLayout(layoutH4, 0, 0)
#
self.plainTextEdit_5 = TextEdit()
self.numbers = NumberBar(self.plainTextEdit_5)
layoutH5 = QHBoxLayout()
#layoutH5.setSpacing(1.5)
layoutH5.addWidget(self.numbers)
layoutH5.addWidget(self.plainTextEdit_5)
self.PlotEditor.addLayout(layoutH5, 0, 0)
#
self.plainTextEdit_6 = TextEdit()
self.numbers = NumberBar(self.plainTextEdit_6)
layoutH6 = QHBoxLayout()
#layoutH6.setSpacing(1.5)
layoutH6.addWidget(self.numbers)
layoutH6.addWidget(self.plainTextEdit_6)
self.CMFDEditor.addLayout(layoutH6, 0, 0)
def HLAct(self):
if self.checkbox.isChecked():
from src.syntax_py import Highlighter
self.highlighter = Highlighter(self.editor.document())
else:
from src.syntax import Highlighter
self.highlighter = Highlighter(self.editor.document())
def editor_id(self):
if self.tabWidget.currentWidget().objectName() == 'tab_python': # python script window
self.editor = self.plainTextEdit_7
self.cursor = self.editor.textCursor()
self.cursor = self.editor.textCursor()
self.editor.setTextCursor(self.cursor)
self.editor.moveCursor(self.cursor.End)
self.filemenu.setEnabled(True)
#self.toolBar_1.setEnabled(True)
self.toolBar_2.setEnabled(True)
self.toolBar_4.setEnabled(True)
elif self.tabWidget.currentWidget().objectName() == 'tab_xml': # xml script windows
self.filemenu.setEnabled(False)
#self.toolBar_1.setEnabled(False)
self.toolBar_2.setEnabled(False)
self.toolBar_4.setEnabled(False)
if self.tabWidget_3.currentWidget().objectName() == 'tab_11':
self.editor = self.plainTextEdit_1
self.cursor = self.editor.textCursor()
self.editor.setTextCursor(self.cursor)
self.editor.moveCursor(self.cursor.End)
elif self.tabWidget_3.currentWidget().objectName() == 'tab_12':
self.editor = self.plainTextEdit_2
self.cursor = self.editor.textCursor()
self.editor.setTextCursor(self.cursor)
self.editor.moveCursor(self.cursor.End)
elif self.tabWidget_3.currentWidget().objectName() == 'tab_13':
self.editor = self.plainTextEdit_3
self.cursor = self.editor.textCursor()
self.editor.setTextCursor(self.cursor)
self.editor.moveCursor(self.cursor.End)
elif self.tabWidget_3.currentWidget().objectName() == 'tab_14':
self.editor = self.plainTextEdit_4
self.cursor = self.editor.textCursor()
self.editor.setTextCursor(self.cursor)
self.editor.moveCursor(self.cursor.End)
elif self.tabWidget_3.currentWidget().objectName() == 'tab_15':
self.editor = self.plainTextEdit_5
self.cursor = self.editor.textCursor()
self.editor.setTextCursor(self.cursor)
self.editor.moveCursor(self.cursor.End)
elif self.tabWidget_3.currentWidget().objectName() == 'tab_16':
self.editor = self.plainTextEdit_6
self.cursor = self.editor.textCursor()
self.editor.setTextCursor(self.cursor)
self.editor.moveCursor(self.cursor.End)
elif self.tabWidget.currentWidget().objectName() == 'tab_run': # output window
self.editor = self.plainTextEdit_8
self.cursor = self.editor.textCursor()
self.editor.setTextCursor(self.cursor)
self.editor.moveCursor(self.cursor.End)
self.filemenu.setEnabled(True)
self.toolBar_2.setEnabled(False)
self.toolBar_4.setEnabled(False)
self.Update_StatusBar()
self.highlighter = Highlighter(self.editor.document())
self.editor.cursorPositionChanged.connect(self.CursorPositionChanged)
def Update_StatusBar(self):
if self.tabWidget.currentWidget().objectName() == 'tab_python': # python script window
if self.filename and os.path.getsize(self.filename) != 0:
msg = 'Project python file : ' + self.filename + ' size :' + str(os.path.getsize(self.filename)) + ' KB'
else:
msg = 'Python file : '
msg1 = self.editor.blockCount()
elif self.tabWidget.currentWidget().objectName() == 'tab_xml': # xml script window
if self.directory:
filename = self.directory + '/' + self.xml_file_names_list[self.tabWidget_3.currentIndex()]
if os.path.exists(filename):
if os.path.getsize(filename) != 0 and self.editor.toPlainText() != '':
msg = 'Project xml file : ' + filename + ' size :' + str(os.path.getsize(filename)) + ' B'
else:
msg = 'xml file : ' + self.xml_file_names_list[self.tabWidget_3.currentIndex()]
else:
msg = 'xml file : ' + self.xml_file_names_list[self.tabWidget_3.currentIndex()]
else:
msg = 'xml file : ' + self.xml_file_names_list[self.tabWidget_3.currentIndex()]
msg1 = self.editor.blockCount()
else:
msg = 'Window output'
msg1 = ""
self.lineLabel1.setText(msg)
self.lineLabel2.setText(' Blocks number : ' + str(msg1))
self.lineLabel3.setText("Cursor position: line " + str(self.line) + " | column " + str(self.pos))
def clear_Lists(self):
self.surface_id_list = ['0']
self.surface_name_list = []
self.regions = []
self.cell_name_list = []
self.Vol_Calcs_list = []
self.cell_id_list = ['0']
self.materials_name_list = []
self.materials_id_list = []
self.lattice_id_list = []
self.lattice_name_list = []
self.universe_id_list = []
self.universe_name_list = []
self.Source_name_list = []
self.Source_id_list = []
self.Source_strength_list = []
self.tally_name_list = []
self.tally_id_list = []
self.filter_name_list = []
self.filter_id_list = ['0']
self.plot_name_list = []
self.plot_id_list = ['0']
self.score_name_list = []
self.score_id_list = ['0']
self.mesh_name_list = []
self.mesh_id_list = []
self.Model_Nuclides_List = []
self.Model_Elements_List = []
self.filters = {}
self.Bins = {}
def Python_TallyDataProcessing(self):
#self.inst = TallyDataProcessing(self.shellWin)
self.interface = TallyDataProcessing()
self.interface.show()
List_name = [self.surface_name_list, self.cell_name_list, self.materials_name_list, self.lattice_name_list,
self.universe_name_list, self.tally_name_list, self.mesh_name_list, self.filter_name_list]
List_id = [self.surface_id_list, self.cell_id_list, self.materials_id_list, self.lattice_id_list,
self.universe_id_list, self.tally_id_list, self.mesh_id_list, self.filter_id_list]
def file_name(self):
if self.tabWidget.currentIndex() == 0:
if self.directory:
self.filename = self.directory + '/' + self.xml_file_names_list[self.tabWidget_3.currentIndex()]
else:
self.filename = ''
def Get_OpenMC(self):
self.inst = InstallOpenMC()
self.inst.show()
def Tracks_to_VTI(self):
self.tabWidget.setCurrentIndex(2)
self.plainTextEdit_8.clear()
if self.directory:
os.chdir(self.directory)
h5_file = QtWidgets.QFileDialog.getOpenFileName(self, 'Open File', "~", "track*.h5")[0]
self.directory = os.path.dirname(h5_file)
self.lineLabel1.setText("File path: " + h5_file)
self.lineLabel2.setText(' Blocks number : ' + str(self.editor.blockCount()))
self.lineLabel3.setText("Cursor position: line " + str(self.line) + " | column " + str(self.pos))
if h5_file != "":
file = open(h5_file, "r")
cmd = 'openmc-track-to-vtk ' + h5_file
self.process.start(cmd, QtCore.QIODevice.ReadWrite)
os.chdir(self.app_dir)
def Voxels_to_VTI(self):
self.tabWidget.setCurrentIndex(2)
self.plainTextEdit_8.clear()
if self.directory:
os.chdir(self.directory)
h5_file = QtWidgets.QFileDialog.getOpenFileName(self, 'Open File', "~", "*.h5")[0]
self.directory = os.path.dirname(h5_file)
self.lineLabel1.setText("File path: " + h5_file)
self.lineLabel2.setText(' Blocks number : ' + str(self.editor.blockCount()))
self.lineLabel3.setText("Cursor position: line " + str(self.line) + " | column " + str(self.pos))
if h5_file != "":
file = open(h5_file, "r")
cmd = 'openmc-voxel-to-vtk ' + h5_file
self.process.start(cmd, QtCore.QIODevice.ReadWrite)
os.chdir(self.app_dir)
def Dump_H5(self):
self.tabWidget.setCurrentIndex(2)
self.plainTextEdit_8.clear()
if self.directory:
os.chdir(self.directory)
h5_file = QtWidgets.QFileDialog.getOpenFileName(self, 'Open File', "~", "*.h5")[0]
self.directory = os.path.dirname(h5_file)
self.lineLabel1.setText("File path: " + h5_file)
self.lineLabel2.setText(' Blocks number : ' + str(self.editor.blockCount()))
self.lineLabel3.setText("Cursor position: line " + str(self.line) + " | column " + str(self.pos))
if h5_file != "":
file = open(h5_file, "r")
cmd = 'h5dump ' + h5_file
self.plainTextEdit_8.insertPlainText(os.popen(cmd).read())
os.chdir(self.app_dir)
def Tallies_View(self):
self.tabWidget.setCurrentIndex(2)
self.plainTextEdit_8.clear()
if self.directory:
os.chdir(self.directory)
tallies_out = QtWidgets.QFileDialog.getOpenFileName(self, 'Open File', "~", "*.out")[0]
self.directory = os.path.dirname(tallies_out)
self.lineLabel1.setText("File path: " + tallies_out)
self.lineLabel2.setText(' Blocks number : ' + str(self.editor.blockCount()))
self.lineLabel3.setText("Cursor position: line " + str(self.line) + " | column " + str(self.pos))
if tallies_out != "":
file = open(tallies_out, "r")
self.plainTextEdit_8.setPlainText(file.read())
os.chdir(self.app_dir)
def XML_Validation1(self):
# openmc-validate-xml -i test/ -r ~/miniconda3/envs/openmc-py3.7/share/openmc/relaxng/
self.tabWidget.setCurrentIndex(2)
self.plainTextEdit_8.clear()
env: str = os.environ['CONDA_DEFAULT_ENV']
cmd = 'which openmc'
openmc_path: str = subprocess.getoutput(cmd)
validate_script = openmc_path.replace('bin/openmc', 'bin/openmc-validate-xml')
relaxng_dir = openmc_path.replace('bin/openmc', 'share/openmc/relaxng')
cmd = validate_script + ' -i ' + str(self.directory) + ' -r ' + relaxng_dir
if self.plainTextEdit_1.toPlainText():
stream = os.popen(cmd)
document = stream.read()
self.highlighter = Highlighter(self.plainTextEdit_8.document())
self.plainTextEdit_8.clear()
self.plainTextEdit_8.insertPlainText(document)
else:
msg = 'Project is empty or no active project !'
self.showDialog('Warning', msg)
def XML_Validation(self):
# openmc-validate-xml -i test/ -r ~/miniconda3/envs/openmc-py3.7/share/openmc/relaxng/
from src.syntax_validate import Highlighter
os.chdir(self.app_dir)
self.checkbox.setChecked(False)
self.tabWidget.setCurrentIndex(2)
self.plainTextEdit_8.clear()
self.highlighter = Highlighter(self.plainTextEdit_8.document())
self.Process()
validate_script = './validate_xml/openmc-validate-xml'
relaxng_dir = './validate_xml/relaxng'
cmd = validate_script + ' -i ' + str(self.directory) + ' -r ' + relaxng_dir
if self.plainTextEdit_1.toPlainText():
self.process.start(cmd)
else:
msg = 'Project is empty or no active project !'
self.showDialog('Warning', msg)
def ViewXML(self, Editor):
Header_text_lines = []
self.xml_files_list = []
if self.filename:
if self.new_File:
Header_text = self.wind8.Header_text
elif self.openedFiles:
lines = self.plainTextEdit_7.toPlainText().split('\n')
matchers = ['Description', 'Case', 'Writen by', 'DateTime']
Header_text_lines = [line for line in lines if any(xs in line for xs in matchers)]
if any('Description' in item for item in Header_text_lines):
pass
else:
Header_text_lines.insert(0, ' Description: ')
if any('Case' in item for item in Header_text_lines):
pass
else:
Header_text_lines.insert(1, ' Case: ')
if any('Writen by' in item for item in Header_text_lines):
pass
else:
Header_text_lines.insert(2, ' Writen by: ' + os.getlogin())
if any('DateTime' in item for item in Header_text_lines):
pass
else:
Header_text_lines.insert(3, ' DateTime: ' + str(datetime.now()))
Header_text = '='*75 + '\n' + '\n'.join(Header_text_lines) + '\n' + '='*75
self.directory = os.path.dirname(self.filename)
os.chdir(self.directory)
for TE in [self.plainTextEdit_1, self.plainTextEdit_2, self.plainTextEdit_3, self.plainTextEdit_4,
self.plainTextEdit_5, self.plainTextEdit_6]:
TE.clear()
if path.exists(self.directory + '/geometry.xml') == True:
self.xml_files_list.append('geometry.xml')
files = self.directory + '/geometry.xml'
file = open(files,"r")
text = file.read().split('\n')
text.insert(1, ' <!-- ')
text.insert(2, Header_text)
text.insert(3, ' -->')
self.plainTextEdit_1.setPlainText('\n'.join(text))
self.plainTextEdit_1.show()
if path.exists(self.directory + '/materials.xml') == True:
self.xml_files_list.append('materials.xml')
files = self.directory + '/materials.xml'
file = open(files,"r")
text = file.read().split('\n')
text.insert(1, ' <!-- ')
text.insert(2, Header_text)
text.insert(3, ' -->')
self.plainTextEdit_2.setPlainText('\n'.join(text))
self.plainTextEdit_2.show()
if path.exists(self.directory + '/settings.xml') == True:
self.xml_files_list.append('settings.xml')
files = self.directory + '/settings.xml'
file = open(files,"r")
text = file.read().split('\n')
text.insert(1, ' <!-- ')
text.insert(2, Header_text)
text.insert(3, ' -->')
self.plainTextEdit_3.setPlainText('\n'.join(text))
self.plainTextEdit_3.show()
if path.exists(self.directory + '/tallies.xml') == True: