def paintEvent(self, event): """override the paint event to paint the 1/4 circle image.""" painter = QPainter(self) painter.setRenderHint(QPainter.SmoothPixmapTransform) painter.translate(self.pix.width() / 2, self.pix.height() / 2) painter.rotate(self._rotation) painter.drawPixmap(-self.pix.width() / 2, -self.pix.height() / 2, self.pix.width(), self.pix.height(), self.pix) painter.end() return super(MLoading, self).paintEvent(event)
def draw_empty_content(view, text=None, pix_map=None): from dayu_widgets import dayu_theme pix_map = pix_map or MPixmap('empty.svg') text = text or view.tr('No Data') painter = QPainter(view) font_metrics = painter.fontMetrics() painter.setPen(QPen(dayu_theme.secondary_text_color)) content_height = pix_map.height() + font_metrics.height() padding = 10 proper_min_size = min(view.height() - padding * 2, view.width() - padding * 2, content_height) if proper_min_size < content_height: pix_map = pix_map.scaledToHeight(proper_min_size - font_metrics.height(), Qt.SmoothTransformation) content_height = proper_min_size painter.drawText(view.width() / 2 - font_metrics.width(text) / 2, view.height() / 2 + content_height / 2 - font_metrics.height() / 2, text) painter.drawPixmap(view.width() / 2 - pix_map.width() / 2, view.height() / 2 - content_height / 2, pix_map) painter.end()