-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProjMergeDlg.py
110 lines (95 loc) · 3.83 KB
/
ProjMergeDlg.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
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import QDialog
import ui_projmergedlg
from os.path import isfile
from os.path import isdir
import sys
class ProjMergeDlg(QDialog, ui_projmergedlg.Ui_ProjMergeDlg):
def __init__(self, curfolder = "", parent=None):
super(ProjMergeDlg, self).__init__(parent)
self.setupUi(self)
self.projName = ""
self.outFolder = ""
self.projFiles = []
self.projFileName = "project.nma"
self.workingpath = curfolder
self.removeButton.setEnabled(False)
self.setFixedSize(425, 285)
@pyqtSlot()
def on_selectButton_clicked(self):
foldername = str(QFileDialog.getExistingDirectory(self, 'Output Folder',
self.workingpath))
if(foldername):
self.outfolderEdit.setText(foldername)
self.workingpath = foldername
@pyqtSlot()
def on_addButton_clicked(self):
foldername = str(QFileDialog.getExistingDirectory(self, 'Add Project Folder',
self.workingpath))
if(foldername):
self.__addProjPath(foldername)
self.workingpath = foldername
@pyqtSlot()
def on_removeButton_clicked(self):
self.projsListWidget.takeItem(self.projsListWidget.currentRow())
if(self.projsListWidget.currentItem() is None):
self.removeButton.setEnabled(False)
@pyqtSlot()
def on_okayButton_clicked(self):
if(self.__checkEditLine(self.projnameEdit,"Project Name")):
self.projName = self.projnameEdit.text()
else:
return
if(self.__checkEditLine(self.outfolderEdit,"Project Folder")):
if(not isdir(self.outfolderEdit.text())):
QMessageBox.warning(self, "Error",
("Project folder does not exist!"),
QMessageBox.Ok|QMessageBox.Default)
return
self.outFolder = self.outfolderEdit.text()
else:
return
self.projFiles = self.__getSeqFiles()
self.projFiles = list(set(self.projFiles))
if(len(self.projFiles) < 2):
QMessageBox.warning(self, "Error",
("At least two different projects required"),
QMessageBox.Ok|QMessageBox.Default)
return
self.accept()
def on_projsListWidget_itemClicked(self):
self.removeButton.setEnabled(True)
def __addProjPath(self,foldername):
projfile = foldername + "/" + self.projFileName
if(not isfile(projfile)):
QMessageBox.warning(self, "Error:",
("Cannot project file in folder %s" %(foldername)), QMessageBox.Ok|QMessageBox.Default)
return
fileItem = QListWidgetItem()
fileItem.setText(foldername)
self.projsListWidget.addItem(fileItem)
def __getSeqFiles(self):
foldercount = self.projsListWidget.count()
projfiles = []
for count in range(foldercount):
item = self.projsListWidget.item(count)
foldername = str(item.text())
projfile = foldername + "/" + self.projFileName
projfiles.append(projfile)
return (projfiles)
def __checkEditLine(self,edtline,msg):
if(edtline.text() == ""):
self.__sendMessage(msg)
edtline.setFocus()
return False
else:
return True
def __sendMessage(self, msg):
QMessageBox.warning(self, "Parameter missing",
("%s is empty" %(msg)), QMessageBox.Ok|QMessageBox.Default)
if(__name__ == "__main__"):
app = QApplication(sys.argv)
mainwindow = ProjMergeDlg()
mainwindow.show()
app.exec_()