def paintEvent(self, pe): if self._drop_zones_shown: painter = QPainter(self.viewport( )) # See documentation to know why I draw on the viewport painter.setFont(self._titles_font) vr = self.rect() nb_drop_zones = len(self._drop_zones_titles) subr = QRect(vr) subr.setHeight(vr.height() / nb_drop_zones) for i in range(nb_drop_zones): c = self._drop_zones_colors[i] text_pen = QPen() text_pen.setColor(inverse_colors(c)) painter.setPen(text_pen) if i == self._selected_drop_zone: # mainlog.debug("selected drop zone is {}".format(i)) c = c.lighter(200) painter.setBrush(c) subr.moveTop(int(i * vr.height() / nb_drop_zones)) painter.drawRect(subr) painter.drawText( QPoint(10, int((i + 0.5) * vr.height() / nb_drop_zones)), self._drop_zones_titles[i]) return None else: return super(AnimatedTableView, self).paintEvent(pe)
def _setupAnimation(self): self._load_animation = QPropertyAnimation(self._label_movie, "geometry") # since the opacity is failing, make it run out of the area! anim_label_geom = self._label_movie.geometry() self._load_animation.setStartValue(anim_label_geom) target_anim_geom = QRect(anim_label_geom) target_anim_geom.moveTop(self.height()) # make the animation target a rectangle that's directly under it but shifted downwards outside of parent self._load_animation.setEndValue(target_anim_geom) self._load_animation.setEasingCurve(QEasingCurve.InBack) self._load_animation.setDuration(1000) self._load_animation.finished.connect(self.animation_finished) self._load_animation.finished.connect(self._hideAnimLabel)