Coverage for modules/org/openteacher/interfaces/qt/percentNotesViewer/percentNotesViewer : 47%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
#! /usr/bin/env python3 # -*- coding: utf-8 -*-
# Copyright 2011-2012, Marten de Vries # # This file is part of OpenTeacher. # # OpenTeacher is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # OpenTeacher is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with OpenTeacher. If not, see <http://www.gnu.org/licenses/>.
super().__init__(*args, **kwargs)
self._notes = notes
self.setSizePolicy( QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Minimum )
w = len(self._notes) * self.BAR_SIZE + len(self._notes) * self.SPACING h = self.fontMetrics().height() + 2 * self.FONT_MARGIN return QtCore.QSize(w, h)
h = self.height()
p = QtGui.QPainter() p.begin(self)
#draw the bars p.setBrush(self.palette().highlight())
horPos = int(round(self.SPACING / 2.0)) for note in self._notes: barHeight = int(round(note / 100.0 * h)) p.setPen(QtCore.Qt.NoPen) p.drawRect(horPos, h, self.BAR_SIZE, -barHeight) p.setPen(QtGui.QPen(self.palette().highlightedText().color())) text = "%s%%" % note y = h - self.FONT_MARGIN #center on the bar x = horPos + self.BAR_SIZE / 2.0 - self.fontMetrics().width(text) / 2.0 p.drawText(x, y, text) horPos += self.BAR_SIZE + self.SPACING
p.end()
super().__init__(*args, **kwargs)
self.setFrameStyle(QtWidgets.QFrame.NoFrame)
graph = Graph(notes) self.setWidget(graph)
graphHeight = self.viewport().height() self.widget().resize(self.widget().width(), graphHeight)
super().resizeEvent(*args, **kwargs)
self._mm.mods(type="ui"), self._mm.mods(type="percentsCalculator"), )
global QtCore, QtGui, QtWidgets except ImportError: return global Graph, PercentNotesViewer
calculatePercents = self._modules.default( "active", type="percentsCalculator" ).calculatePercents return [calculatePercents(test) for test in tests]
return PercentNotesViewer(self._percentNotesFor(tests), *args, **kwargs)
|