created Visualisations tab with the same table
This commit is contained in:
parent
cbd200ea98
commit
5a37492188
@ -10,7 +10,11 @@ from PyQt5.QtGui import QIcon, QPixmap
|
|||||||
from PyQt5.QtCore import *
|
from PyQt5.QtCore import *
|
||||||
|
|
||||||
scriptPath = os.path.dirname(os.path.realpath(__file__))
|
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):
|
def files(path):
|
||||||
for file in os.listdir(path):
|
for file in os.listdir(path):
|
||||||
@ -20,7 +24,10 @@ def files(path):
|
|||||||
class deletePopup(QMessageBox):
|
class deletePopup(QMessageBox):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(deletePopup,self).__init__(parent)
|
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):
|
def save_input(oldpath):
|
||||||
# make timestampt the filename, so it wouln't overwrite
|
# make timestampt the filename, so it wouln't overwrite
|
||||||
@ -32,18 +39,18 @@ def save_input(oldpath):
|
|||||||
|
|
||||||
|
|
||||||
class LibraryTableButtons(QWidget):
|
class LibraryTableButtons(QWidget):
|
||||||
def __init__(self, filename, parent=None):
|
def __init__(self, file, parent=None):
|
||||||
super(LibraryTableButtons,self).__init__(parent)
|
super(LibraryTableButtons,self).__init__(parent)
|
||||||
|
|
||||||
def viewFile():
|
def viewFile():
|
||||||
os.startfile(filePath + '\\' + filename)
|
os.startfile(file)
|
||||||
|
|
||||||
def deleteFile():
|
def deleteFile():
|
||||||
self.exPopup = deletePopup()
|
self.exPopup = deletePopup()
|
||||||
self.exPopup.setGeometry(100, 200, 100, 100)
|
# self.exPopup.setGeometry(100, 200, 100, 100)
|
||||||
# self.exPopup.show()
|
ret = self.exPopup.exec()
|
||||||
if self.exPopup.Yes:
|
if ret == self.exPopup.Yes:
|
||||||
os.remove(filePath + '\\' + filename)
|
os.remove(file)
|
||||||
|
|
||||||
layout = QHBoxLayout()
|
layout = QHBoxLayout()
|
||||||
layout.setContentsMargins(0,0,0,0)
|
layout.setContentsMargins(0,0,0,0)
|
||||||
@ -62,10 +69,16 @@ class LibraryTableButtons(QWidget):
|
|||||||
|
|
||||||
class LibraryTable(QTableWidget):
|
class LibraryTable(QTableWidget):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, type, parent=None):
|
||||||
QTableWidget.__init__(self)
|
QTableWidget.__init__(self)
|
||||||
self.setColumnCount(3)
|
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(0, QHeaderView.ResizeToContents)
|
||||||
self.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
|
self.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
|
||||||
self.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeToContents)
|
self.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeToContents)
|
||||||
@ -81,7 +94,7 @@ 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.setCellWidget(index,2,LibraryTableButtons(filePath + '\\' + names[index].text()))
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow):
|
class MainWindow(QMainWindow):
|
||||||
@ -91,8 +104,13 @@ class MainWindow(QMainWindow):
|
|||||||
self.initUI()
|
self.initUI()
|
||||||
|
|
||||||
# Show raw uploaded files
|
# Show raw uploaded files
|
||||||
def showLibrary(self):
|
def showInputLibrary(self):
|
||||||
libTable = LibraryTable()
|
libTable = LibraryTable(LIB_RAW)
|
||||||
|
self.setCentralWidget(libTable)
|
||||||
|
|
||||||
|
# Show visualisations
|
||||||
|
def showVisualisationsLibrary(self):
|
||||||
|
libTable = LibraryTable(LIB_VIS)
|
||||||
self.setCentralWidget(libTable)
|
self.setCentralWidget(libTable)
|
||||||
|
|
||||||
def showUploadFile(self):
|
def showUploadFile(self):
|
||||||
@ -119,9 +137,19 @@ class MainWindow(QMainWindow):
|
|||||||
uploadAct.triggered.connect(self.showUploadFile)
|
uploadAct.triggered.connect(self.showUploadFile)
|
||||||
homeMenu.addAction(uploadAct)
|
homeMenu.addAction(uploadAct)
|
||||||
|
|
||||||
libraryAct = QAction('&Library', self)
|
#Library menu
|
||||||
libraryAct.triggered.connect(self.showLibrary)
|
libraryMenu = QMenu("&Library", self)
|
||||||
menuBar.addAction(libraryAct)
|
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
|
# Exit app
|
||||||
exitAct = QAction('&Exit', self)
|
exitAct = QAction('&Exit', self)
|
||||||
|
Loading…
Reference in New Issue
Block a user