created Visualisations tab with the same table #6

Merged
s416067 merged 1 commits from VIS-32 into master 2021-01-04 12:48:39 +01:00
Showing only changes of commit 5a37492188 - Show all commits

View File

@ -10,7 +10,11 @@ from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtCore import *
scriptPath = os.path.dirname(os.path.realpath(__file__))
filePath = scriptPath + '\\files\\input'
inputFilePath = scriptPath + '\\files\\input'
outputFilePath = scriptPath + '\\files\\output'
LIB_RAW = 0
LIB_VIS = 1
def files(path):
for file in os.listdir(path):
@ -20,7 +24,10 @@ def files(path):
class deletePopup(QMessageBox):
def __init__(self, parent=None):
super(deletePopup,self).__init__(parent)
self.question(self,'', "Are you sure you want to delete the file?", self.Yes | self.No)
self.setText("Are you sure you want to delete the file?")
self.setIcon(self.Warning)
self.setWindowTitle("Confirm deletion")
self.setStandardButtons(self.Yes | self.No)
def save_input(oldpath):
# make timestampt the filename, so it wouln't overwrite
@ -32,18 +39,18 @@ def save_input(oldpath):
class LibraryTableButtons(QWidget):
def __init__(self, filename, parent=None):
def __init__(self, file, parent=None):
super(LibraryTableButtons,self).__init__(parent)
def viewFile():
os.startfile(filePath + '\\' + filename)
os.startfile(file)
def deleteFile():
self.exPopup = deletePopup()
self.exPopup.setGeometry(100, 200, 100, 100)
# self.exPopup.show()
if self.exPopup.Yes:
os.remove(filePath + '\\' + filename)
# self.exPopup.setGeometry(100, 200, 100, 100)
ret = self.exPopup.exec()
if ret == self.exPopup.Yes:
os.remove(file)
layout = QHBoxLayout()
layout.setContentsMargins(0,0,0,0)
@ -62,10 +69,16 @@ class LibraryTableButtons(QWidget):
class LibraryTable(QTableWidget):
def __init__(self, parent=None):
def __init__(self, type, parent=None):
QTableWidget.__init__(self)
self.setColumnCount(3)
self.setHorizontalHeaderLabels(['Upload date', 'Filename', 'Options'])
if type == LIB_RAW:
self.setHorizontalHeaderLabels(['Upload date', 'Filename', 'Options'])
filePath = inputFilePath
else:
self.setHorizontalHeaderLabels(['Creation date', 'Filename', 'Options'])
filePath = outputFilePath
self.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents)
self.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
self.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeToContents)
@ -81,7 +94,7 @@ class LibraryTable(QTableWidget):
for index, date in enumerate(dates):
self.setItem(index,0,date)
self.setItem(index,1,names[index])
self.setCellWidget(index,2,LibraryTableButtons(names[index].text()))
self.setCellWidget(index,2,LibraryTableButtons(filePath + '\\' + names[index].text()))
class MainWindow(QMainWindow):
@ -91,8 +104,13 @@ class MainWindow(QMainWindow):
self.initUI()
# Show raw uploaded files
def showLibrary(self):
libTable = LibraryTable()
def showInputLibrary(self):
libTable = LibraryTable(LIB_RAW)
self.setCentralWidget(libTable)
# Show visualisations
def showVisualisationsLibrary(self):
libTable = LibraryTable(LIB_VIS)
self.setCentralWidget(libTable)
def showUploadFile(self):
@ -119,9 +137,19 @@ class MainWindow(QMainWindow):
uploadAct.triggered.connect(self.showUploadFile)
homeMenu.addAction(uploadAct)
libraryAct = QAction('&Library', self)
libraryAct.triggered.connect(self.showLibrary)
menuBar.addAction(libraryAct)
#Library menu
libraryMenu = QMenu("&Library", self)
menuBar.addMenu(libraryMenu)
#Input files
inputAct = QAction('&Input files', self)
inputAct.triggered.connect(self.showInputLibrary)
libraryMenu.addAction(inputAct)
#Visualisations
visAct = QAction('&Visualisations', self)
visAct.triggered.connect(self.showVisualisationsLibrary)
libraryMenu.addAction(visAct)
# Exit app
exitAct = QAction('&Exit', self)