-
Notifications
You must be signed in to change notification settings - Fork 0
/
batchSolarCellAnalyzer.py
92 lines (81 loc) · 3.28 KB
/
batchSolarCellAnalyzer.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/python3
#-*- coding: utf-8 -*-
from PyQt5 import QtWidgets, QtGui
from UIfiles.BSA_MainGui import Ui_MainWindow
from PyQt5.QtWidgets import QFileDialog
from AddCl.ExtButton import mPushButton
import sys
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setWindowTitle("Simple Solar Cell Analyzer")
self.ui.tableWithFiles.setHorizontalHeaderLabels(["PLOT?", "ANALYZE?", "File name", "Area", "jsc", "Uoc", "FF", "Eff", "Compare?", "Full Path"])
# SLOTS:
self.ui.closeAppButton.clicked.connect(self.closeFunction)
self.ui.actionClose.triggered.connect(self.closeFunction)
self.ui.clearTableButton.clicked.connect(self.clearTableFunction)
#LOAD files:
self.ui.addFilesButton.clicked.connect(self.loadFilesFunction)
def FillFiles(self, file_url=None):
if file_url is not None:
print("File url is not None")
rCount = self.ui.tableWithFiles.rowCount()
print(rCount, " rCount was...")
if rCount is not None and rCount != 0:
print("Count is not None")
self.ui.tableWithFiles.setRowCount(rCount + 1)
self.ui.tableWithFiles.setCellWidget(rCount, 0, mPushButton( "Plot it!", self.ui.tableWithFiles))
cell = QtWidgets.QTableWidgetItem()
cell.setText(str(file_url.path()))
self.ui.tableWithFiles.setItem(rCount, 9, cell)
self.ui.tableWithFiles.selectRow(rCount)
self.ui.tableWithFiles.update()
pass
else:
print("Count is None")
self.ui.tableWithFiles.setRowCount(1)
# Fill all additional info:
self.ui.tableWithFiles.setCellWidget(0, 0, mPushButton( "Plot it!", self.ui.tableWithFiles))
cell = QtWidgets.QTableWidgetItem()
cell.setText(str(file_url.path()))
self.ui.tableWithFiles.setItem(0, 9, cell)
self.ui.tableWithFiles.selectRow(0)
self.ui.tableWithFiles.update()
pass
# Continue
pass
else:
pass
pass
def loadFilesFunction(self):
self.ConsoleOutput("File(s) will be add")
filter = "TXT (*.txt);;CSV (*.csv);;DAT (*.dat);; ANY file (*.*)"
file_name = QFileDialog()
file_name.setFileMode(QFileDialog.ExistingFiles)
names = file_name.getOpenFileUrls(self, "Open files", "/home/", filter)
for i in names[0]:
self.ConsoleOutput(str(i.path()))
# MAIN LOADER:
for i in names[0]:
file_path = i
self.FillFiles( file_path)
pass
def ConsoleOutput(self, text=None):
if text is not None:
self.ui.consoleOutput.appendPlainText(str(text))
else:
pass
def clearTableFunction(self):
self.ConsoleOutput("Table will be cleared")
pass
def closeFunction(self):
print("Exiting ... ")
sys.exit(10)
pass
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())