-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPatientModel.py
36 lines (29 loc) · 1.04 KB
/
PatientModel.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
from PyQt5.QtCore import QAbstractTableModel, QVariant, Qt
from database import PatientOperations
from PyQt5 import QtCore
class PatientModel(QtCore.QAbstractTableModel):
def __init__(self, parent, header, *args):
QAbstractTableModel.__init__(self, parent, *args)
results = PatientOperations.show_patients()
self.mylist = results
self.header = header
def rowCount(self, parent):
if len(self.mylist) == 0:
return 0
return len(self.mylist)
def columnCount(self, parent):
if len(self.mylist) == 0:
return 0
return len(self.mylist[0])
def data(self, index, role):
# 5. populate data
if not index.isValid():
return None
if (role == Qt.DisplayRole):
return self.mylist[index.row()][index.column()]
else:
return QVariant()
def headerData(self, col, orientation, role):
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
return self.header[col]
return None