forked from NORBI273COOL/PyQT-projectYandex-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiles_history.py
More file actions
38 lines (28 loc) · 1.12 KB
/
Copy pathfiles_history.py
File metadata and controls
38 lines (28 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from query_db import *
from PyQt5.QtWidgets import QDialog
from PyQt5 import uic
from PyQt5.QtWidgets import QTableWidgetItem
class FilesHistoryDialog(QDialog):
def __init__(self):
super().__init__()
uic.loadUi('files_history.ui', self)
self.fill_table()
self.btn_open.clicked.connect(self.open)
self.selected_file_path = None
def open(self):
selected_row_index = self.tbl_history.currentRow()
if selected_row_index is not None:
row = [self.tbl_history.item(selected_row_index, i).text()
for i in range(self.tbl_history.columnCount())]
self.selected_file_path = row[2]
self.close()
def get_selected_file(self):
return self.selected_file_path
def fill_table(self):
history = get_history()
for i, row in enumerate(history):
self.tbl_history.setRowCount(self.tbl_history.rowCount() + 1)
row = row[1:]
for j, el in enumerate(row):
self.tbl_history.setItem(i, j, QTableWidgetItem(str(el)))
self.tbl_history.resizeColumnsToContents()