From a4b04c7c8f1cfaa28f9d30ffb0fa88d761f8c032 Mon Sep 17 00:00:00 2001 From: VanillaHellen Date: Mon, 18 Jan 2021 16:10:17 +0100 Subject: [PATCH 1/2] added the view after uploading the file --- win_venv/main.py | 60 +++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/win_venv/main.py b/win_venv/main.py index c73fea9..ea8618e 100644 --- a/win_venv/main.py +++ b/win_venv/main.py @@ -23,7 +23,7 @@ def files(path): yield file def save_input(oldpath): - # make timestampt the filename, so it wouln't overwrite + # add timestampt the filename, so it wouln't overwrite timestamp = str(int(time.time())) filename = timestamp + '.' + oldpath.split('.')[-1] newpath = inputFilePath + '\\' + filename @@ -71,36 +71,52 @@ class LibraryTableButtons(QWidget): class LibraryTable(QTableWidget): - def __init__(self, type, parent=None): + def __init__(self, type, singleFilePath = None, parent = None): QTableWidget.__init__(self) - self.fillTable(type) + self.fillTable(type, singleFilePath) - def fillTable(self, type): + def fillTable(self, type, singleFilePath = None): self.setColumnCount(3) - if type == LIB_RAW: + if singleFilePath != None: + self.setRowCount(1) + self.setHorizontalHeaderLabels(['Upload date', 'Filename', 'Options']) filePath = inputFilePath + + self.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch) + self.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) + self.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeToContents) + + self.setItem(0,0,QTableWidgetItem(str(datetime.fromtimestamp(os.path.getmtime(singleFilePath))))) + self.setItem(0,1,QTableWidgetItem(str(os.path.basename(singleFilePath)))) + self.setCellWidget(0,2,LibraryTableButtons(singleFilePath, self, type)) + + else: - self.setHorizontalHeaderLabels(['Creation date', 'Filename', 'Options']) - filePath = outputFilePath + 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.Stretch) - self.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) - self.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeToContents) + self.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch) + self.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) + self.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeToContents) - dates = [] - names = [] - for index, file in enumerate(files(filePath)): - dates.append(QTableWidgetItem(str(datetime.fromtimestamp(os.path.getmtime(filePath + '/' + file))))) - names.append(QTableWidgetItem(str(file))) + dates = [] + names = [] + for index, file in enumerate(files(filePath)): + dates.append(QTableWidgetItem(str(datetime.fromtimestamp(os.path.getmtime(filePath + '/' + file))))) + names.append(QTableWidgetItem(str(file))) - self.setRowCount(len(dates)) + self.setRowCount(len(dates)) - for index, date in enumerate(dates): - self.setItem(index,0,date) - self.setItem(index,1,names[index]) - self.setCellWidget(index,2,LibraryTableButtons(filePath + '\\' + names[index].text(), self, type)) + for index, date in enumerate(dates): + self.setItem(index,0,date) + self.setItem(index,1,names[index]) + self.setCellWidget(index,2,LibraryTableButtons(filePath + '\\' + names[index].text(), self, type)) class formatHelp(QLabel): @@ -170,7 +186,9 @@ class MainWindow(QMainWindow): dialog.setFilter(QDir.Files) if dialog.exec_(): file_path = dialog.selectedFiles()[0] # ['C:/Users/agatha/Desktop/SYI/VisionScore/win_venv/requirements.txt'] - save_input(file_path) + newPath = save_input(file_path) + singleFileTable = LibraryTable(LIB_RAW, newPath) + self.setCentralWidget(singleFileTable) def initUI(self): self.setGeometry(0, 0, 600, 400) -- 2.20.1 From 1c7aa28ed0792618cc686d312c73404f35dd24bc Mon Sep 17 00:00:00 2001 From: VanillaHellen Date: Mon, 18 Jan 2021 16:13:21 +0100 Subject: [PATCH 2/2] fix --- win_venv/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win_venv/main.py b/win_venv/main.py index ea8618e..9732fa2 100644 --- a/win_venv/main.py +++ b/win_venv/main.py @@ -23,7 +23,7 @@ def files(path): yield file def save_input(oldpath): - # add timestampt the filename, so it wouln't overwrite + # make timestampt the filename, so it wouln't overwrite timestamp = str(int(time.time())) filename = timestamp + '.' + oldpath.split('.')[-1] newpath = inputFilePath + '\\' + filename -- 2.20.1