def __init__(self, sid, title, header, body, footer, formarts, columns, parent=None): super(TableProfile, self).__init__(parent) #page setup self.setGeometry(100, 100, 700, 700) self.textStyle = "background-color: white; color:black; border: 3px ridge #ccc" self.minW = 670 self.maxW = 700 self.sid = sid self.header = header self.body = body self.footer = footer self.formarts = formarts self.title = title self.columns = [x + 1 for x in columns] self.hold = self.columns cn = Db() self.myterms = cn.getTermClass(self.sid) menu = self.menuUi() self.h1_box = QVBoxLayout() self.bioText = QTextEdit(self) self.bioText.setMinimumWidth(self.minW) self.bioText.setMinimumHeight(self.maxW) self.bioText.setMaximumHeight(self.maxW) btext = self.buildBio() self.bioText.insertHtml(btext) self.bioText.setStyleSheet(self.textStyle) self.h1_box.addWidget(self.bioText) self.h1_box.setSizeConstraint(QLayout.SetFixedSize) self.doc1 = self.bioText scrollArea = QScrollArea(self) scrollArea.setWidgetResizable(True) scrollArea.setFixedHeight(700) scrollArea.setFixedWidth(700) bioProfileWidget = QWidget() bioProfileWidget.setLayout(self.h1_box) #Main layout Hbox = QVBoxLayout() Hbox.addWidget(menu) Hbox.addStretch() Hbox.addWidget(bioProfileWidget) Hbox.setContentsMargins(0, 0, 0, 0) #Create central widget, add layout and set central_widget = QWidget(scrollArea) scrollArea.setWidget(central_widget) central_widget.setContentsMargins(0, 0, 0, 0) central_widget.setGeometry(0, 0, 650, 700) central_widget.setStyleSheet("background-color: #ccc; color:#000") central_widget.setLayout(Hbox) self.setWindowTitle(title) self.show()
def __init__(self, sids, es, parent=None): super(StudentProfile, self).__init__(parent) red = 50 + es reds = 50 + es self.setGeometry(red, reds, 700, 700) self.textStyle = "background-color: white; color:black; border: 3px ridge #ccc" self.minW = 670 self.maxW = 700 self.sid = sids self.student = sids cn = Db() self.myterms = cn.getTermClass(self.sid) menu = self.menuUi() data = self.pullStudents(self.sid) fullnamex = data['surname'] + ' ' + data['firstname'] + ' ' + data[ 'othername'] self.fullname = fullnamex.title() self.schno = str(data['schno']).upper() if data['gender'] == 0: self.gender = 'Male' elif data['gender'] == 1: self.gender = 'Female' else: self.gender = 'None Stated' now = datetime.datetime.today() dob = data['dob'] dt = datetime.datetime.strptime(dob, '%d/%m/%Y').date() dt1 = now.date() diff = (dt1 - dt).days age1 = int(diff) / 365.25 agey = round(int(diff) / 365.25, 0) agem = age1 - agey months = round(agem * 12) self.dob = "{:%d, %b %Y}".format(dt) self.age = str(math.floor(agey)) + ' yrs ' + str( math.floor(months)) + ' months ' admit = data['admit'] dt2 = datetime.datetime.strptime(admit, '%d/%m/%Y').date() dt3 = now.date() diff1 = (dt3 - dt2).days admit1 = int(diff1) / 365.25 admity = round(int(diff1) / 365.25, 0) admitm = admit1 - admity amonths = round(admitm * 12) self.admit = "{:%d, %b %Y}".format(dt2) self.admit_dur = str(math.floor(admity)) + ' yrs ' + str( math.floor(amonths)) + ' months ' self.data = data self.h1_box = QVBoxLayout() self.h2_box = QVBoxLayout() self.h3_box = QVBoxLayout() self.h4_box = QVBoxLayout() self.h5_box = QVBoxLayout() self.profileStack = QStackedWidget() bioText = QTextEdit(self) bioText.setMinimumWidth(self.minW) bioText.setMinimumHeight(self.maxW) bioText.setMaximumHeight(self.maxW) btext = self.buildBio() bioText.insertHtml(btext) bioText.setStyleSheet(self.textStyle) self.profileStack.setCurrentIndex(0) self.h1_box.addWidget(bioText) self.h1_box.setSizeConstraint(QLayout.SetFixedSize) self.doc1 = bioText self.academicText = QTextEdit() self.academicText.setMinimumWidth(self.minW) self.academicText.setMinimumHeight(self.maxW) self.academicText.setMaximumHeight(self.maxW) actext = self.buildBio() self.academicText.insertHtml(actext) self.academicText.setStyleSheet(self.textStyle) self.h2_box.addWidget(self.academicText) self.h2_box.setSizeConstraint(QLayout.SetFixedSize) self.doc2 = self.academicText self.affectiveText = QTextEdit() self.affectiveText.setMinimumWidth(self.minW) self.affectiveText.setMinimumHeight(self.maxW) self.affectiveText.setMaximumHeight(self.maxW) aftext = self.buildBio() self.affectiveText.insertHtml(aftext) self.affectiveText.setStyleSheet(self.textStyle) self.h3_box.addWidget(self.affectiveText) self.h3_box.setSizeConstraint(QLayout.SetFixedSize) self.doc3 = self.affectiveText self.psychomotorText = QTextEdit() self.psychomotorText.setMinimumWidth(self.minW) self.psychomotorText.setMinimumHeight(self.maxW) self.psychomotorText.setMaximumHeight(self.maxW) pstext = self.buildBio() self.psychomotorText.insertHtml(pstext) self.psychomotorText.setStyleSheet(self.textStyle) self.h4_box.addWidget(self.psychomotorText) self.h4_box.setSizeConstraint(QLayout.SetFixedSize) self.doc4 = self.psychomotorText self.feeText = QTextEdit() self.feeText.setMinimumWidth(self.minW) self.feeText.setMinimumHeight(self.maxW) self.feeText.setMaximumHeight(self.maxW) fetext = self.buildBio() self.feeText.insertHtml(fetext) self.feeText.setStyleSheet(self.textStyle) self.h5_box.addWidget(self.feeText) self.h5_box.setSizeConstraint(QLayout.SetFixedSize) self.doc5 = self.feeText scrollArea = QScrollArea(self) scrollArea.setWidgetResizable(True) scrollArea.setFixedHeight(700) scrollArea.setFixedWidth(700) bioProfileWidget = QWidget() academicProfileWidget = QWidget() affectiveProfileWidget = QWidget() psychomotorProfileWidget = QWidget() feeProfileWidget = QWidget() self.profileStack.addWidget(bioProfileWidget) self.profileStack.addWidget(academicProfileWidget) self.profileStack.addWidget(affectiveProfileWidget) self.profileStack.addWidget(psychomotorProfileWidget) self.profileStack.addWidget(feeProfileWidget) bioProfileWidget.setLayout(self.h1_box) academicProfileWidget.setLayout(self.h2_box) affectiveProfileWidget.setLayout(self.h3_box) psychomotorProfileWidget.setLayout(self.h4_box) feeProfileWidget.setLayout(self.h5_box) #Main layout Hbox = QVBoxLayout() Hbox.addWidget(menu) Hbox.addStretch() Hbox.addWidget(self.profileStack) Hbox.setContentsMargins(0, 0, 0, 0) #Create central widget, add layout and set central_widget = QWidget(scrollArea) scrollArea.setWidget(central_widget) central_widget.setContentsMargins(0, 0, 0, 0) central_widget.setGeometry(0, 0, 650, 700) central_widget.setStyleSheet("background-color: #ccc; color:#000") central_widget.setLayout(Hbox) self.setWindowTitle(fullnamex.title()) self.show()