-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMWClass.py
More file actions
50 lines (42 loc) · 1.71 KB
/
MWClass.py
File metadata and controls
50 lines (42 loc) · 1.71 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
39
40
41
42
43
44
45
46
47
48
49
50
from PyQt6.QtWidgets import QMainWindow, QFileDialog, QTableWidget, QTableWidgetItem
from myui import Ui_MainWindow
from SWCLass import SecondWindow
import pandas as pd
class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.swin = SecondWindow()
self.swin.test_signal.connect(self.print)
self.show()
def selectFile(self):
self.fill_table_ff(QFileDialog.getOpenFileName()[0])
def print(self):
for i in self.swin.listT:
self.fill_table_f_df(self.swin.dfw[int(i)])
def fill_table_ff(self, currentData):
df = pd.read_csv(currentData)
table = QTableWidget()
headers = df.columns.values.tolist()
table.setColumnCount(len(headers))
table.setHorizontalHeaderLabels(headers)
for i, row in df.iterrows():
# Добавление строки
table.setRowCount(table.rowCount() + 1)
for j in range(table.columnCount()):
table.setItem(i, j, QTableWidgetItem(str(row[j])))
self.ui.gridLayout_4.addWidget(table)
def fill_table_f_df(self, df):
table = QTableWidget()
headers = df.columns.values.tolist()
table.setColumnCount(len(headers))
table.setHorizontalHeaderLabels(headers)
for i, row in df.iterrows():
# Добавление строки
table.setRowCount(table.rowCount() + 1)
for j in range(table.columnCount()):
table.setItem(i, j, QTableWidgetItem(str(row[j])))
self.ui.gridLayout_4.addWidget(table)
def open_second_window(self):
self.swin.show()