Merge pull request 'VIS-22 added Library table' (#2) from VIS-22 into master
Reviewed-on: #2
This commit is contained in:
commit
3862848a7e
0
win_venv/files/input/input1.mp4
Normal file
0
win_venv/files/input/input1.mp4
Normal file
0
win_venv/files/input/input2.mp4
Normal file
0
win_venv/files/input/input2.mp4
Normal file
@ -1,9 +1,61 @@
|
||||
#import tkinter as tk
|
||||
import sys
|
||||
import os
|
||||
from datetime import datetime
|
||||
from PyQt5 import QtCore
|
||||
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QMainWindow, QGridLayout, QMenu, QFileDialog, QAction
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtGui import QIcon, QPixmap
|
||||
from PyQt5.QtCore import *
|
||||
|
||||
scriptPath = os.path.dirname(os.path.realpath(__file__))
|
||||
filePath = scriptPath + '\\files\\input'
|
||||
|
||||
def files(path):
|
||||
for file in os.listdir(path):
|
||||
if os.path.isfile(os.path.join(path, file)):
|
||||
yield file
|
||||
|
||||
class LibraryTableButtons(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(LibraryTableButtons,self).__init__(parent)
|
||||
layout = QHBoxLayout()
|
||||
|
||||
layout.setContentsMargins(0,0,0,0)
|
||||
layout.setSpacing(0)
|
||||
|
||||
layout.addWidget(QPushButton('View'))
|
||||
layout.addWidget(QPushButton('Delete'))
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
class LibraryTable(QTableWidget):
|
||||
def __init__(self, parent=None):
|
||||
QTableWidget.__init__(self)
|
||||
self.setColumnCount(3)
|
||||
self.setHorizontalHeaderLabels(['Upload date', 'Filename', 'Options'])
|
||||
self.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents)
|
||||
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)))
|
||||
|
||||
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())
|
||||
|
||||
def handleButtonClicked(w):
|
||||
button = qApp.focusWidget()
|
||||
# or button = self.sender()
|
||||
index = self.table.indexAt(button.pos())
|
||||
if index.isValid():
|
||||
print(index.row(), index.column())
|
||||
|
||||
|
||||
def main():
|
||||
@ -30,6 +82,15 @@ def main():
|
||||
menuBar.addMenu(homeMenu)
|
||||
homeMenu.addAction("Load new file")
|
||||
|
||||
# Show raw uploaded files
|
||||
def showLibrary():
|
||||
libTable = LibraryTable()
|
||||
w.setCentralWidget(libTable)
|
||||
|
||||
libraryAct = QAction('&Library', w)
|
||||
libraryAct.triggered.connect(showLibrary)
|
||||
menuBar.addAction(libraryAct)
|
||||
|
||||
# Exit app
|
||||
exitAct = QAction('&Exit', w)
|
||||
exitAct.setShortcut('Ctrl+Q')
|
||||
@ -37,8 +98,6 @@ def main():
|
||||
exitAct.triggered.connect(app.quit)
|
||||
homeMenu.addAction(exitAct)
|
||||
|
||||
|
||||
historyMenu = menuBar.addMenu("&History")
|
||||
helpMenu = menuBar.addMenu("&Help")
|
||||
|
||||
w.show()
|
||||
|
Loading…
Reference in New Issue
Block a user