-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_row
93 lines (76 loc) · 2.35 KB
/
add_row
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
93
#This code helps to add a new row to the existing data file
import csv, codecs
import os
from PyQt5 import QtCore, QtGui, QtWidgets, QtPrintSupport
from PyQt5.QtGui import QImage, QPainter
from PyQt5.QtCore import QFile
class MyWindow(QtWidgets.QWidget):
def __init__(self, fileName, parent=None):
super(MyWindow, self).__init__(parent)
self.fileName = ""
self.fname = "plot"
self.model = QtGui.QStandardItemModel(self)
self.tableView = QtWidgets.QTableView(self)
self.tableView.setStyleSheet(stylesheet(self))
self.tableView.setModel(self.model)
self.tableView.horizontalHeader().setStretchLastSection(True)
self.tableView.setShowGrid(True)
self.tableView.setGeometry(50, 50, 780, 645)
self.model.dataChanged.connect(self.finishedEdit)
self.pushAddRow = QtWidgets.QPushButton(self)
self.pushAddRow.setText("add Row")
self.pushAddRow.clicked.connect(self.addRow)
self.pushAddRow.setFixedWidth(80)
self.pushAddRow.setStyleSheet(stylesheet(self))
item = QtGui.QStandardItem()
self.model.appendRow(item)
self.model.setData(self.model.index(0, 0), "", 0)
self.tableView.resizeColumnsToContents()
def finishedEdit(self):
self.tableView.resizeColumnsToContents()
def addRow(self):
item = QtGui.QStandardItem("")
self.model.appendRow(item)
def stylesheet(self):
return """
QTableView
{
border: 1px solid grey;
border-radius: 0px;
font-size: 12px;
background-color: #f8f8f8;
selection-color: white;
selection-background-color: #00ED56;
}
QTableView QTableCornerButton::section {
background: #D6D1D1;
border: 1px outset black;
}
QPushButton
{
font-size: 11px;
border: 1px inset grey;
height: 24px;
width: 80px;
color: black;
background-color: #e8e8e8;
background-position: bottom-left;
}
QPushButton::hover
{
border: 2px inset goldenrod;
font-weight: bold;
color: #e8e8e8;
background-color: green;
}
"""
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
app.setApplicationName('MyWindow')
main = MyWindow('')
main.setMinimumSize(300, 300)
main.setGeometry(0,0,800,700)
main.setWindowTitle("Plotter")
main.show()
sys.exit(app.exec_())