added post-vis table, fixed help, removed test input/output files

This commit is contained in:
VanillaHellen 2021-01-25 16:50:27 +01:00
parent 681f434386
commit 0864afb2b7
5 changed files with 19 additions and 15 deletions

View File

@ -1 +0,0 @@
test txt file

Binary file not shown.

View File

@ -49,7 +49,7 @@ class deletePopup(QMessageBox):
class LibraryTableButtons(QWidget): class LibraryTableButtons(QWidget):
def __init__(self, file, table, type, parent=None): def __init__(self, file, table, type, mainWindow, parent=None):
super(LibraryTableButtons,self).__init__(parent) super(LibraryTableButtons,self).__init__(parent)
def viewFile(): def viewFile():
@ -60,14 +60,15 @@ class LibraryTableButtons(QWidget):
ret = self.exPopup.exec() ret = self.exPopup.exec()
if ret == self.exPopup.Yes: if ret == self.exPopup.Yes:
os.remove(file) os.remove(file)
table.fillTable(type) table.fillTable(type, mainWindow)
def analyzeFile(): def analyzeFile():
cmd = "py detect.py --source {} --view-img".format(str(file)) # cmd = "py detect.py --source {} --view-img".format(str(file))
popen = subprocess.Popen(cmd, cwd="../yolov5/", stdout=subprocess.PIPE) # popen = subprocess.Popen(cmd, cwd="../yolov5/", stdout=subprocess.PIPE)
popen.wait() # popen.wait()
# todo: display gif/spinning wheel # todo: display gif/spinning wheel
mainWindow.showVisualisation(file)
pass pass
layout = QHBoxLayout() layout = QHBoxLayout()
@ -92,11 +93,11 @@ class LibraryTableButtons(QWidget):
class LibraryTable(QTableWidget): class LibraryTable(QTableWidget):
def __init__(self, type, singleFilePath = None, parent = None): def __init__(self, type, mainWindow, singleFilePath = None, parent = None):
QTableWidget.__init__(self) QTableWidget.__init__(self)
self.fillTable(type, singleFilePath) self.fillTable(type, mainWindow, singleFilePath)
def fillTable(self, type, singleFilePath = None): def fillTable(self, type, mainWindow, singleFilePath = None):
self.setColumnCount(3) self.setColumnCount(3)
if singleFilePath != None: if singleFilePath != None:
@ -111,7 +112,7 @@ class LibraryTable(QTableWidget):
self.setItem(0,0,QTableWidgetItem(str(datetime.fromtimestamp(os.path.getmtime(singleFilePath))))) self.setItem(0,0,QTableWidgetItem(str(datetime.fromtimestamp(os.path.getmtime(singleFilePath)))))
self.setItem(0,1,QTableWidgetItem(str(os.path.basename(singleFilePath)))) self.setItem(0,1,QTableWidgetItem(str(os.path.basename(singleFilePath))))
self.setCellWidget(0,2,LibraryTableButtons(singleFilePath, self, type)) self.setCellWidget(0,2,LibraryTableButtons(singleFilePath, self, type, mainWindow))
else: else:
@ -138,14 +139,14 @@ class LibraryTable(QTableWidget):
for index, date in enumerate(dates): for index, date in enumerate(dates):
self.setItem(index,0,date) self.setItem(index,0,date)
self.setItem(index,1,names[index]) self.setItem(index,1,names[index])
self.setCellWidget(index,2,LibraryTableButtons(names[index].text(), self, type)) self.setCellWidget(index,2,LibraryTableButtons(names[index].text(), self, type, mainWindow))
class formatHelp(QLabel): class formatHelp(QLabel):
def __init__(self, parent=None): def __init__(self, parent=None):
QLabel.__init__(self) QLabel.__init__(self)
with open('static/help.txt', 'r', encoding='utf-8') as file: with open(scriptPath + os.path.sep + 'static/help.txt', 'r', encoding='utf-8') as file:
help_text = file.read().replace('\n', '') help_text = file.read().replace('\n', '')
self.setText(help_text) self.setText(help_text)
self.setStyleSheet("padding-left: 20px; padding-right: 20px; padding-top: 10px; padding-bottom: 10px; font-size:32px;") self.setStyleSheet("padding-left: 20px; padding-right: 20px; padding-top: 10px; padding-bottom: 10px; font-size:32px;")
@ -167,12 +168,12 @@ class MainWindow(QMainWindow):
# Show raw uploaded files # Show raw uploaded files
def showInputLibrary(self): def showInputLibrary(self):
libTable = LibraryTable(LIB_RAW) libTable = LibraryTable(LIB_RAW, self)
self.setCentralWidget(libTable) self.setCentralWidget(libTable)
# Show visualisations # Show visualisations
def showVisualisationsLibrary(self): def showVisualisationsLibrary(self):
libTable = LibraryTable(LIB_VIS) libTable = LibraryTable(LIB_VIS, self)
self.setCentralWidget(libTable) self.setCentralWidget(libTable)
def showUploadFile(self): def showUploadFile(self):
@ -182,7 +183,11 @@ class MainWindow(QMainWindow):
if dialog.exec_(): if dialog.exec_():
file_path = dialog.selectedFiles()[0] # ['C:/Users/agatha/Desktop/SYI/VisionScore/win_venv/requirements.txt'] file_path = dialog.selectedFiles()[0] # ['C:/Users/agatha/Desktop/SYI/VisionScore/win_venv/requirements.txt']
newPath = save_input(file_path) newPath = save_input(file_path)
singleFileTable = LibraryTable(LIB_RAW, newPath) singleFileTable = LibraryTable(LIB_RAW, self, newPath)
self.setCentralWidget(singleFileTable)
def showVisualisation(self, path):
singleFileTable = LibraryTable(LIB_VIS, self, path)
self.setCentralWidget(singleFileTable) self.setCentralWidget(singleFileTable)
def initUI(self): def initUI(self):